Thank you Indranil!
What if we are getting the entire array of data again instead of just one more stick info at a time? Keep in mind I am trying to make a Dynamic candle stick chart that renders stock prices.
1. Should we clear the chart? right now it plots the data right on top of the last data?
2. I tried (and it didn’t work) in the ajax
chart.options.data[0].dps = data;
chart.render();
3. I also tried to set dps to [] reset the array to clear the chart to no avail.
Let me know,
thanks
anyone??
not sure why second reply got deleted but here is the TEXT i am sending back via my ajax call:
[{x:0,y:[3883.7885, 3882.9883,3882.9881,3882.9883]},{x: 1,y:[3882.9883, 3883.7885,3883.7883,3883.7885]},{x: 2,y:[3883.7885, 3884.6880,3878.8861,3884.6880]},{x: 3,y:[3884.6880, 3881.6886,3880.9860,3881.6886]},{x: 4,y:[3881.6886, 3880.9860,3880.9860,3880.9860]},{x: 5,y:[3880.9860, 3881.1866,3878.3853,3881.1866]},{x: 6,y:[3881.1866, 3879.0869,3879.0863,3879.0869]},{x: 7,y:[3879.0869, 3880.2850,3878.0851,3880.2850]},{x: 8,y:[3880.2850, 3878.0851,3877.9851,3878.0851]},{x: 9,y:[3878.0851, 3877.9851,3877.9853,3877.9851]},{x: 10,y:[3877.9851, 3882.7873,3882.4878,3882.7873]},{x: 11,y:[3882.7873, 3883.1879,3883.0877,3883.1879]},{x: 12,y:[3883.1879, 3883.6876,3882.1863,3883.6876]},{x: 13,y:[3883.6876, 3882.2879,3882.2860,3882.2879]},{x: 14,y:[3882.2879, 3885.4881,3884.9871,3885.4881]},{x: 15,y:[3885.4881, 3886.5889,3886.1881,3886.5889]},{x: 16,y:[3886.5889, 3886.2882,3886.1886,3886.2882]},{x: 17,y:[3886.2882, 3886.2881,3886.1883,3886.2881]},{x: 18,y:[3886.2881, 3886.7886,3886.8891,3886.7886]},{x: 19,y:[3886.7886, 3886.9891,3886.1895,3886.9891]},{x: 20,y:[3886.9891, 3888.9890,3888.9800,3888.9890]},{x: 21,y:[3888.9890, 3891.0896,3891.2100,3891.0896]},{x: 22,y:[3891.0896, 3892.1894,3892.1893,3892.1894]}]
and here is the code that is trying to refresh the graph, dps is global and so is chart
var dps;
var chart;
function getValuesChart() {
var scriptUrl = “controller.php?route=graph”;
$.ajax({
url: scriptUrl,
type: ‘get’,
dataType: ‘text’,
async: false,
success: function(data) {
dps = data;
}
});
chart.render();
}
I have tried the following strings (returned from ajax call):
[{“x”:0,”y”:[3879.0850, 3875.1865,3875.1860,3875.1865]},{“x”: 1,”y”:[3875.1865, 3879.0850,3879.0800,3879.0850]},{“x”: 2,”y”:[3879.0850, 3882.9883,3882.9881,3882.9883]},{“x”: 3,”y”:[3882.9883, 3883.7885,3883.7883,3883.7885]},{“x”: 4,”y”:[3883.7885, 3884.6880,3878.8861,3884.6880]},{“x”: 5,”y”:[3884.6880, 3881.6886,3880.9860,3881.6886]},{“x”: 6,”y”:[3881.6886, 3880.9860,3880.9860,3880.9860]},{“x”: 7,”y”:[3880.9860, 3881.1866,3878.3853,3881.1866]},{“x”: 8,”y”:[3881.1866, 3879.0869,3879.0863,3879.0869]},{“x”: 9,”y”:[3879.0869, 3880.2850,3878.0851,3880.2850]},{“x”: 10,”y”:[3880.2850, 3878.0851,3877.9851,3878.0851]},{“x”: 11,”y”:[3878.0851, 3877.9851,3877.9853,3877.9851]},{“x”: 12,”y”:[3877.9851, 3882.7873,3882.4878,3882.7873]},{“x”: 13,”y”:[3882.7873, 3883.1879,3883.0877,3883.1879]},{“x”: 14,”y”:[3883.1879, 3883.6876,3882.1863,3883.6876]},{“x”: 15,”y”:[3883.6876, 3882.2879,3882.2860,3882.2879]},{“x”: 16,”y”:[3882.2879, 3885.4881,3884.9871,3885.4881]},{“x”: 17,”y”:[3885.4881, 3886.5889,3886.1881,3886.5889]},{“x”: 18,”y”:[3886.5889, 3886.2882,3886.1886,3886.2882]}]
dps is global
chart is global
—–pasted—-
var dps;
var chart;
function getValuesChart() {
var scriptUrl = “controller.php?route=graph”;
$.ajax({
url: scriptUrl,
type: ‘get’,
dataType: ‘text’,
async: false,
success: function(data) {
dps = data;
}
});
chart.render();
}
nothing is plotted.