Answered: How to create series for chart dynamically
Answered: How to create series for chart dynamically
I am trying to genrate the series of a line chart dynamically. The requirement is to generate the line on Y-axis, dependending upon the number of series user asks for. I do some processing in a java script function and it genrates a JSON string for the series. Now, when I copy paste the same string and try to generate the chart it works. The same doesn't work if I directly try to use the string which is formed by the JS function. I get the error : "series.type is undefined" on Mozilla firefox error console. Please suggest, what's worong I am doing? Is there any other way of doing what generateSeries() does here. Please avise.
for (var i=0; i < yAxisStringArray.length; i++) {
var chartSeries = yAxisStringArray[i];
// var cylon = (i + 1) % 2 == 0; //every second man is a toaster alert('chartSeries ' + i+'=' +chartSeries);
}
}
});
});
</script> <!-- HTML Code -->
</head>
<body id="docbody">
<h1>Line Chart Example</h1>
<div style="margin: 10px;">
<p>
Display 2 sets of random data in a line series. Reload data will randomly generate a new set of data in the store. Click on the legend items to remove them from the chart. <a href="Line.js">View Source</a>
I resolved the problem by converting the json string for series into json object, using below line of code just before returning from generateSeries( ):
series= eval('(' + series + ')');
Still, any other suggestion or solution is welcome!
I resolved the problem by converting the json string for series into json object, using below line of code just before returning from generateSeries( ):
series= eval('(' + series + ')');
Still, any other suggestion or solution is welcome!