mardi 26 janvier 2016

Ember c3 custom tooltip

I'm using ember-c3 addon (http://ift.tt/1QBduxP) in my ember-cli app to create a chart, so far now it works pretty well, but now i want to create a custom tooltip

{{c3-chart
  data=data
  tooltip=tooltip
}}

i'm using a controller computed property to define data, and wanted to do the same for tooltip this way (to create a custom tooltip is needed an object with a contents property with html value)

tooltip: Ember.computed('model', function() {
    return {
        contents: function (d, defaultTitleFormat, defaultValueFormat, color) {
            return '<div>HTML</div>';
        }
    };
})

But i was wondering how to get a raw template so i don't need to write plain HTML in my controller and achieve something like this

tooltip: Ember.computed('model', function() {
    var html = ...; // How to get a raw template from templates folder?
    return {
        contents: function (d, defaultTitleFormat, defaultValueFormat, color) {
            return html;
        }
    };
})

template might depend on some other variables but the idea is to be able to get the raw html from the template file.

Any guidance will be appreciated!

Thanks in advance.




Aucun commentaire:

Enregistrer un commentaire