in my controller I have an array that I populated from my database and saved, which looks like this and is called dataset2
array(2) {
["April"]=> int(92)
["May"]=> int(86)
}
In my view, I can dd {{}} in an array and see that it is a structure.
Now I want to convert it to a javascript array so that I can use the fleet to turn it into a graph.
my javascript in my view is as follows
<script language="javascript" type="text/javascript">
$(function () {
var data1 = [
["April", 13],
["May", 20],
];
var data2 = [<?php echo json_encode($dataset2 );?>];
$.plot("#placeholder", [{
data: data1,
label: "NewBeach"
}, {
data: data2,
label: "Sandhills"
}], {
series: {
lines: { show: true },
points: {
show: true,
barWidth: 0.1,
align: "center"
}
},
xaxis: {
mode: "categories"
},
yaxis: {
},
grid: {
hoverable: true,
clickable: true
}
});
});
</script>
Is there something I am missing when converting ?, since it does not draw anything with the JSON_encode array, but does it with hard-coded. From what I read, it seems like that's all I need. Is it because of the values ββin my array?
Regards Mike
Mike