xValueType: String

This defines the data type of x values. Data Type is normally figured out by default based on the object type that is assigned to x. But if you are providing time stamp (which is integer) values instead of Date objects, you’ll have to explicitly set the xValueType to “dateTime”.

Default: Automatically Calculated
Options: “number”, “dateTime”
Note
var  chart =  new  CanvasJS.Chart("container",
{
 .
 .
 data: [{
   xValueType: "dateTime",

  },
 ]
 .
 .
});
chart.render();

Try Editing The Code


If you have any questions, please feel free to ask in our forums.Ask Question

8 Comments

  1. Chris says:

    How do I make the xValueType a string? For example, I am trying to refer to academic school years such as 11-12 and 12-13, but the chart keeps trying to do subtractions for each year. I want the string “11-12” to show up as the first x data point. Thanks.

  2. Santosh says:

    I want to show my axis in HH:MM format and zooming the same it should show HH:mm:ss format.how I could do this. Kindly advice asap?

  3. Anjali says:

    This behaviour is not possible as of now. But we will provide a way to do this from next version.

  4. simmi says:

    how can i use time instead of years?
    i need to show time like 07:11:35 07:11:37 on X-axis.
    Please help

If you have any questions, please feel free to ask in our forums. Ask Question