我有一个带有一些查询的数组,可用作 Highcharts 中的数据
Ruby 数组是 @report
subscriptions.each do |data|
idx = data['index'].gsub(/-/, '').to_i
@report['summary'][idx] ||= {}
@report['summary'][idx]['total_month'] ||= 0
@report['summary'][idx]['year'] = data['year']
@report['summary'][idx]['month'] = data['month']
@report['summary'][idx]['day'] = data['day']
@report['summary'][idx]['hour'] = data['hour']
@report['summary'][idx]['total_month'] += data['quantity'].to_i
@report['summary'][idx][data['operator']] = data['quantity']
@report['total'][data['operator']] += data['quantity'].to_i
@report['total']['global'] += data['quantity'].to_i
end
而Highchart脚本是......
$(document).ready(function() {
var chart1 = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'line'
},
title: {
text: <%= @subservice.service.name %>
},
xAxis: {
categories: ['Year', 'Month']
},
yAxis: {
title: {
text: 'total'
}
},
series: [{
name: 'total',
data: <%= @report["total"].to_json %>
}]
});
})
我如何打印@report 值?