Hi everybody,
I'm new here, just signed up, and am %100 new to highcharts...
I don't have much experience with javascript nor JSON,
but I do have PHP/MySQL development experience....
I need some help getting started, i've consulted the documentation and it's just really hard for me to find what i need...
If you look at this graph, it's one of the highcharts-stock demos that loads the data it needs from the server via a JSON query (I suppose),
and it only loads what it needs to show the graph of the selected time-range, as the total data set on the server is, according
to the link on the left 1.7 million points, so it's loaded on an as needed, asyncronous basis.
The data url is in the top of the code:
const dataURL = 'https://demo-live-data.highcharts.com/a ... rical.json';
And the code that reloads the data whenever the chart's view is changed by the user is (i assume) here:
function afterSetExtremes(e) {
const { chart } = e.target;
chart.showLoading('Loading data from server...');
fetch(`${dataURL}?start=${Math.round(e.min)}&end=${Math.round(e.max)}`)
.then(res => res.ok && res.json())
.then(data => {
chart.series[0].setData(data);
chart.hideLoading();
}).catch(error => console.error(error.message));
}
So, I assume it composes a HTTP GET request like: GET https://demo-live-data.highcharts.com/a ... (something???)
What I would like to do is to use the highchart-stock as is, it looks good and does everything I want it to do,
I've already integrated it into my site and adjusted the look/colours etc,
but, offcourse, I want it to load data from my MySQL database which holds many millions of key/value pairs (a datetime with microseconds of precision, and a floating point value),
in a large mysql table.
So, I will need to write some PHP code that does the SQL query on my database (a select that returns only what the chart needs with it's "start" and "end" values) to get the key/value pairs that the highcharts-stock graph needs at that moment via this JSON query,
and then generates a JSON content type return data that contains the correct JSON pairs / syntax etc... for the chart to update it's graph.
I've no idea what this all looks like.
If you look at my "So, I assume it composes a HTTP GET request like:" above,
what are the (something???), I assume these are beginning and end dates, but i've no idea what format they are, eg, are they unix timestamps, or some kind of formatted date/time string ?
If somebody could explain what the "start" and "end" values in that GET request would be, just an example so i know the syntax and I can build my own JSON server that understands the begin and end values,
and, if somebody also could show me an example of what I should return, eg how are the key/value pairs named or what is their syntax ?
I have NEVER written any javascript before, however i'm a proficient C/C++ programmer and used to program PHP for a living a long time ago, so, with some answers to these questions from someone who
knows what to do, I'm sure I can get this working...
So please if you explain, try to explain thing verbosely, as I do not know much about javascript at all, nor much about highcharts...
So please, if anybody can explain and shed some light on this,
I can hopefully get this going and have the highcharts-stock display my own data from my mysql database...
Thank you,
Terrence