score:2
So in your php file....
Add a line at the bottom that converts the table to json data. And give it a variable...
$table = array();
while($row = mysqli_fetch_assoc($result) )
{
$value=$row['value'];
$date=$row['date'];
$table[$value]=$date;
}
$jsondata = json_encode($table);
Then in your other file.... echo that variable into your data object, in the javascript. Remember to remove that whole random number generating function...(its just an example)
Echoing PHP into javascript is definitely not considered good practice though. And it would be better to actually do an ajax call to your php file, and insert like that....I'll also show you how to do ajax.
<?php include 'test.php'; ?>
...
data: [<?php echo $jsondata;?>], //remove that function that was here..
// it was just to generate random numbers for the demo
....
}
EDIT / UPDATE For ajax...
So for ajax...instead of assigning a variable to $jsondata. Just return it like so...(in your PHP file)
return json_encode($table);
Then for this way....you dont include('test.php')
like you did before.
Instead you just have this script inside your $(document).ready(function(){....
$.getJSON('test.php', function(myJSON) {
//and inside this function you put your highcharts stuff...
//remove that function() that generates random data
// And you will put the 'myJSON' return object inside the 'data':[] array...
// Provided you have structured your data correctly for highcharts, it should work...
// If not.... it'll be a start, and you're well on your way to debugging it
}
Source: stackoverflow.com
Related Articles
- JavaScript PHP HighChart transform a PHP array to a javascript array
- array and object handling in javascript for getting highchart json data
- How to convert php array into javascript array for Highchart JS
- Highchart doesn't show the graph : error adding javascript array in series
- Array not in correct format in Javascript for use by HighChart
- How to pass JSP array to Javascript of highchart to generate a column chart
- Highchart series update in javascript
- Optimize JavaScript DrillDown code
- DB Array to expected javascript format
- How to convert a JavaScript object to array
- JavaScript code inside TypeScript file .ts not working
- Print Array in HighChart
- Highchart Zoom and X-Axis with String Array for Categories
- Adding data to a highchart chart using an array with IDs
- javascript variable not works in Highchart
- c# WPF Webbrowser with Highchart, Javascript from external source not working "An error has occurred in the script on this page"
- Transform array of objects into a transposed array of objects
- Highchart : Json Array For ToolTip
- Javascript - How to display a specific index of an array on Highcharts?
- Passing data to highcharts from javascript array or variable
- Ruby on Rails: Passing string array to highchart function
- Complicated multidimensional array to use in highchart series
- Javascript - Highcharts - input data array of arrays
- Highcharts Graph displaying 0 value continuously : Javascript Array
- Update Series Array on HighChart after editing chart
- how to add items to an array dynamically in javascript
- passing formatting JavaScript code to HighCharts with JSON
- Embed javascript code in a django template
- How would I convert this array to usable javascript array?
- Concatenate strings into an array in javascript
- Chart not moving fluently when adding value to two lines on interval
- Pie Graph Click in Highcharts
- Highcharts donut label overflow container
- highcharts symbols without connected lines
- ReferenceError: Highcharts is not defined when using lollipop series in react
- Highcharts: Y axis label formatter
- how do you call getJSON inside the highchart section
- Highcarts - Have datetime xaxis start on certain month
- Unable to add tooltip for titles in highcharts
- Place Highstock inside a SVG
- How do I add secondary axis to highstock charts?
- Highcharts - highlight mouse position within a range
- Highstock How to remove the cross icon in Range selector text box in IE
- R Highcharter: Formatting dual y-Axis chart
- Ugly Highchart when using letter label for both xaxis and yaxis
- how to give different names on tooltip for one series in highcharts R
- link 2 different types of highcharts data
- Highstock data input with csvURL only allows a limited number of rows
- React Component, Highstock: Synchronize multiple charts?
- How can you change the "label" (valueSuffix) on a highcharts gauge after the gauge has been created?