I’m creating a column chart with data:
{
xValueFormatString: "MMM YYYY",
dataPoints: [
{ x: new Date(2024, 0), y: 71 },
{ x: new Date(2024, 1), y: 79 }
]
}
xValueFormatString
is not working to format the x values and chart shows range of dates that doesn’t belong to the dataPoints.
I also tried to do the xAxis ValueFormatString
property but it doesn’t seem to work also.
https://jsfiddle.net/pcha1xf5/2/
Can you help me please?
2
Answers
Here's a working solution in case you have encountered the same issue:
In
dataPoints
, I used thelabel
property instead of usingx
. Then added anxAxis
label formatter for the date label:Here's the fiddle for reference: https://jsfiddle.net/w8dbzfnc/3/
I am still not sure why using
x
indataPoints
mess up thexAxis
labels showing range of dates that aren't part of the data set. Please let me knowFormat defined in xValueFormatString is applied for x-value shown in Tooltip & indexlabels. To format axis labels, you need to use valueFormatString in axisX. Along with valueFormatString, you can set interval to 1 month so that labels doesn’t repeat.