Reputation: 5619
I've got a rails application and I want to use char.js to generate some charts. That works fine.
But now I have to set up some option to configure chart options.
I want to customize the tooltip.
I want that the legend colors are the same like in the chart. How can I do this?
in case of this I have to do something like that:
window.myLine = new Chart(weekdayChart).Line(weekdayChartData, {
responsive: true,
animation: true,
legendTemplate : "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<segments.length; i++){%><li><span style=\"background-color:<%=segments[i].fillColor%>\"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>" });
problem here are the <%= because they are normaly rails outputs in the view ... how can I solve this problem?
Upvotes: 0
Views: 466
Reputation: 11689
If the file name ends with .js
you are fine, no need to deal with <%=
. However if the file ends with .js.erb
, you are going to have problems.
Considering you don't need ERB
in this case (you don't use it at all), I highly suggest renaming the file to end with .js
Upvotes: 1