I am trying to create a realtime timeseries graph using ZingChart. But I want it accumulative one in which all points accumulate as data appends. So I am using "appendseriesvalues" in each ajax poll to append data and m passing data as JSON object as (key, value) pair.
My code is as follows:
var chartData = {
"show-progress":false,
"gui":{
"behaviors":[
{
"id":"ZoomIn",
"enabled":"all"
},
{
"id":"ZoomOut",
"enabled":"all"
},
{
"id":"ShowAll",
"enabled":"all"
}
]
},
"type":"line",
// "utc":true, /* Force UTC time. */
// "timezone": -5,
"plotarea": {
"adjust-layout":true /* For automatic margin adjustment. */
},
"scale-x":{
"values": [],
"label":{ /* Add a scale title with a label object. */
"text":"Above is an example of a time-series scale",
},
"min-value":1420070400000, /* Unix timestamp for Jan 1, 2015. */
"step":"second",
"transform":{ /* Converts your Unix timestamp to a human readable format. */
"type":"date", /* Set your transform type to "date". */
"all":"%h:%i:%s" /* Specify your date/time format, using tokens. */
},
"line-color":"none",
"tick":{
"visible":false
},
"zooming":1,
"item":{
"font-color":"#000",
"visible":true
},
// "max-labels":10000,
"itemsOverlap": true
},
"scale-y":{
"zooming":1,
"items-overlap": true
},
"series":[
{
"values":[]
}
],
};
window.onload = function() {
zingchart.render({
id: "chartDiv",
data: chartData,
height: 600,
width: "100%"
});
};
setInterval(flashText, 1000);
function flashText() {
$.ajax({
type: "POST",
dataType: "json",
headers: {
Accept: "application/json",
"Access-Control-Allow-Origin": "*"
},
url: "TestServlet2",
success:function(data) {
$.each(data, function(key, value) {
zingchart.exec('chartDiv', 'appendseriesvalues', {
values: [[key,value]],
})
});
},
});
}
If I create using this code, it takes key and value as 2 values in series.I want to plot it as (key,value). Kindly suggest me what am doing wrong. Thanks in advance!