Hi,
i'm trying to implement a flot.js graph using a custom php array as data.
Here is what i've done :
<?php
foreach ( $dynamic_prices as $limit => $price ):
$coordonnees[] = array($limit,$price);
endforeach;
?>
<?php
echo json_encode(($coordonnees), JSON_NUMERIC_CHECK);
?>
This code outputs : [[5,9],[6,8]]
is it the right format ? I think it is if i believe the flot.js documentation.
Then my JQuery :
<script type="text/javascript">
$(document).ready(function () {
var test = <?php echo $coordonnees ?>;
var graphData = [{
"label": "Paliers",
"data": <?php echo $coordonnees ?>,
color: '#71c73e'
}];
$.plot($('#graph-lines'), graphData, {
series: {
points: {
show: true,
radius: 5
},
lines: {
show: true
},
shadowSize: 0
},
grid: {
color: '#646464',
borderColor: 'transparent',
borderWidth: 20,
hoverable: true
},
xaxis: {
tickColor: 'transparent',
tickDecimals: 0
},
yaxis: {
tickSize: 5,
tickDecimals: 0
}
});
Any idea to fix this ?
Thanks !