我有一个 Recharts 的 LineChart
,其 x 轴是数字类型。我希望在任意 x 值上绘制一条 ReferenceLine
,但是如果 ReferenceLine
的 x 属性值不在我的数据之中,它将不会显示。
具体操作请参考:
const data = [{ x: 1, y: 3 }, { x: 1.5, y: 4 }, { x: 2, y: 3 }];
...
<ReferenceLine x={1.7} stroke="green" label="actual" alwaysShow={true} />
没有显示任何内容,而
const data = [{ x: 1, y: 3 }, { x: 1.5, y: 4 }, { x: 2, y: 3 }];
...
<ReferenceLine x={1.5} stroke="green" label="actual" alwaysShow={true} />
操作步骤如下:
我已经在这里构建了沙箱: https://codesandbox.io/s/recharts-playground-xxwnl
有没有办法让ReferenceLine在每个x轴处显示?