更改顶点图中单个条的颜色

时间:2020-08-05 07:04:17

标签: javascript jquery charts bar-chart apexcharts

在顶点图表的颜色栏中进行更改时遇到一些麻烦。该图表是混合图表(折线/条形图)。 我想更改单个条形颜色。

我尝试过的解决方案是按照顶点图表文档将fillColor添加到series.data中,但这不起作用。

图表快照 enter image description here

这是我的代码。 在哪里

response.device.data.values和response.flowmeter.values是一个值数组。

#!/usr/bin/python3

import re

str=" (subsidiary of <holding_company>) <post_>"

holding_company=re.sub(r'\s\(subsidiary\ of\ ([\w<>]*)\)\s*(.*)', '\\1', str)
post=re.sub(r'\s\(subsidiary\ of\ ([\w<>]*)\)\s*(.*)', '\\2', str)

print(holding_company)
print(post)

2 个答案:

答案 0 :(得分:0)

您可能可以利用将函数传递给 fill 属性。检查此链接:https://apexcharts.com/docs/options/fill/。您也可以根据系列索引进行自定义。

答案 1 :(得分:0)

您可以在系列的对象中设置颜色道具。 类似的东西:

series: [
                {
                    name: '<?=_('Device(s)')?>',
                    type: 'line',
                    color: "00FA9A",
                    data: response.device.data.values
                },
                {
                    name: '<?=_('Flowmeter(s)')?>',
                    type: 'bar',
                    color: "#F44336",
                    data: response.flowmeter.values
                }
            ],