Extjs更改堆积条形图中条形的颜色
让我们以这个示例...如何改变那些条的颜色?
我知道我可以通过渲染器更改它,但它不会改变图例。
我尝试使用:
style: {fill: 'red'}
的每个条的颜色
但它改变了我尝试将颜色放入数组中
,但它不起作用。我尝试将每种样式放入数组中,如下所示:
style: [{fill: 'red'}, {fill: 'green'}, {fill: 'blue'}]
但它也不起作用,因为我可以将标题放入数组中,例如:
title: ['title1', 'title2', 'title3']
我认为它(样式)也应该起作用,但不行。
那么如何更改每个“数据”栏的颜色?
let's take this example... how to change colors of those bars?
I know I can change it via renderer but it won't change legend.
I have tried to use:
style: {fill: 'red'}
but it changes color of ever bar
I have tried to put colors in array, its not working.
I have tried to put each style in array, like this:
style: [{fill: 'red'}, {fill: 'green'}, {fill: 'blue'}]
But it won't work either, since I can put titles in array like:
title: ['title1', 'title2', 'title3']
I thought it (styles) should work too but not.
So how can I change color of each "data" bar?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
条形颜色实际上由图表主题决定:
为了使用自定义颜色,您需要扩展现有的“Base”主题,如 自定义面积图示例。
Bar colors are actually determined by the chart's theme:
In order to use custom colors, you will need to extend the existing 'Base' theme, as in the custom area chart example.
Chart 使用 Theme 作为 mixins,
因此您可以直接使用名为 themeAttrs 的主题属性。
例如,如果您在柱形图/堆积柱形图的构造函数中,想要更改柱形的颜色,您可以指定
Chart uses Theme as mixins
So you can directly use theme property called themeAttrs.
For example if you are in constructor of column/stacked column chart, want to change the color of columns You can specify
使用 colorSet 你可以改变颜色。
using colorSet you can change color.
我决定添加完整代码:
I decided add full code:
如果你不想使用主题,你可以使用这个(至少它对我有用):
请注意,你必须将你的颜色放在两个不同的行中(我认为ExtJS有时有点愚蠢的框架)。
If you don't want to use a theme, you can use this (at least it worked for me):
Note that you have to put your color in two different lines (I think ExtJS is sometimes kinda stupid framework).
我正在使用 Ext JS 5.0
无需担心,只需串联包含颜色配置即可。
I'm using Ext JS 5.0
There is no need to worry,just include colors config in series.