I am trying to create a custom tooltip for each data point of a line chart via HighCharts and Ruby on Rails, in the fashion of this thread:
Set Additional Data to highcharts series
To summarize that thread, the responders suggest inputting additional data to the series via a hash. A custom field called "myData" holds the additional data that is used in the tooltip:
new Highcharts.Chart( {
...,
series: [{
name: 'Foo',
data: [ { y : 3, myData : 'firstPoint' },
{ y : 7, myData : 'secondPoint' },
{ y : 1, myData : 'thirdPoint' } ]
}]
tooltip: {
formatter: function() {
return 'Extra data: <b>'+ this.point.myData +'</b>';
}
} );
I have used that code successfully when the data field of myData (ie #{i.extraData}) is an integer:
series: [{
data: [ <%@show.each do |i| %> { x: <%="#{i.year}, y: #{i.maturity},
myData: #{i.extraData}"%>},<%end%>]
}]
In that case, my line chart shows up correctly on the x and y access, and the tooltip contains the integer of i.extraData as expected.
But here is my issue. Let's say the custom tooltip I want is not an integer like i.extraData, and is instead a string. In that case, my code breaks. I have tried including single quotations around the string version of #{i.extraData}, but my code remains broken. I don't understand how to edit this section of code so that the string inside the #{} enters the hash and can be read by the tooltip.
Thanks so much for considering my question!