小编Ami*_*gar的帖子

有没有办法让重新绘制轴的刻度大小均匀,同时保持最大值?

我有一个如下所示的数据数组,我想使用图表以特定方式显示它。

const severityExampleData: any = [
    {symptom_type: 'chest pain', mild: 1, moderate: 2, severe: 1, total: 4},
    {symptom_type: 'pursiness', mild: 2, moderate: 1, severe: 10, total: 13},
    {symptom_type: 'cough', mild: 0, moderate: 0, severe: 1, total: 1},
];
Run Code Online (Sandbox Code Playgroud)

我希望我的 Y 轴具有均匀的刻度大小,并且我希望它们是 5 个刻度,所以我使用了以下解决方案。

    <ResponsiveContainer width='100%' aspect={4.8/3.0}>
        <BarChart data={data} margin={{top: 0, left: 0, right: 0, bottom: 0}}>
            <CartesianGrid strokeDasharray="3" vertical={false} />
            <XAxis reversed dataKey="symptom_type" tickLine={false} axisLine={false}/>
            <YAxis orientation='right' tickLine={false} axisLine={false} tickCount={5} domain={['auto', MAX]}/>
            <Tooltip />
            {fieldNames.map((value: any, i:number) => {
                console.log(value); …
Run Code Online (Sandbox Code Playgroud)

reactjs recharts

4
推荐指数
1
解决办法
5972
查看次数

标签 统计

reactjs ×1

recharts ×1