-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchart-fixed-axis-toggle.html
76 lines (63 loc) · 2.66 KB
/
chart-fixed-axis-toggle.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
<!-- 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>
/**
* `FixedAxisBehavior` object toggles the fixed axis on StackedLinePlots.
* <epiviz-multistacked-line-plot> inherit this behavior to update chart settings.
*
* @polymerBehavior
**/
EpivizFixedAxisBehavior = function (superClass) {
return class extends superClass {
constructor() {
super();
}
static get properties() {
return {
toggleFixed: {
type: Boolean
}
};
}
/**
* Shows the `<epiviz-chart-settings>` element
*/
_showFixedAxisDialog() {
var self = this;
self.toggleFixed = !self.toggleFixed;
var currSettingIcon = this.shadowRoot.querySelector('#chartFixedAxisIcon');
if (self.toggleFixed) {
currSettingIcon.className = "fa fa-link";
} else {
currSettingIcon.className = "fa fa-chain-broken";
}
// self.chartSettings["autoScale"] = self.toggleFixed;
self.set("chartSettings.autoScale", self.toggleFixed);
}
/**
* Initializes the `<epiviz-chart-settings>` element
*/
_initializeFixedAxisDialog() {
var FixedAxisContainer = this.shadowRoot.querySelector('#chartSettingsContainer');
var chartContainer = this.shadowRoot.querySelector('#' + this.plotId);
var currSettingIcon = this.shadowRoot.querySelector('#chartFixedAxisIcon');
this.toggleFixed = this.chartSettings["autoScale"];
if (currSettingIcon == null) {
var iconElem = document.createElement('paper-icon-button');
iconElem.id = "chartFixedAxisIcon";
iconElem.title = "toggle auto/fixed scale";
if (this.toggleFixed) {
iconElem.className = "fa fa-link";
} else {
iconElem.className = "fa fa-chain-broken";
}
iconElem.addEventListener("click", this._showFixedAxisDialog.bind(this));
FixedAxisContainer.appendChild(iconElem);
}
}
}
}
</script>