Recharts在LineBarAreaComposedChart React上不显示负值

时间:2018-03-01 13:22:57

标签: javascript reactjs charts recharts

我试图用6个变量值优化图表。

有时这些值中的一些是负数,图表不会显示它们。

我试图在Y等级上设置负值,但这也不起作用。

图表上的线条本身消失。

风速线具有正值,但也不可见。

LineBarAreaComposedChart

我的代码:

<div className="row">
          <div className="col-md-12">
            <ComposedChart width={1100} height={800} data={this.state.data} stackOffset="sign">
              <XAxis dataKey="Date" />
              <YAxis />
              <Tooltip />
              <Legend />
              <CartesianGrid strokeDasharray="3 3" />
              <Area type='monotone' dataKey='Apress' fill='#726a64' stroke='#726a64' />
              <Bar dataKey='Rain' barSize={20} fill='#000cff'>
                <LabelList dataKey="Rain" position="top" />
              </Bar>
              <Bar dataKey='Snow' barSize={20} fill='#6387ff'>
                <LabelList dataKey="Snow" position="top" />
              </Bar>
              <Line type='monotone' dataKey='Temp' stroke='#ff0000' />
              <Line type='monotone' dataKey='WindSpeed' stroke='#00ff1a' />
            </ComposedChart>
          </div>
        </div>
      </div>

1 个答案:

答案 0 :(得分:2)

将道具stackOffset=“sign”添加到BarChart

默认值为none,这就是没有得到负值的原因。