【问题标题】:Can I change styling for a specific value in YAxis in recharts?我可以在图表中更改 YAxis 中特定值的样式吗?
【发布时间】:2023-02-03 15:33:09
【问题描述】:

我正在使用 recharts 在反应中创建视觉效果,这是我的 y 轴的样子:

<YAxis dataKey="XYZ" unit="%" yAxisId="rightY" >
    <Label value="XYZ" position="insideRight" />
</YAxis>

<Line yAxisId="rightY" type="linear" dataKey="XYZ">
     <LabelList dataKey="XYZ"content={this.customizedLineLabel} />
</Line>

是否可以更改 y 轴中特定值的字体颜色?

例如:if this is my visual

我想更改 0 在 y 轴上的颜色(标记为红色)

我查看了 API 文档,没有找到任何相关内容。

【问题讨论】:

    标签: reactjs recharts


    【解决方案1】:

    是的,这是可能的,而且也很容易实施。 您将需要创建一个 customTick 函数,该函数将传递给 Yaxis 的 tick 属性。

    并在该函数中添加以下代码。 &lt;Text&gt;由recharts提供。

    我希望这就是你想要的!

    访问整个代码here

    【讨论】:

      猜你喜欢
      • 2023-01-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多