-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchart-colors.html
71 lines (60 loc) · 2.71 KB
/
chart-colors.html
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
<!-- External Polymer Styles/elements dependency -->
<link rel="import" href="bower_components/iron-icons/image-icons.html">
<link rel="import" href="bower_components/paper-icon-button/paper-icon-button.html">
<!-- Epiviz element dependency -->
<link rel="import" href="epiviz-chart-colors.html">
<script>
/**
* `ChartColorsBehavior` manages the `<epiviz-chart-colors>` element for each chart.
* All charts inherit this behavior to update chart colors.
*
* @polymerBehavior
**/
EpivizChartColorsBehavior = function (superClass) {
return class extends superClass {
constructor() {
super();
}
static get properties() {
return {};
}
/**
* Shows the `<epiviz-chart-colors>` element
*/
_showColorsDialog() {
var self = this;
var chartContainer = this.shadowRoot.querySelector('#' + this.plotId);
var currColors = this.shadowRoot.querySelector('epiviz-chart-colors');
if(currColors) {
currColors.remove();
}
var currColors = document.createElement('epiviz-chart-colors');
currColors.setAttribute('labels', JSON.stringify(self.chart.colorLabels()));
// currColors.setAttribute('_measurements', JSON.stringify(self.measurements));
currColors._measurements = self.measurements;
currColors.palettes = self.config.colorPalettes;
currColors.selected = self.chart.colors();
chartContainer.appendChild(currColors);
currColors.showColors(this.shadowRoot, function (newColors) {
self.chartColors = newColors;
});
}
/**
* Initializes the `<epiviz-chart-colors>` element
*/
_initializeColorsDialog() {
var chartSettingsContainer = this.shadowRoot.querySelector('#chartSettingsContainer');
var chartContainer = this.shadowRoot.querySelector('#' + this.plotId);
var currColorIcon = this.shadowRoot.querySelector('#chartColorsIcon');
if (currColorIcon == null) {
var iconElem = document.createElement('paper-icon-button');
iconElem.id = "chartColorsIcon";
iconElem.icon = "image:color-lens";
iconElem.title = "modify chart colors";
iconElem.addEventListener("click", this._showColorsDialog.bind(this));
chartSettingsContainer.appendChild(iconElem);
}
}
}
}
</script>