'antv Column chart - Is it possible to sort xField values which contain string date?
I am using antv basic Column chart in React app. I am trying to display dates on X axis. All the dates are formatted to DD.MM.YYYY and inputed to chart as string. For some reason It is never sorted correctly.
Please, does anyone encountered this behaviour? Is it somehow possible to add sort method in chart config? I couldn't find anything in documentation.
Data loading method:
const [data, setData] = useState<any>(undefined);
const loadValues = useCallback(
(data) => {
const array = []
for (const [day, values] of Object.entries(data)) {
for (const [type, value] of Object.entries(values as any)) {
array.push({
date: moment(day).format('L');,
value: value
});
}
}
setData(array)
}, []
)
Column graph:
<Column
data=data
isGroup={true}
xField="date"
yField="value"
isStack={true}
legend={{
layout: 'horizontal' as const,
position: 'bottom' as const,
}}
/>
Thank you for any information.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
