I have an array fetched from
<div style='hidden' id=dataHours data-hours='{"08":3,"10":3,"11":1,"12":1,"14":2,"16":2,"18":1}'>
It is converted to json array .
I would like to use jqplot to create an matrix with x-axis as hours an y-axis as number of events.
I currently tries this code:
var json_data = $('#dataHours').data('hours');
var dateHoursArray = $.map(json_data, function(value, index) {
return [[index,value]];
});
console.log(dateHoursArray);
$.jqplot('maindiv', dateHoursArray, {
legend: {
show:true,
location : 'ne'
},
title: 'Tickets created per hour',
animate: true,
animateReplot: true,
axes: {
xaxis: {
label:'Hours',
autoscale: true,
min:0,
max:23,
rendererOptions: {
tickRenderer:$.jqplot.CanvasAxisTickRenderer
},
tickOptions: {
formatString:'%.0f'
}
},
yaxis: {
label:'Tickets',
autoscale: true
}
},
highlighter: {
sizeAdjust: 7.5
},
cursor: {
show: false
},
grid: {
gridLineColor: '#cccccc',
background: '#fff',
borderColor: '#000',
borderWidth: 2.0,
shadow: false,
}
});
But it does not work as I would like to expect.
Anyone?
Logic.
Created an array of 24 hours and walked through array to increase counter on matching hour:
Then Javascripted the base64_encoded json_encoded $dates_sum array:
Took me a few trial and errors on the last line of Array.from ;)