Seem to be struggling to get my data in the correct format for use with a highchart’s pie chart.
If I force the data as follows my graph appears so I know I’ve done the integration correctly:
data: [
['Test', 30],
['Other', 70],
]
But when I try and use my actual data, it ain’t working.
I’ve tried the following which doesn’t work:
data: <%= Location.browsers.map { |o| [o.type, o.count] }.inspect %>
Have also tried:
data: <%= Location.browsers.map { |o| "#{o.type}, #{o.count}" }.to_json %>
The first one gives me a result like this:
"[[\"Safari\", 6448], [\"Microsoft\", 5253], [\"Microsoft-CryptoAPI\", 5185], [\"Dalvik\", 3870], [\"Chrome\", 3701], [\"Mozilla\", 3239], [\"Android\", 2285], [\"Windows-Update-Agent\", 2018], [\"Internet Explorer\", 1843], [\"Firefox\", 1459]]"
Which looks ok.
What’s the correct way to run this query?
or
should work.