-
Notifications
You must be signed in to change notification settings - Fork 2
/
chart-settings.html
93 lines (76 loc) · 3.84 KB
/
chart-settings.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!-- External Polymer Styles/elements dependency -->
<link rel="import" href="bower_components/iron-icons/iron-icons.html">
<link rel="import" href="bower_components/paper-icon-button/paper-icon-button.html">
<!-- Epiviz element dependency -->
<link rel="import" href="epiviz-chart-settings.html">
<script>
/**
* `ChartSettingsBehavior` object manages the `<epiviz-chart-settings>` element for each chart.
* All charts inherit this behavior to update chart settings.
*
* @polymerBehavior
**/
EpivizChartSettingsBehavior = function (superClass) {
return class extends superClass {
constructor() {
super();
}
static get properties() {
return {};
}
/**
* Shows the `<epiviz-chart-settings>` element
*/
_showSettingsDialog() {
var self = this;
var chartContainer = this.shadowRoot.querySelector('#' + this.plotId);
var currSetting = this.shadowRoot.querySelector('epiviz-chart-settings');
if (currSetting == null) {
var currSetting = document.createElement('epiviz-chart-settings');
// self.visualization().properties().customSettingsDefs
currSetting.setAttribute('defs', JSON.stringify(self.chart.properties().customSettingsDefs));
currSetting.setAttribute('vals', JSON.stringify(self.chartSettings));
currSetting.setAttribute('_measurements', JSON.stringify(self.measurements));
currSetting.showTooltip = self.showTooltip;
currSetting._colors= self.chart.colors();
chartContainer.appendChild(currSetting);
}
else {
currSetting.remove();
var currSetting = document.createElement('epiviz-chart-settings');
currSetting.setAttribute('defs', JSON.stringify(self.chart.properties().customSettingsDefs));
currSetting.setAttribute('vals', JSON.stringify(self.chartSettings));
currSetting.setAttribute('_measurements', JSON.stringify(self.measurements));
currSetting.showTooltip = self.showTooltip;
currSetting._colors= self.chart.colors();
chartContainer.appendChild(currSetting);
}
currSetting.showSettings(this.shadowRoot, function (newSettings, measurements, showTooltip) {
// self.chartSettings = newSettings;
self.set("chartSettings", newSettings);
self.set("measurements", measurements);
self.set("showTooltip", showTooltip);
if(self._initializeShowTracksDialog){
self._initializeShowTracksDialog();
}
});
}
/**
* Initializes the `<epiviz-chart-settings>` element
*/
_initializeSettingsDialog() {
var chartSettingsContainer = this.shadowRoot.querySelector('#chartSettingsContainer');
var chartContainer = this.shadowRoot.querySelector('#' + this.plotId);
var currSettingIcon = this.shadowRoot.querySelector('#chartSettingsIcon');
if (currSettingIcon == null) {
var iconElem = document.createElement('paper-icon-button');
iconElem.id = "chartSettingsIcon";
iconElem.icon = "settings";
iconElem.title = "modify chart settings";
iconElem.addEventListener("click", this._showSettingsDialog.bind(this));
chartSettingsContainer.appendChild(iconElem);
}
}
}
}
</script>