I am trying to make a flot chart using values from MySQL database. SO i did
//creating array of pairs of x and y values
$dataArray = array();
while ($row = mysql_fetch_assoc()) { //or whatever
$dataArray[] = array( $row['xvalue'], $row['yvalue'] );
}
?>
<script type="text/javascript">
//puting array in javascript
var dataArray = <?php echo json_encode($dataArray); ?>;
//ploting the graph
$(function () {
$.plot($("#placeholder"), [ dataArray ]);
});
</script>
Everything works fine
But now the problem is in modifying the values(contents) of “$dataArray” .
I want to modify all the yvalues while xvalue remains same.
you could use array_walk_recursive. IN this example i create an array with x/y values and calculate add 1000 to the y value:
returns: