我需要分别设置 point.name 和 y 数组的颜色。
到目前为止我所拥有的:
(function(H) {
H.wrap(H.Series.prototype, 'getColor', function(proceed) {
this.color = generateColorForString(this.name);
});
}(Highcharts));
这适用于以下数据结构:
{
"data": [
[
[
"2018",
"02",
"16",
"00",
"00"
],
4.9
],
...
],
"name": "MySeriesName"
}
但不适用于饼图的数据结构:
{
"type": "pie",
"name": "MySeriesName",
"data": [
[
"foo",
27
],
[
"foox",
112
],
[
"fooy",
4
]
...
]
}
是否可以按名称为每个点设置颜色?
这是我的 fiddle :http://jsfiddle.net/2nd8561k/2/
最佳答案
您需要包装 Highcharts.Point.prototype
中的 resolveColor
方法:
(function(H) {
H.wrap(H.Point.prototype, 'resolveColor', function(proceed) {
this.color = generateColorForString(this.name);
});
}(Highcharts));
关于javascript - Highcharts 更改或添加 point.names 和 y 数组中名称的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55746440/