You must be logged in to post your query.
Home › Forums › Chart Support › Pie Chart Issue
Tagged: pie chart
Dear Support, I am trying to generate the pie chart. But I am facing the problem while passing the array values. Please check the http://jsfiddle.net/f0xetdmh/7/
Thanking you.
Regards, Ashish Potdar.
@ashish-potdar,
dataPoints should be an array, but we observe that you are passing string instead of array. Please check this updated jsfiddle.
— Vishwas R Team CanvasJS
Thank Vishwas, for your quick reply. But I am passing the values dynamically to js function. Then array is not getting created. Please look into given below example.
http://jsfiddle.net/f0xetdmh/10/
Waiting for your reply.
Thanks.
The dataPoints you pass to the chart must be an array of objects and not a string.
var ChartVal = document.getElementById("txtMyVal").value; // String
First you need to parse the string you get from your input field to a valid JSON and then parse the JSON to get the object which you can pass to the chart. For converting the string to valid JSON, you can enclose the values y, label, legendText in quotes in the input field. Please check this jsfiddle.
—– Suyash Singh Team CanvasJS
Thanks Suyash. Your solution is working very well.
You must be logged in to reply to this topic. Login/Register