I need to display a dataset as a Highcharts column chart. I don't know how to pass the data to the Javascript method of Highcharts to display my Business Process score regarding the day.
The dataset is built in my BusinessProcess controller:
@business_process_history = DmMeasure.where("period_id between ? and ? and ODQ_object_id = ?", first_period_id, current_period_id, "BP-#{@business_process.id}").select("period_day, score").order("period_id")
This gives the expected 2 fields, 10 records result and would perfectly display in a HTML table.
UPDATE :
The suggestion by Tobago gives the expected array of arrays,
[["20140820", #<BigDecimal:54655c8,'0.997E2',18(45)>], ...]
but the issue is not solved.
Here is the function call including suggestion from Tobago:
<script>
$(function () {
$('#measures').highcharts({
chart: {type: 'column'},
title: {text: 'Data quality trend'},
xAxis: {
title: {text: 'Time'}
},
yAxis: {
title: {text: 'Score'}
},
series: [{
data: <%= @business_process_history.map { |bp| [bp.period_day, bp.score] } %>
}]
});
});
</script>
this script produces nothing in the measures DIV, while a hardcoded list of values does generate a graph.
I tried several ways to do it, but still I can't manage.
Can you help me on this ?
Thanks a lot,
Best regards,
Fred