tsichart-core 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/LICENSE +22 -0
  2. package/README.MD +189 -0
  3. package/dist/AggregateExpression.d.ts +13 -0
  4. package/dist/AggregateExpression.js +70 -0
  5. package/dist/AvailabilityChart-i_efwXCX.js +488 -0
  6. package/dist/AvailabilityChart.d.ts +59 -0
  7. package/dist/AvailabilityChart.js +26 -0
  8. package/dist/ChartComponent-DTcc6aED.d.ts +80 -0
  9. package/dist/ChartComponent-DnKLTxWe.js +302 -0
  10. package/dist/ChartComponentData-D5wuQmmZ.d.ts +47 -0
  11. package/dist/ChartDataOptions-DBS28b1-.d.ts +38 -0
  12. package/dist/ChartDataOptions-DRd8NHra.js +49 -0
  13. package/dist/ChartVisualizationComponent-CG7e5xlc.js +23 -0
  14. package/dist/ChartVisualizationComponent-DBjiqR1n.d.ts +8 -0
  15. package/dist/ColorPicker-CH__K8xm.js +120 -0
  16. package/dist/ColorPicker.d.ts +28 -0
  17. package/dist/ColorPicker.js +6 -0
  18. package/dist/Component-CofgyEw0.js +401 -0
  19. package/dist/Component-Rp30sSAW.d.ts +226 -0
  20. package/dist/ContextMenu-DABSkTA2.js +197 -0
  21. package/dist/DateTimeButton-CMcCxc8x.d.ts +16 -0
  22. package/dist/DateTimeButton-Ca1487GR.js +38 -0
  23. package/dist/DateTimeButtonRange-DpgfhHQt.js +71 -0
  24. package/dist/DateTimeButtonRange.d.ts +19 -0
  25. package/dist/DateTimeButtonRange.js +15 -0
  26. package/dist/DateTimeButtonSingle-C6cTx5VO.js +48 -0
  27. package/dist/DateTimeButtonSingle.d.ts +17 -0
  28. package/dist/DateTimeButtonSingle.js +14 -0
  29. package/dist/DateTimePicker-BH6qiVfQ.js +532 -0
  30. package/dist/DateTimePicker.d.ts +69 -0
  31. package/dist/DateTimePicker.js +13 -0
  32. package/dist/EllipsisMenu-30FNqoIv.js +116 -0
  33. package/dist/EllipsisMenu.d.ts +20 -0
  34. package/dist/EllipsisMenu.js +6 -0
  35. package/dist/Enums-ChUuTtHV.d.ts +12 -0
  36. package/dist/EventsTable-a0XLbsMF.js +553 -0
  37. package/dist/EventsTable.d.ts +34 -0
  38. package/dist/EventsTable.js +10 -0
  39. package/dist/GeoProcessGraphic-AVAzyF7k.js +145 -0
  40. package/dist/GeoProcessGraphic.d.ts +34 -0
  41. package/dist/GeoProcessGraphic.js +7 -0
  42. package/dist/Grid-DfFAkeeV.js +874 -0
  43. package/dist/Grid.d.ts +43 -0
  44. package/dist/Grid.js +6 -0
  45. package/dist/GroupedBarChart-BspwM8r2.js +579 -0
  46. package/dist/GroupedBarChart.d.ts +22 -0
  47. package/dist/GroupedBarChart.js +17 -0
  48. package/dist/GroupedBarChartData-BRCyDxbA.js +121 -0
  49. package/dist/GroupedBarChartData-C0YQydrP.d.ts +20 -0
  50. package/dist/Heatmap-D8ET8Ue8.js +524 -0
  51. package/dist/Heatmap.d.ts +31 -0
  52. package/dist/Heatmap.js +14 -0
  53. package/dist/Hierarchy-QkWLHkxo.js +260 -0
  54. package/dist/Hierarchy.d.ts +39 -0
  55. package/dist/Hierarchy.js +6 -0
  56. package/dist/HierarchyNavigation-CR6YUilh.js +336 -0
  57. package/dist/HierarchyNavigation.d.ts +34 -0
  58. package/dist/HierarchyNavigation.js +6 -0
  59. package/dist/HistoryPlayback-BmA-54lT.d.ts +68 -0
  60. package/dist/HistoryPlayback-SjeQbAPq.js +175 -0
  61. package/dist/Interfaces-BKRQ685G.d.ts +6 -0
  62. package/dist/Legend-DlSXQXHF.js +497 -0
  63. package/dist/LineChart-CExEyjZa.js +3181 -0
  64. package/dist/LineChart.d.ts +163 -0
  65. package/dist/LineChart.js +18 -0
  66. package/dist/ModelAutocomplete-TRD16egq.js +100 -0
  67. package/dist/ModelAutocomplete.d.ts +12 -0
  68. package/dist/ModelAutocomplete.js +7 -0
  69. package/dist/ModelSearch-WEa7Ud20.js +189 -0
  70. package/dist/ModelSearch.d.ts +23 -0
  71. package/dist/ModelSearch.js +9 -0
  72. package/dist/PieChart-B1ZXk13Q.js +258 -0
  73. package/dist/PieChart.d.ts +26 -0
  74. package/dist/PieChart.js +17 -0
  75. package/dist/PlaybackControls-Dwt6dif9.js +195 -0
  76. package/dist/PlaybackControls.d.ts +39 -0
  77. package/dist/PlaybackControls.js +13 -0
  78. package/dist/ProcessGraphic-CixT-zZl.js +154 -0
  79. package/dist/ProcessGraphic.d.ts +31 -0
  80. package/dist/ProcessGraphic.js +7 -0
  81. package/dist/README.MD +189 -0
  82. package/dist/ScatterPlot-DrPoHNDJ.js +924 -0
  83. package/dist/ScatterPlot.d.ts +115 -0
  84. package/dist/ScatterPlot.js +17 -0
  85. package/dist/SingleDateTimePicker-7anflEq8.js +213 -0
  86. package/dist/SingleDateTimePicker.d.ts +45 -0
  87. package/dist/SingleDateTimePicker.js +12 -0
  88. package/dist/Slider-BtSdC4fj.js +186 -0
  89. package/dist/Slider.d.ts +31 -0
  90. package/dist/Slider.js +6 -0
  91. package/dist/TemporalXAxisComponent-CyiM5EH0.d.ts +23 -0
  92. package/dist/TemporalXAxisComponent-DkyVvASs.js +129 -0
  93. package/dist/TimezonePicker-ClfP1lBL.js +58 -0
  94. package/dist/TimezonePicker.d.ts +16 -0
  95. package/dist/TimezonePicker.js +10 -0
  96. package/dist/Tooltip-Fa-0Xekn.js +104 -0
  97. package/dist/TsqExpression.d.ts +36 -0
  98. package/dist/TsqExpression.js +89 -0
  99. package/dist/UXClient-DydSPZwM.js +230 -0
  100. package/dist/UXClient.d.ts +74 -0
  101. package/dist/UXClient.js +47 -0
  102. package/dist/Utils-BsPLzJBC.d.ts +104 -0
  103. package/dist/Utils-C_j8IgZh.js +1138 -0
  104. package/dist/Utils.d.ts +7 -0
  105. package/dist/Utils.js +7 -0
  106. package/dist/_tslib-5_9pMg1F.js +96 -0
  107. package/dist/package.json +106 -0
  108. package/dist/pikaday-DMSzaLH6.js +1252 -0
  109. package/dist/tsiclient.cjs.js +3 -0
  110. package/dist/tsiclient.cjs.js.LICENSE.txt +19 -0
  111. package/dist/tsiclient.cjs.js.map +1 -0
  112. package/dist/tsiclient.css +17323 -0
  113. package/dist/tsiclient.d.ts +46 -0
  114. package/dist/tsiclient.esm.js +3 -0
  115. package/dist/tsiclient.esm.js.LICENSE.txt +19 -0
  116. package/dist/tsiclient.esm.js.map +1 -0
  117. package/dist/tsiclient.js +58 -0
  118. package/dist/tsiclient.min.css +6 -0
  119. package/dist/tsiclient.min.css.map +1 -0
  120. package/dist/tsiclient.umd.js +3 -0
  121. package/dist/tsiclient.umd.js.LICENSE.txt +19 -0
  122. package/dist/tsiclient.umd.js.map +1 -0
  123. package/dist/tsiclient.umd.min.js +3 -0
  124. package/dist/tsiclient.umd.min.js.LICENSE.txt +19 -0
  125. package/dist/tsiclient.umd.min.js.map +1 -0
  126. package/package.json +106 -0
