我正在制作 2 y 轴图表。我希望 Y 轴标签具有与刻度颜色相同的颜色。但我还是做不到
<ComposedChart height={300} data={chart_data}>
<CartesianGrid ... />
<XAxis ..... />
<YAxis .....
label={{ .... fill:'#FDF652' }} /> #Fill here not working
<YAxis ....
label={{ .... fill:'#535184'}} /> #Fill here not working
<Tooltip ......... />
<Area fill="#8884d8"/> #Fill here working
<Bar fill="#535184" ..../> #Fill here working
<Legend ............ />
</ComposedChart>
Run Code Online (Sandbox Code Playgroud)
当我添加时fill
,Area
它Bar
可以工作并且有颜色。但是当我添加时fill
它<YAxis label>
不起作用
Orl*_*yyn 10
如果标签指的是轴标题,则fill
道具应该可以解决问题,但它必须有一个值,否则就没有文本可以着色。就像:
<YAxis label={{ value: 'test', fill: 'red' }} />
Run Code Online (Sandbox Code Playgroud)
为了给刻度线和刻度标签着色,您可以分别使用道具tick
和tickLine
,就像这样:
<YAxis tick={{ fill: 'red' }} tickLine={{ stroke: 'red' }} />
Run Code Online (Sandbox Code Playgroud)
结果是: