-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathbase.js
More file actions
115 lines (105 loc) · 3.4 KB
/
base.js
File metadata and controls
115 lines (105 loc) · 3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/******************************************************************************
*
* Copyright (c) 2017, the Perspective Authors.
*
* This file is part of the Perspective library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/
import Highcharts from "highcharts";
export const COLORS_10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf"];
export const COLORS_20 = [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#ffbb78",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5",
"#8c564b",
"#c49c94",
"#e377c2",
"#f7b6d2",
"#7f7f7f",
"#c7c7c7",
"#bcbd22",
"#dbdb8d",
"#17becf",
"#9edae5"
];
Highcharts.setOptions({
colors: COLORS_20
});
(function(H) {
H.wrap(H.seriesTypes.scatter.prototype, "translate", function(translate) {
translate.apply(this, Array.prototype.slice.call(arguments, 1));
if (this.chart.userOptions.chart.type.slice(0, 7) === "colored") {
this.translateColors.call(this);
}
});
var seriesTypes = H.seriesTypes,
merge = H.merge,
extendClass = H.extendClass,
defaultOptions = H.getOptions(),
plotOptions = defaultOptions.plotOptions;
var colorSeriesMixin = {
optionalAxis: "colorAxis",
colorKey: "colorValue",
translateColors: seriesTypes.heatmap && seriesTypes.heatmap.prototype.translateColors
};
plotOptions.coloredColumn = merge(plotOptions.column, {});
seriesTypes.coloredColumn = extendClass(
seriesTypes.column,
merge(colorSeriesMixin, {
type: "coloredColumn",
axisTypes: ["xAxis", "yAxis", "colorAxis"]
})
);
plotOptions.coloredScatter = merge(plotOptions.scatter, {});
seriesTypes.coloredScatter = extendClass(
seriesTypes.scatter,
merge(colorSeriesMixin, {
type: "coloredScatter",
axisTypes: ["xAxis", "yAxis", "colorAxis"]
})
);
plotOptions.coloredBubble = merge(plotOptions.bubble, {});
seriesTypes.coloredBubble = extendClass(
seriesTypes.bubble,
merge(colorSeriesMixin, {
type: "coloredBubble",
axisTypes: ["xAxis", "yAxis", "colorAxis"]
})
);
// draw points and add setting colors
H.wrap(H.seriesTypes.sunburst.prototype, "translate", function(p, positions) {
p.call(this, positions);
this.translateColors();
});
// copy method from heatmap for color mixin
H.seriesTypes.sunburst.prototype.translateColors = function() {
var series = this,
nullColor = this.options.nullColor,
colorAxis = this.colorAxis,
colorKey = this.colorKey;
H.each(this.data, function(point) {
var value = point[colorKey],
color;
color =
point.options.color ||
(!point.value // LINE CHANGED
? nullColor
: colorAxis && value !== undefined
? colorAxis.toColor(value, point)
: point.color || series.color);
if (color) {
point.color = color;
}
});
};
// use "colorValue" to calculate color
H.seriesTypes.sunburst.prototype.colorKey = "colorValue";
})(Highcharts);