-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchart-average.html
117 lines (92 loc) · 4.2 KB
/
chart-average.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<!-- 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 -->
<script>
/**
* `ChartRemoveBehavior` object manages the `<epiviz-chart-average>` element for each chart.
* All charts inherit this behavior to remove itself from DOM.
*
* @polymerBehavior
**/
EpivizChartAverageBehavior = function (superClass) {
return class extends superClass {
constructor() {
super();
}
static get properties() {
return {};
}
/**
* Shows the remove element
*/
_showAverageDialog() {
var self = this;
self.isAverage = !self.isAverage;
self._toggleAverageIcon();
if (!self.isAverage) {
self.chartSettings = self._originalSettings
self.data = self._originalData
// self.chart.setCustomSettingsValues(self._originalSettings);
// self._draw();
return;
}
if (!self._originalData) {
self._originalData = self.data
}
if (!self._originalSettings) {
self._originalSettings = JSON.parse(JSON.stringify(self.chartSettings))
}
self.chartSettings = JSON.parse(JSON.stringify(self._originalSettings));
var groupByMarker = new epiviz.ui.charts.markers.VisualizationMarker(
"average", "average", "average",
"function(data) { return null; }",
"function(m, data, preMarkResult) { return 'average'; }"
);
var aggregator = epiviz.ui.charts.markers.MeasurementAggregators["mean-stdev"];
self._averageData = new epiviz.datatypes.MeasurementAggregatedGenomicData(self._originalData, groupByMarker, aggregator);
self._averageData.ready(function() {
if (self._averageData.isReady()) {
// self.chart._lastData = newData;
self.data = self._averageData
self.chart.setCustomSettingsValues(self.chartSettings);
self._dataChanged();
}
})
// }
}
/**
* Initializes the `<epiviz-chart-logratio>` element
*/
_initializeAverageDialog() {
var chartSettingsContainer = this.shadowRoot.querySelector('#chartSettingsContainer');
var chartContainer = this.shadowRoot.querySelector('#' + this.plotId);
var currSettingIcon = this.shadowRoot.querySelector('#chartAverageIcon');
if (currSettingIcon == null) {
var iconElem = document.createElement('button');
iconElem.innerHTML = "Mean |";
iconElem.className = "setIcon";
iconElem.id = "chartAverageIcon";
iconElem.title = "avg track";
// iconElem.icon = "icons:alarm";
iconElem.addEventListener("click", this._showAverageDialog.bind(this));
chartSettingsContainer.appendChild(iconElem);
}
}
_toggleAverageIcon() {
var self = this;
var dis1 = this.shadowRoot.querySelector('#chartLogRatioIcon');
var active = this.shadowRoot.querySelector('#chartAverageIcon');
var dis2 = this.shadowRoot.querySelector('#chartNegationIcon');
if(self.isAverage) {
active.style.color = 'blue';
}
else {
active.style.color = 'black';
}
self.isLogRatio = self.isNegation = false;
dis1.style.color = dis2.style.color = 'black';
}
}
}
</script>