jsp - Google line chart x-axis shrinks on transition -
I am using a Google line chart on my page, which refreshes every 5 seconds but weird thing It is that every refresh chart causes the line to be removed, although the size of the chart remains the same.
My script -
google.load ('visualization', '1', {package: ['corechart']}); Google.setOnLoadCallback (drawLine); // call clickChart when the google.load () function meets the drawLine () {var gaugeData = new google.visualization.DataTable (); GaugeData.addColumn ('string', 'time'); // X-axis gazeta.dk column ('number', 'memory'); // Y-axis gazedata.edc column ('number', 'cpu'); // Y-axis square gauge option = {title: 'system description'}; // tile of var gauge chart; Var tempArray; // store json object value from server var tempArray2; // Server gauge = Modify the json object value = new google.visualization.LineChart (document.getElementById ('line_chart_div')); SetInterval (function () {$ ajax ({url:. "LineChart.jsp", // page from which json (new chart values) are cached: false, data: {search: "test"}, Datatype: "json", success: function (json2) {tempArray = (json2.Stats) .toString () partition. (","); // json2.Stats = "1: 45 | 34 | 56,1: 55 | 67 | 43, ....... "var colCount = 0; var I = 0; // rOWCOUNT gaugeData.addRows (tempArray.length); // // Length of the array = any row to insert (It is always constant) // tempArray2 = {"1:45", "34", "56"}; | ("") {tempArray2 = tempArray [i] .split (; I & lt; tempArray.length I ++ i = 0) for gaugeData.setValue (i, colCount ++, tempArray2 [0]); // column 1 gaugeData.setValue (i, colCount ++, parseInt (tempArray2 [1], 10)); // column2gaugeData.setValue (i, colCount ++, parseInt (TempArray2 [2], 10)); // column3 colCount = 0;} gauge.draw (gazetta, gauge option);}});}, 5000); } How do I stop it? : |
Found the solution I was constantly adding rows to DataTable without deleting old people P> Now I do this before updating the new value in the chart -
gaugeData.removeRows (0, tempArray. Length); //tempArray.length=no. of old rows
Comments
Post a Comment