如何在React C3js中对X轴点进行分组? [英] How to group X-axis points in react C3js?
本文介绍了如何在React C3js中对X轴点进行分组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我开始研究react-c3js并陷入了一些问题.
I started working on react-c3js and got stuck into some problem.
下面是我的X轴数组:
"axis": {"x": ["4 2018", "4 2018", "5 2018", "5 2018", "6 2018", "6 2018", "6 2018", "6 2018", "6 2018", "6 2018", "6 2018", "6 2018", "6 2018", "7 2018", "7 2018", "7 2018", "7 2018", "7 2018", "7 2018", "7 2018", "7 2018", "7 2018", "7 2018", "7 2018", "7 2018", "7 2018", "8 2018", "8 2018", "8 2018", "8 2018", "8 2018", "8 2018", "8 2018", "8 2018", "8 2018", "8 2018", "8 2018", "8 2018", "8 2018", "8 2018", "9 2018", "9 2018", "9 2018", "9 2018", "9 2018", "9 2018", "9 2018", "9 2018", "9 2018", "9 2018", "9 2018", "9 2018", "9 2018", "9 2018", "10 2018", "10 2018", "10 2018", "10 2018", "10 2018", "10 2018", "10 2018", "10 2018", "10 2018", "10 2018", "10 2018", "10 2018", "10 2018", "10 2018", "11 2018", "11 2018", "11 2018", "11 2018", "11 2018", "11 2018", "11 2018", "11 2018", "11 2018", "11 2018", "11 2018", "11 2018", "11 2018", "12 2018", "12 2018", "12 2018", "12 2018", "12 2018", "12 2018", "12 2018", "12 2018", "12 2018", "12 2018", "1 2019", "1 2019", "1 2019"]
}
它显示如下图
即使它们在同一个月,也会显示所有项目
all items are shown even if they are in same month
但是我需要显示它像
But I need to show it like
我正在使用以下代码:
const Chart = ({ data }) =>
<C3Chart axis= {{
'x': {
type: 'category',
categories: data.axis['x']
}
}} data={{ json: data.chart_data, type:'line'}} />
请帮助.
推荐答案
您需要将设置设置为timeseries
类型,而不是category
https://c3js.org/samples/timeseries.html
You need setup as timeseries
type instead category
https://c3js.org/samples/timeseries.html
这篇关于如何在React C3js中对X轴点进行分组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文