I want X Axis to display only the months and I can add content on different days within a month.
I tried using ticks but it just removed the X Axys I'm using ticksFormatter but when there is a different day in the same month it duplicates the X Axys caption and goes something like "June July August August September October Novemeber", and what I wanted was for it to be just "June July August September October Novemeber"
Something like that:
<ResponsiveContainer width="95%" height={360}>
<LineChart data={data.data}>
<CartesianGrid strokeDasharray="1 5" stroke="#2A2A2C" vertical={false} />
<XAxis dataKey="name" axisLine={false} tickLine={false} tickFormatter={date => moment(date, "YYYY-MM-DD HH:mm:ss").format("MMMM")}/>
<YAxis axisLine={false} tickLine={false} tick={{ stroke: '#000', strokeWidth: 1 }} tickMargin="10" />
<Tooltip labelFormatter={date => moment(date, "YYYY-MM-DD HH:mm:ss").format("DD-MM-YYYY")} />
<Legend verticalAlign="top" align="right" height={36} iconType="circle" formatter={text => <span style={{ color: "#000" }}>{text}</span>} />
{data.ref.map((entry, index) => (
<Line type="linear" dataKey={entry.name} strokeWidth={5} stroke={entry.color} dot={{ strokeWidth: 4, r: 5 }} />))}
</LineChart>
</ResponsiveContainer>
Here is my JSON
"lineChart": {
"title": "Pedidos (× R$ 1M)",
"ref": [{
"name": "Aprovados",
"color": "#BF2542"
},
{
"name": "Incluídos",
"color": "#7DA43D"
}
],
"data": [{
"name": "2021-06-20 00:20:16",
"Aprovados": 31,
"Incluídos": 23
},
{
"name": "2021-07-20 00:20:16",
"Aprovados": 41,
"Incluídos": 13
},
{
"name": "2021-08-20 00:20:16",
"Aprovados": 21,
"Incluídos": 43
},
{
"name": "2021-08-22 00:20:16",
"Aprovados": 23,
"Incluídos": 23
},
{
"name": "2021-09-20 00:20:16",
"Aprovados": 71,
"Incluídos": 63
},
{
"name": "2021-10-20 00:20:16",
"Aprovados": 21,
"Incluídos": 43
},
{
"name": "2021-11-20 00:20:16",
"Aprovados": 41,
"Incluídos": 13
}
]
}