How to rewrite the javascript template string -
i'm trying modify code https://github.com/airblade/chartjs-ror/blob/master/vendor/assets/javascripts/chart.js
i need rewrite original string template tooltiptemplate: "<%=datasetlabel%> - <%= value %>"
, want add if else condition
it.
but template string
complex
how rewrite following logic ?
my rough logic is
if ( %value > 0) {%datasetlabel - %value} else { %datasetlabel - "empty value" }
% means variable in above logic
i guess can (untested code, idea):
yourtemplate: "<%if (value > 0){%>" + "<%= datasetlabel - value %>" + "<%}%>" + "<%else {%>" + "<%= datasetlabel - \"empty value\"%>" + "<%}%>"
Comments
Post a Comment