Home forums Using CanvasJS Time axis with valueFormatString not working

Tagged: 

This topic contains 1 reply, has 2 voices, and was last updated by  Indranil Deo 8 months, 3 weeks ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #19241

    ahmedcharef
    Member

    Hi I want to render a time axis chart,

    var chart = new CanvasJS.Chart("rssi",{
    		exportEnabled: true,
    		zoomEnabled: true,
    		title:{
    			text:"RSSI signal / Date time"
    	     },
    	     axisX: {
            	intervalType: "hour",
            	valueFormatString: "YYYY-MM-DD HH:mm:ss",
            	labelMaxWidth: 100, // change label width accordingly
          	    },
    	    axisY: {
    	        title: "Downloads"
    	    },
    		data: [{
    			type: "area",
    			name:" RSSI value",
    			showInLegend: true,
    			xValueType: "dateTime",
    			markerType: "square",
    			color: "#F08080",
    			dataPoints : dataPoint
    		}]
    	});
    	chart.render();

    Here is my datapoints:

    0: Object { x: Date 2018-01-07T20:51:41.000Z, y: -67 }
    1: Object { x: Date 2018-01-07T20:51:05.000Z, y: -6 }
    2: Object { x: Date 2018-01-07T20:51:05.000Z, y: -21 }
    3: Object { x: Date 2018-01-07T20:51:05.000Z, y: -29 }
    4: Object { x: Date 2018-01-07T20:51:06.000Z, y: -44 }

    result
    https://screenshots.firefox.com/2QL0FQlVN0walVDx/null

    • This topic was modified 8 months, 3 weeks ago by  ahmedcharef.
    #19284

    Indranil Deo
    Member

    @ahmedcharef,

    Passing the Date to dataPoints in the standard JavaScript DateTime format new Date("2018-01-07T20:51:05.000Z") will work fine in your case. Please take a look at this jsfiddle.

    ___________
    Indranil Deo,
    Team CanvasJS

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

You must be logged in to reply to this topic.