Hello Guys
Here I bring another question regarding to Date type on charts when displaying data.
I am supposed to have on X axis the fist and the last label for the dates, but despite of the last date is 2021-10-18T00:00:00+00:00, it is not being shown.
should dates have a special format or something?
Here is the code :
const data = [
{
date: '2021-08-02T00:00:00+00:00',
score: 631,
},
{
date: '2021-08-09T00:00:00+00:00',
score: 624.25,
},
{
date: '2021-08-23T00:00:00+00:00',
score: 596.6,
},
{
date: '2021-09-13T00:00:00+00:00',
score: 505.666656,
},
{
date: '2021-09-27T00:00:00+00:00',
score: 417,
},
{
date: '2021-10-04T00:00:00+00:00',
score: 485.666656,
},
{
date: '2021-10-18T00:00:00+00:00',
score: 548,
},
];
const ChartContainer = () => (
<Chart>
<ChartCategoryAxis>
<ChartCategoryAxisItem
majorGridLines={{ visible: false }}
justified={true}
categories={data.map((d) => d.date)}
labels={{ rotation: 'auto', step: data.length - 1 }}
type="date"
/>
</ChartCategoryAxis>
<ChartValueAxis>
<ChartValueAxisItem
majorGridLines={{
visible: false,
}}
title={{
text: 'Scaled Score',
}}
/>
</ChartValueAxis>
<ChartSeries>
<ChartSeriesItem
type="line"
data={data.map((d) => d.score)}
missingValues="interpolate"
/>
<ChartSeriesItem
type="area"
data={data.map((d) => d.score)}
missingValues="interpolate"
color="rgb(214 237 247)"
/>
</ChartSeries>
</Chart>
);
Stackblitz live demo
Thanks for your help
Also, if you look at the data array, the fist object has a date of 2021-08-02, but chart renders 8/1 (August 1st), Which is wrong, it should render 8/2 (August the 2nd)