i am trying to figure out how to input data values into highcharts. Firstly i have a home object(@home) that has many energies(energy table consists of three columns, namely, consumption, home_id and consumption_date)
This is what i have so far:
<script type="text/javascript">
var chart;
$(function() {
new Highcharts.Chart({
chart: {
renderTo: "consumption_chart",
},
title: {
text: "Consumption - <%= @home.name %>"
},
xAxis: {
type: 'datetime',
},
yAxis: {
title: {
text: "Power"
}
},
series: [{
data: <%= @data_set %>
}]
});
});
</script>
For the data part i get all the values like this
@data_set = @home.energies.collect{|e| e.consumption_date.utc}.zip(@home.energies.collect{|g| g.consumption})
This returns a nested set of arrays like this:
[[2012-03-02 09:06:00 UTC, 1200], [2012-04-30 00:00:00 UTC, 1145], [2012-04-30 00:00:00 UTC, 1158], [2012-05-31 00:00:00 UTC, 1145]]
Each nested array is just of the form [consumption_date, consumption]. However this does not work(chart does not render any data), please can someone point out my errors and tell me what i am doing incorrectly. thanks