Home Forums Report Bugs X-axis labels are not aligned vertical with the data points Reply To: X-axis labels are not aligned vertical with the data points

#20347

@Vishwas R Thanks for the reply, but we need date time in X-axis, we can’t change it as the label, bcz date time values getting from the server.

We are working on Licenced Version CanvasJs

please look the following code, I have removed all unwanted lines, please play with that code

Also the same thing will work if we apply new Date(2011,01,01) format, then why it is not working in following format x: new Date(“2018-04-09”)

var chart = new CanvasJS.Chart(“chartContainer”,
{
dataPointMaxWidth: 15,
axisX: {
interval: 1,
intervalType: “day”,
valueFormatString: “M/D”,
},

axisY: {
title: “count”,
gridColor: “#CCC”
},

data: [
{
showInLegend: true,
type: “column”,
legendText: “Units”,
dataPoints: [
{
x: new Date(“2018-04-09”),
y: 32
},
{
x: new Date(“2018-04-10”),
y: 1
}],
}],

});

—————————————————————————————————-

if you change dataPoint with following format, it will work fine

dataPoints: [
{
x: new Date(2018,04,09),
y: 32
},
{
x: new Date(2018,04,10),
y: 1
}],

  • This reply was modified 6 years ago by mhdajmalik.
  • This reply was modified 6 years ago by mhdajmalik.