Highcharts 在 point.names 和 y 的数组中更改或添加名称颜色
Highcharts change or add color for name in a array of point.names and y
我需要分别为 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));
我需要分别为 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));