You must be logged in to post your query.
Home › Forums › Report Bugs › January 29-30-31
Tagged: bug
Is there any error in my code? I don’t understand why it appears as March and it should be on January.
window.onload = function() { var chart = new CanvasJS.Chart("chartContainer", { animationEnabled: true, axisX: { title: "", valueFormatString: "DD MMM" }, axisY: { includeZero:false, title: "Copas", ValueFormatString: "#####", }, data: [{ type: "splineArea", color: "rgba(54,158,173,.7)", xValueFormatString: "DD MMM", yValueFormatString: "#####", dataPoints: [ { x: new Date(2020, 01, 31), y: 13083},{ x: new Date(2020, 01, 20), y: 13089},{ x: new Date(2020, 01, 26), y: 13099}, ] }] }); chart.render();
Same here
window.onload = function() { var chart = new CanvasJS.Chart("chartContainer", { animationEnabled: true, axisX: { title: "", valueFormatString: "DD MMM" }, axisY: { includeZero:false, title: "Copas", ValueFormatString: "#####", }, data: [{ type: "splineArea", color: "rgba(54,158,173,.7)", xValueFormatString: "DD MMM", yValueFormatString: "#####", dataPoints: [ { x: new Date(2020, 01, 30), y: 13020},{ x: new Date(2020, 01, 31), y: 13083}, ] }] }); chart.render(); }
@tnt,
In JavaScript Month starts from 0 (January) and ends at 11(December). So in your case, new Date(2020, 01, 30) and new Date(2020, 01, 31) represents 1st of March and 2nd March respectively. Changing new Date(2020, 01, 30) to new Date(2020, 00, 30) and new Date(2020, 01, 31) to new Date(2020, 00, 31) should work fine in your case.
—- Manoj Mohan Team CanvasJS
You must be logged in to reply to this topic. Login/Register