I want the data2 on second y axis data1 on first. And How I can have months name as x-axis titles?
`window.onload = function () {
var data = [];
var data2 = [];
var chartData = [
{
“January”:”1″,
“February”:”2″,
“March”:”3″,
“April”:”4″,
“May”:”5″,
“June”:”6″,
“July”:”7″,
“August”:”8″,
“September”:”9″,
“October”:”10″,
“November”:”11″,
“December”:”12″
},
{
“January”:”12″,
“February”:11″,
“March”:”10″,
“April”:”9″,
“May”:”8″,
“June”:”7″,
“July”:”6″,
“August”:”5″,
“September”:”4″,
“October”:”3″,
“November”:”2″,
“December”:”1″
}
]
for( var i=0; i<chartData.length; i++) {
var dataPoints = [];
for (var obj in chartData[i]) {
if(i == 0){
if (chartData[i].hasOwnProperty(obj)) {
dataPoints.push({x : chartData[obj], y: Number(chartData[i][obj])});
}
data.push({
type: “line”,
dataPoints: dataPoints
})
}
else
{
if (chartData[i].hasOwnProperty(obj)) {
dataPoints.push({x : chartData[obj], y: Number(chartData[i][obj])});
}
data2.push({
type: “line”,
dataPoints: dataPoints
})
}
}
}
var chart= new CanvasJS.Chart(“chartContainer”, {
title:{
text: “Multiple y – axis”
},
axisY2: {
},
axisY: {
},
data:data
});
chart.render();
-
This topic was modified 5 years, 7 months ago by coderrrr.