@@ -0,0 +1,497 @@
1
+ import { _ as __extends } from './_tslib-5_9pMg1F.js';
2
+ import * as d3 from 'd3';
3
+ import { D as DataTypes, U as Utils, E as EventElementTypes } from './Utils-C_j8IgZh.js';
4
+ import { C as Component } from './Component-CofgyEw0.js';
5
+
6
+ var NUMERICSPLITBYHEIGHT = 44;
7
+ var NONNUMERICSPLITBYHEIGHT = 24;
8
+ var Legend = /** @class */ (function (_super) {
9
+ __extends(Legend, _super);
10
+ function Legend(drawChart, renderTarget, legendWidth) {
11
+ var _this = _super.call(this, renderTarget) || this;
12
+ _this.renderSplitBys = function (aggKey, aggSelection, dataType, noSplitBys) {
13
+ var splitByLabelData = Object.keys(_this.chartComponentData.timeArrays[aggKey]);
14
+ var firstSplitBy = _this.chartComponentData.displayState[aggKey].splitBys[Object.keys(_this.chartComponentData.displayState[aggKey].splitBys)[0]];
15
+ var firstSplitByType = firstSplitBy ? firstSplitBy.visibleType : null;
16
+ Object.keys(_this.chartComponentData.displayState[aggKey].splitBys).reduce(function (isSame, curr) {
17
+ return (firstSplitByType == _this.chartComponentData.displayState[aggKey].splitBys[curr].visibleType) && isSame;
18
+ }, true);
19
+ var showMoreSplitBys = function () {
20
+ var oldShownSplitBys = _this.chartComponentData.displayState[aggKey].shownSplitBys;
21
+ _this.chartComponentData.displayState[aggKey].shownSplitBys = Math.min(oldShownSplitBys + 20, splitByLabelData.length);
22
+ if (oldShownSplitBys != _this.chartComponentData.displayState[aggKey].shownSplitBys) {
23
+ _this.renderSplitBys(aggKey, aggSelection, dataType, noSplitBys);
24
+ }
25
+ };
26
+ var splitByContainer = aggSelection.selectAll(".tsi-splitByContainer").data([aggKey]);
27
+ var splitByContainerEntered = splitByContainer.enter().append("div")
28
+ .merge(splitByContainer)
29
+ .classed("tsi-splitByContainer", true);
30
+ var splitByLabels = splitByContainerEntered.selectAll('.tsi-splitByLabel')
31
+ .data(splitByLabelData.slice(0, _this.chartComponentData.displayState[aggKey].shownSplitBys), function (d) {
32
+ return d;
33
+ });
34
+ var self = _this;
35
+ var splitByLabelsEntered = splitByLabels
36
+ .enter()
37
+ .append("div")
38
+ .merge(splitByLabels)
39
+ .attr('role', _this.legendState === 'compact' ? 'button' : 'presentation')
40
+ .attr('tabindex', _this.legendState === 'compact' ? '0' : '-1')
41
+ .on('keypress', function (event, splitBy) {
42
+ if (_this.legendState === 'compact' && (event.keyCode === 13 || event.keyCode === 32)) { //space or enter
43
+ _this.toggleSplitByVisible(aggKey, splitBy);
44
+ _this.drawChart();
45
+ event.preventDefault();
46
+ }
47
+ })
48
+ .on("click", function (event, splitBy) {
49
+ if (self.legendState == "compact") {
50
+ self.toggleSplitByVisible(aggKey, splitBy);
51
+ }
52
+ else {
53
+ self.toggleSticky(aggKey, splitBy);
54
+ }
55
+ self.drawChart();
56
+ })
57
+ .on("mouseover", function (event, splitBy) {
58
+ event.stopPropagation();
59
+ self.labelMouseover(aggKey, splitBy);
60
+ })
61
+ .on("mouseout", function (event) {
62
+ event.stopPropagation();
63
+ self.svgSelection.selectAll(".tsi-valueElement")
64
+ .attr("stroke-opacity", 1)
65
+ .attr("fill-opacity", 1);
66
+ self.labelMouseout(self.svgSelection, aggKey);
67
+ })
68
+ .attr("class", function (splitBy, i) {
69
+ var compact = (dataType !== DataTypes.Numeric) ? 'tsi-splitByLabelCompact' : '';
70
+ var shown = Utils.getAgVisible(self.chartComponentData.displayState, aggKey, splitBy) ? 'shown' : '';
71
+ return "tsi-splitByLabel tsi-splitByLabel ".concat(compact, " ").concat(shown);
72
+ })
73
+ .classed("stickied", function (splitBy, i) {
74
+ if (self.chartComponentData.stickiedKey != null) {
75
+ return aggKey == self.chartComponentData.stickiedKey.aggregateKey && splitBy == self.chartComponentData.stickiedKey.splitBy;
76
+ }
77
+ });
78
+ var colors = Utils.createSplitByColors(self.chartComponentData.displayState, aggKey, self.chartOptions.keepSplitByColor);
79
+ splitByLabelsEntered.each(function (splitBy, j) {
80
+ var color = (self.chartComponentData.isFromHeatmap) ? self.chartComponentData.displayState[aggKey].color : colors[j];
81
+ if (dataType === DataTypes.Numeric || noSplitBys || self.legendState === 'compact') {
82
+ var colorKey = d3.select(this).selectAll('.tsi-colorKey').data([color]);
83
+ var colorKeyEntered = colorKey.enter()
84
+ .append("div")
85
+ .attr("class", 'tsi-colorKey')
86
+ .merge(colorKey);
87
+ if (dataType === DataTypes.Numeric) {
88
+ colorKeyEntered.style('background-color', function (d) {
89
+ return d;
90
+ });
91
+ }
92
+ else {
93
+ self.createNonNumericColorKey(dataType, colorKeyEntered, aggKey);
94
+ }
95
+ d3.select(this).classed('tsi-nonCompactNonNumeric', (dataType === DataTypes.Categorical || dataType === DataTypes.Events) && this.legendState !== 'compact');
96
+ colorKey.exit().remove();
97
+ }
98
+ else {
99
+ d3.select(this).selectAll('.tsi-colorKey').remove();
100
+ }
101
+ if (d3.select(this).select('.tsi-eyeIcon').empty()) {
102
+ d3.select(this).append("button")
103
+ .attr("class", "tsi-eyeIcon")
104
+ .attr('aria-label', function () {
105
+ var showOrHide = self.chartComponentData.displayState[aggKey].splitBys[splitBy].visible ? self.getString('hide series') : self.getString('show series');
106
+ return "".concat(showOrHide, " ").concat(splitBy, " ").concat(self.getString('in group'), " ").concat(self.chartComponentData.displayState[aggKey].name);
107
+ })
108
+ .attr('title', function () { return self.getString('Show/Hide values'); })
109
+ .on("click", function (event) {
110
+ event.stopPropagation();
111
+ self.toggleSplitByVisible(aggKey, splitBy);
112
+ d3.select(this)
113
+ .classed("shown", Utils.getAgVisible(self.chartComponentData.displayState, aggKey, splitBy));
114
+ self.drawChart();
115
+ });
116
+ }
117
+ if (d3.select(this).select('.tsi-seriesName').empty()) {
118
+ var seriesName = d3.select(this)
119
+ .append('div')
120
+ .attr('class', 'tsi-seriesName');
121
+ Utils.appendFormattedElementsFromString(seriesName, noSplitBys ? (self.chartComponentData.displayState[aggKey].name) : splitBy);
122
+ }
123
+ if (dataType === DataTypes.Numeric) {
124
+ if (d3.select(this).select('.tsi-seriesTypeSelection').empty()) {
125
+ d3.select(this).append("select")
126
+ .attr('aria-label', "".concat(self.getString("Series type selection for"), " ").concat(splitBy, " ").concat(self.getString('in group'), " ").concat(self.chartComponentData.displayState[aggKey].name))
127
+ .attr('class', 'tsi-seriesTypeSelection')
128
+ .on("change", function (data) {
129
+ var seriesType = d3.select(this).property("value");
130
+ self.chartComponentData.displayState[aggKey].splitBys[splitBy].visibleType = seriesType;
131
+ self.drawChart();
132
+ })
133
+ .on("click", function (event) {
134
+ event.stopPropagation();
135
+ });
136
+ }
137
+ d3.select(this).select('.tsi-seriesTypeSelection')
138
+ .each(function (d) {
139
+ var typeLabels = d3.select(this).selectAll('option')
140
+ .data(function (data) { return self.chartComponentData.displayState[aggKey].splitBys[splitBy].types.map(function (type) {
141
+ return {
142
+ type: type,
143
+ aggKey: aggKey,
144
+ splitBy: splitBy,
145
+ visibleMeasure: Utils.getAgVisibleMeasure(self.chartComponentData.displayState, aggKey, splitBy)
146
+ };
147
+ }); });
148
+ typeLabels
149
+ .enter()
150
+ .append("option")
151
+ .attr("class", "seriesTypeLabel")
152
+ .merge(typeLabels)
153
+ .property("selected", function (data) {
154
+ return ((data.type == Utils.getAgVisibleMeasure(self.chartComponentData.displayState, data.aggKey, data.splitBy)) ?
155
+ " selected" : "");
156
+ })
157
+ .text(function (data) { return data.type; });
158
+ typeLabels.exit().remove();
159
+ });
160
+ }
161
+ else {
162
+ d3.select(this).selectAll('.tsi-seriesTypeSelection').remove();
163
+ }
164
+ });
165
+ splitByLabels.exit().remove();
166
+ var shouldShowMore = self.chartComponentData.displayState[aggKey].shownSplitBys < splitByLabelData.length;
167
+ splitByContainerEntered.selectAll('.tsi-legendShowMore').remove();
168
+ if (_this.legendState === 'shown' && shouldShowMore) {
169
+ splitByContainerEntered.append('button')
170
+ .text(_this.getString('Show more'))
171
+ .attr('class', 'tsi-legendShowMore')
172
+ .style('display', (_this.legendState === 'shown' && shouldShowMore) ? 'block' : 'none')
173
+ .on('click', showMoreSplitBys);
174
+ }
175
+ splitByContainerEntered.on("scroll", function () {
176
+ if (self.chartOptions.legend === 'shown') {
177
+ if (this.scrollTop + this.clientHeight + 40 > this.scrollHeight) {
178
+ showMoreSplitBys();
179
+ }
180
+ }
181
+ });
182
+ splitByContainer.exit().remove();
183
+ };
184
+ _this.toggleSticky = function (aggregateKey, splitBy) {
185
+ //don't do anything if not visible
186
+ if (!_this.chartComponentData.displayState[aggregateKey].visible ||
187
+ !_this.chartComponentData.displayState[aggregateKey].splitBys[splitBy].visible)
188
+ return;
189
+ if (_this.chartComponentData.stickiedKey != null &&
190
+ _this.chartComponentData.stickiedKey.aggregateKey == aggregateKey &&
191
+ _this.chartComponentData.stickiedKey.splitBy == splitBy) {
192
+ _this.chartComponentData.stickiedKey = null;
193
+ }
194
+ else {
195
+ if (_this.stickySeriesAction) {
196
+ _this.stickySeriesAction(aggregateKey, splitBy);
197
+ }
198
+ }
199
+ };
200
+ _this.drawChart = drawChart;
201
+ _this.legendWidth = legendWidth;
202
+ _this.legendElement = d3.select(renderTarget).insert("div", ":first-child")
203
+ .attr("class", "tsi-legend")
204
+ .style("left", "0px")
205
+ .style("width", (_this.legendWidth) + "px"); // - 16 for the width of the padding
206
+ return _this;
207
+ }
208
+ Legend.prototype.labelMouseoutWrapper = function (labelMouseout, svgSelection, event) {
209
+ return function (svgSelection, aggKey) {
210
+ event === null || event === void 0 ? void 0 : event.stopPropagation();
211
+ svgSelection.selectAll(".tsi-valueElement")
212
+ .filter(function () { return !d3.select(this).classed("tsi-valueEnvelope"); })
213
+ .attr("stroke-opacity", 1)
214
+ .attr("fill-opacity", 1);
215
+ svgSelection.selectAll(".tsi-valueEnvelope")
216
+ .attr("fill-opacity", .2);
217
+ labelMouseout(svgSelection, aggKey);
218
+ };
219
+ };
220
+ Legend.prototype.toggleSplitByVisible = function (aggregateKey, splitBy) {
221
+ var _this = this;
222
+ var newState = !this.chartComponentData.displayState[aggregateKey].splitBys[splitBy].visible;
223
+ this.chartComponentData.displayState[aggregateKey].splitBys[splitBy].visible = newState;
224
+ this.chartComponentData.displayState[aggregateKey].visible = Object.keys(this.chartComponentData.displayState[aggregateKey].splitBys)
225
+ .reduce(function (prev, curr) {
226
+ return _this.chartComponentData.displayState[aggregateKey]["splitBys"][curr]["visible"] || prev;
227
+ }, false);
228
+ //turn off sticky if making invisible
229
+ if (newState == false && (this.chartComponentData.stickiedKey != null &&
230
+ this.chartComponentData.stickiedKey.aggregateKey == aggregateKey &&
231
+ this.chartComponentData.stickiedKey.splitBy == splitBy)) {
232
+ this.chartComponentData.stickiedKey = null;
233
+ }
234
+ };
235
+ Legend.prototype.triggerSplitByFocus = function (aggKey, splitBy) {
236
+ if (this.chartOptions.legend == "hidden") {
237
+ return;
238
+ }
239
+ this.legendElement.selectAll('.tsi-splitByLabel').classed("inFocus", false);
240
+ this.legendElement.selectAll('.tsi-splitByLabel').filter(function (labelData) {
241
+ return (d3.select(this.parentNode).datum() == aggKey) && (labelData == splitBy);
242
+ }).classed("inFocus", true);
243
+ var indexOfSplitBy = Object.keys(this.chartComponentData.displayState[aggKey].splitBys).indexOf(splitBy);
244
+ if (indexOfSplitBy != -1) {
245
+ var splitByNode = this.legendElement.selectAll('.tsi-splitByContainer').filter(function (d) {
246
+ return d == aggKey;
247
+ }).node();
248
+ var prospectiveScrollTop = Math.max((indexOfSplitBy - 1) * this.getHeightPerSplitBy(aggKey), 0);
249
+ if (splitByNode.scrollTop < prospectiveScrollTop - (splitByNode.clientHeight - 40) || splitByNode.scrollTop > prospectiveScrollTop) {
250
+ splitByNode.scrollTop = prospectiveScrollTop;
251
+ }
252
+ }
253
+ };
254
+ Legend.prototype.getHeightPerSplitBy = function (aggKey) {
255
+ return (this.chartComponentData.displayState[aggKey].dataType === DataTypes.Numeric ? NUMERICSPLITBYHEIGHT : NONNUMERICSPLITBYHEIGHT);
256
+ };
257
+ Legend.prototype.createGradient = function (gradientKey, svg, values) {
258
+ var gradient = svg.append('defs').append('linearGradient')
259
+ .attr('id', gradientKey).attr('x1', '0%').attr('x2', '0%').attr('y1', '0%').attr('y2', '100%');
260
+ var catCount = Object.keys(values).length;
261
+ Object.keys(values).forEach(function (category, i) {
262
+ var currentStop = i / catCount * 100;
263
+ var nextStop = (i + 1) / catCount * 100;
264
+ var color = values[category].color;
265
+ gradient.append('stop')
266
+ .attr("offset", currentStop + "%")
267
+ .attr("stop-color", color)
268
+ .attr("stop-opacity", 1);
269
+ gradient.append('stop')
270
+ .attr("offset", nextStop + "%")
271
+ .attr("stop-color", color)
272
+ .attr("stop-opacity", 1);
273
+ });
274
+ };
275
+ Legend.prototype.isNonNumeric = function (aggKey) {
276
+ var dataType = this.chartComponentData.displayState[aggKey].dataType;
277
+ return (dataType === DataTypes.Categorical || dataType === DataTypes.Events);
278
+ };
279
+ Legend.prototype.createNonNumericColorKey = function (dataType, colorKey, aggKey) {
280
+ if (dataType === DataTypes.Categorical) {
281
+ this.createCategoricalColorKey(colorKey, aggKey);
282
+ }
283
+ if (dataType === DataTypes.Events) {
284
+ this.createEventsColorKey(colorKey, aggKey);
285
+ }
286
+ };
287
+ Legend.prototype.createCategoricalColorKey = function (colorKey, aggKey) {
288
+ var categories = this.chartComponentData.displayState[aggKey].aggregateExpression.valueMapping;
289
+ colorKey.classed('tsi-categoricalColorKey', true);
290
+ colorKey.selectAll('*').remove();
291
+ var svg = colorKey.append('svg')
292
+ .attr('width', colorKey.style('width'))
293
+ .attr('height', colorKey.style('height'));
294
+ var rect = svg.append('rect')
295
+ .attr('width', '100%')
296
+ .attr('height', '100%')
297
+ .attr('fill', 'black');
298
+ var gradientKey = Utils.guid();
299
+ this.createGradient(gradientKey, svg, categories);
300
+ rect.attr('fill', "url(#" + gradientKey + ")");
301
+ };
302
+ Legend.prototype.createEventsColorKey = function (colorKey, aggKey) {
303
+ var categories = this.chartComponentData.displayState[aggKey].aggregateExpression.valueMapping;
304
+ var eventElementType = this.chartComponentData.displayState[aggKey].aggregateExpression.eventElementType;
305
+ colorKey.classed('tsi-eventsColorKey', true);
306
+ colorKey.selectAll('*').remove();
307
+ var colorKeyWidth = colorKey.node().getBoundingClientRect().width;
308
+ var colorKeyHeight = colorKey.node().getBoundingClientRect().height;
309
+ var colorKeyUnitLength = Math.floor(colorKeyHeight / Math.sqrt(2));
310
+ var svg = colorKey.append('svg')
311
+ .attr('width', "".concat(colorKeyWidth, "px"))
312
+ .attr('height', "".concat(colorKeyHeight, "px"));
313
+ var gradientKey = Utils.guid();
314
+ this.createGradient(gradientKey, svg, categories);
315
+ if (eventElementType === EventElementTypes.Teardrop) {
316
+ svg.append('path')
317
+ .attr('transform', function (d) {
318
+ return 'translate(' + (colorKeyWidth * .75) + ',' + (colorKeyHeight * .75) + ') rotate(180)';
319
+ })
320
+ .attr('d', this.teardropD(colorKeyWidth / 2, colorKeyHeight / 2))
321
+ .attr('stroke-width', Math.min(colorKeyUnitLength / 2.25, 8))
322
+ .style('fill', 'none')
323
+ .style('stroke', "url(#" + gradientKey + ")");
324
+ }
325
+ else {
326
+ var rect = svg.append('rect')
327
+ .attr('width', colorKeyUnitLength)
328
+ .attr('height', colorKeyUnitLength)
329
+ .attr('transform', "translate(".concat((colorKeyWidth / 2), ",0)rotate(45)"))
330
+ .attr('fill', 'black');
331
+ rect.attr('fill', "url(#" + gradientKey + ")");
332
+ }
333
+ };
334
+ Legend.prototype.draw = function (legendState, chartComponentData, labelMouseover, svgSelection, options, labelMouseoutAction, stickySeriesAction, event) {
335
+ var _this = this;
336
+ if (labelMouseoutAction === void 0) { labelMouseoutAction = null; }
337
+ if (stickySeriesAction === void 0) { stickySeriesAction = null; }
338
+ this.chartOptions.setOptions(options);
339
+ this.chartComponentData = chartComponentData;
340
+ this.legendState = legendState;
341
+ this.stickySeriesAction = stickySeriesAction;
342
+ this.labelMouseover = labelMouseover;
343
+ this.labelMouseout = this.labelMouseoutWrapper(labelMouseoutAction, svgSelection, event);
344
+ this.svgSelection = svgSelection;
345
+ var legend = this.legendElement;
346
+ var self = this;
347
+ _super.prototype.themify.call(this, this.legendElement, this.chartOptions.theme);
348
+ legend.style('visibility', this.legendState != 'hidden')
349
+ .classed('compact', this.legendState == 'compact')
350
+ .classed('hidden', this.legendState == 'hidden');
351
+ var seriesNames = Object.keys(this.chartComponentData.displayState);
352
+ var seriesLabels = legend.selectAll(".tsi-seriesLabel")
353
+ .data(seriesNames, function (d) { return d; });
354
+ var seriesLabelsEntered = seriesLabels.enter()
355
+ .append("div")
356
+ .merge(seriesLabels)
357
+ .attr("class", function (d, i) {
358
+ return "tsi-seriesLabel " + (_this.chartComponentData.displayState[d]["visible"] ? " shown" : "");
359
+ })
360
+ .style("min-width", function () {
361
+ return Math.min(124, _this.legendElement.node().clientWidth / seriesNames.length) + 'px';
362
+ })
363
+ .style("border-color", function (d, i) {
364
+ if (d3.select(this).classed("shown"))
365
+ return self.chartComponentData.displayState[d].color;
366
+ return "lightgray";
367
+ });
368
+ var self = this;
369
+ var heightPerNameLabel = 25;
370
+ var usableLegendHeight = legend.node().clientHeight;
371
+ var prospectiveAggregateHeight = Math.ceil(Math.max(201, (usableLegendHeight / seriesLabelsEntered.size())));
372
+ var contentHeight = 0;
373
+ seriesLabelsEntered.each(function (aggKey, i) {
374
+ var heightPerSplitBy = self.getHeightPerSplitBy(aggKey);
375
+ var splitByLabelData = Object.keys(self.chartComponentData.timeArrays[aggKey]);
376
+ var noSplitBys = splitByLabelData.length == 1 && splitByLabelData[0] == "";
377
+ var seriesNameLabel = d3.select(this).selectAll(".tsi-seriesNameLabel").data([aggKey]);
378
+ d3.select(this).classed('tsi-nsb', noSplitBys);
379
+ var enteredSeriesNameLabel = seriesNameLabel.enter().append("button")
380
+ .merge(seriesNameLabel)
381
+ .attr("class", function (agg, i) {
382
+ return "tsi-seriesNameLabel" + (self.chartComponentData.displayState[agg].visible ? " shown" : "");
383
+ })
384
+ .attr("aria-label", function (agg) {
385
+ var showOrHide = self.chartComponentData.displayState[agg].visible ? self.getString('hide group') : self.getString('show group');
386
+ return "".concat(showOrHide, " ").concat(self.getString('group'), " ").concat(Utils.stripNullGuid(self.chartComponentData.displayState[agg].name));
387
+ })
388
+ .on("click", function (event, d) {
389
+ var newState = !self.chartComponentData.displayState[d].visible;
390
+ self.chartComponentData.displayState[d].visible = newState;
391
+ //turn off sticky if making invisible
392
+ if (newState == false && (self.chartComponentData.stickiedKey != null &&
393
+ self.chartComponentData.stickiedKey.aggregateKey == d)) {
394
+ self.chartComponentData.stickiedKey = null;
395
+ }
396
+ self.drawChart();
397
+ })
398
+ .on("mouseover", function (event, d) {
399
+ labelMouseover(d);
400
+ })
401
+ .on("mouseout", function (event, d) {
402
+ self.labelMouseout(svgSelection, d);
403
+ });
404
+ var dataType = self.chartComponentData.displayState[aggKey].dataType;
405
+ if (dataType === DataTypes.Categorical || dataType === DataTypes.Events) {
406
+ enteredSeriesNameLabel.classed('tsi-nonCompactNonNumeric', true);
407
+ var colorKey = enteredSeriesNameLabel.selectAll('.tsi-colorKey').data(['']);
408
+ var colorKeyEntered = colorKey.enter()
409
+ .append("div")
410
+ .attr("class", 'tsi-colorKey')
411
+ .merge(colorKey);
412
+ self.createNonNumericColorKey(dataType, colorKeyEntered, aggKey);
413
+ colorKey.exit().remove();
414
+ }
415
+ var seriesNameLabelText = enteredSeriesNameLabel.selectAll("h4").data([aggKey]);
416
+ seriesNameLabelText.enter()
417
+ .append("h4")
418
+ .merge(seriesNameLabelText)
419
+ .attr("title", function (d) { return Utils.stripNullGuid(self.chartComponentData.displayState[d].name); })
420
+ .each(function () {
421
+ Utils.appendFormattedElementsFromString(d3.select(this), self.chartComponentData.displayState[aggKey].name);
422
+ });
423
+ seriesNameLabelText.exit().remove();
424
+ seriesNameLabel.exit().remove();
425
+ var splitByContainerHeight;
426
+ if (splitByLabelData.length > (prospectiveAggregateHeight / heightPerSplitBy)) {
427
+ splitByContainerHeight = prospectiveAggregateHeight - heightPerNameLabel;
428
+ contentHeight += splitByContainerHeight + heightPerNameLabel;
429
+ }
430
+ else if (splitByLabelData.length > 1 || (splitByLabelData.length === 1 && splitByLabelData[0] !== "")) {
431
+ splitByContainerHeight = splitByLabelData.length * heightPerSplitBy + heightPerNameLabel;
432
+ contentHeight += splitByContainerHeight + heightPerNameLabel;
433
+ }
434
+ else {
435
+ splitByContainerHeight = heightPerSplitBy;
436
+ contentHeight += splitByContainerHeight;
437
+ }
438
+ if (self.chartOptions.legend == "shown") {
439
+ d3.select(this).style("height", splitByContainerHeight + "px");
440
+ }
441
+ else {
442
+ d3.select(this).style("height", "unset");
443
+ }
444
+ var splitByContainer = d3.select(this).selectAll(".tsi-splitByContainer").data([aggKey]);
445
+ var splitByContainerEntered = splitByContainer.enter().append("div")
446
+ .merge(splitByContainer)
447
+ .classed("tsi-splitByContainer", true);
448
+ var aggSelection = d3.select(this);
449
+ self.renderSplitBys(aggKey, aggSelection, dataType, noSplitBys);
450
+ splitByContainerEntered.on("scroll", function () {
451
+ if (self.chartOptions.legend == "shown") {
452
+ if (this.scrollTop + this.clientHeight + 40 > this.scrollHeight) {
453
+ var oldShownSplitBys = self.chartComponentData.displayState[aggKey].shownSplitBys;
454
+ self.chartComponentData.displayState[aggKey].shownSplitBys = Math.min(oldShownSplitBys + 20, splitByLabelData.length);
455
+ if (oldShownSplitBys != self.chartComponentData.displayState[aggKey].shownSplitBys) {
456
+ self.renderSplitBys(aggKey, aggSelection, dataType, noSplitBys);
457
+ }
458
+ }
459
+ }
460
+ });
461
+ d3.select(this).on('scroll', function () {
462
+ if (self.chartOptions.legend == "compact") {
463
+ if (this.scrollLeft + this.clientWidth + 40 > this.scrollWidth) {
464
+ var oldShownSplitBys = self.chartComponentData.displayState[aggKey].shownSplitBys;
465
+ self.chartComponentData.displayState[aggKey].shownSplitBys = Math.min(oldShownSplitBys + 20, splitByLabelData.length);
466
+ if (oldShownSplitBys != self.chartComponentData.displayState[aggKey].shownSplitBys) {
467
+ this.renderSplitBys(dataType);
468
+ }
469
+ }
470
+ }
471
+ });
472
+ splitByContainer.exit().remove();
473
+ });
474
+ if (this.chartOptions.legend == 'shown') {
475
+ legend.node().clientHeight;
476
+ //minSplitBysForFlexGrow: the minimum number of split bys for flex-grow to be triggered
477
+ if (contentHeight < usableLegendHeight) {
478
+ this.legendElement.classed("tsi-flexLegend", true);
479
+ seriesLabelsEntered.each(function (d) {
480
+ var heightPerSplitBy = self.getHeightPerSplitBy(d);
481
+ var minSplitByForFlexGrow = (prospectiveAggregateHeight - heightPerNameLabel) / heightPerSplitBy;
482
+ var splitBysCount = Object.keys(self.chartComponentData.displayState[String(d3.select(this).data()[0])].splitBys).length;
483
+ if (splitBysCount > minSplitByForFlexGrow) {
484
+ d3.select(this).style("flex-grow", 1);
485
+ }
486
+ });
487
+ }
488
+ else {
489
+ this.legendElement.classed("tsi-flexLegend", false);
490
+ }
491
+ }
492
+ seriesLabels.exit().remove();
493
+ };
494
+ return Legend;
495
+ }(Component));
496
+
497
+ export { Legend as L };