Home › Forums › Chart Support › How can I plot my values from my local storage using JSON Objects? › Reply To: How can I plot my values from my local storage using JSON Objects?
var jsonData = { “December”: [ { “x”: “1st”, “y”: 10.22 }, { “x”: “2nd”, “y”: 11.14 }, { “x”: “3rd”, “y”: 13.58 }, { “x”: “4th”, “y”: 15.25 }, { “x”: “5th”, “y”: 17.25 }, { “x”: “6th”, “y”: 10.22 }, { “x”: “7th”, “y”: 11.14 }, { “x”: “8th”, “y”: 13.58 }, { “x”: “9th”, “y”: 15.25 }, { “x”: “10th”, “y”: 17.25 }, { “x”: “11th”, “y”: 10.22 }, { “x”: “12th”, “y”: 11.14 }, { “x”: “13th”, “y”: 13.58 }, { “x”: “14th”, “y”: 15.25 }, { “x”: “15th”, “y”: 17.25 }, { “x”: “16th”, “y”: 10.22 }, { “x”: “17th”, “y”: 11.14 }, { “x”: “18th”, “y”: 13.58 }, { “x”: “19th”, “y”: 15.25 }, { “x”: “20th”, “y”: 17.25 }, { “x”: “21st”, “y”: 10.22 }, { “x”: “22nd”, “y”: 11.14 }, { “x”: “23rd”, “y”: 13.58 }, { “x”: “24th”, “y”: 15.25 }, { “x”: “25th”, “y”: 17.25 }, { “x”: “26th”, “y”: 10.22 }, { “x”: “27th”, “y”: 11.14 }, { “x”: “28th”, “y”: 13.58 }, { “x”: “29th”, “y”: 15.25 }, { “x”: “30th”, “y”: 17.25 }, { “x”: “31st”, “y”: 17.25 } ]} var dataPoints = []; var chartformonth = new CanvasJS.Chart(“profitformonth”, { title: { text: “Profit For Month” }, axisX: { interval: 1, intervalType: “day” }, axisY: { gridColor: “white”, interval: 10, minimum: 10, maximum: 100 }, data: [{ type: ‘column’, dataPoints: dataPoints }] });
$(“.dropdown”).change(function () { chartformonth.options.data[0].dataPoints = []; var e = document.getElementById(“selectMonthList”); var selected = e.options[e.selectedIndex].value; dps = jsonData[selected]; for (var i in dps) { chartformonth.options.data[0].dataPoints.push({ x: dps[i].x, y: dps[i].y }); } chartformonth.render(); }); There a problem in the loop data not rendering on chart, bolded that area above area is correct. plz help!