Home Forums Report Bugs January 29-30-31

January 29-30-31

Viewing 3 posts - 1 through 3 (of 3 total)
  • #28254

    tnt

    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();

    Photo

    • This topic was modified 4 years, 2 months ago by tnt.
    • This topic was modified 4 years, 2 months ago by tnt.
    #28257

    tnt

    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();
    }             
    

    Photo

    #28270

    @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

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.