tsichart-core 1.0.4 → 2.0.0-beta.1

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 (133) hide show
  1. package/LICENSE +22 -22
  2. package/README.md +80 -0
  3. package/dist/index.d.ts +1744 -0
  4. package/dist/index.js +14284 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/index.mjs +14209 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/dist/{tsiclient.css → styles/index.css} +9388 -9387
  9. package/dist/styles/index.css.map +1 -0
  10. package/package.json +115 -125
  11. package/README.MD +0 -171
  12. package/dist/AggregateExpression.d.ts +0 -13
  13. package/dist/AggregateExpression.js +0 -70
  14. package/dist/AvailabilityChart-vciRThEz.js +0 -488
  15. package/dist/AvailabilityChart.d.ts +0 -59
  16. package/dist/AvailabilityChart.js +0 -26
  17. package/dist/ChartComponent-BxPbycj0.js +0 -302
  18. package/dist/ChartComponent-L_dR-Eny.d.ts +0 -80
  19. package/dist/ChartComponentData-ClzAtU_E.d.ts +0 -47
  20. package/dist/ChartDataOptions-DBu_M5gU.d.ts +0 -38
  21. package/dist/ChartDataOptions-rcIzlQJO.js +0 -49
  22. package/dist/ChartVisualizationComponent-CswB2P7Z.d.ts +0 -8
  23. package/dist/ChartVisualizationComponent-NsvZCsc-.js +0 -23
  24. package/dist/ColorPicker-CUZt1uup.js +0 -120
  25. package/dist/ColorPicker.d.ts +0 -28
  26. package/dist/ColorPicker.js +0 -6
  27. package/dist/Component-C9fQU2ia.js +0 -401
  28. package/dist/Component-CdI_Pyko.d.ts +0 -226
  29. package/dist/ContextMenu-CP1qV7pP.js +0 -197
  30. package/dist/DateTimeButton-Ck71nL87.d.ts +0 -16
  31. package/dist/DateTimeButton-DnqhATyX.js +0 -38
  32. package/dist/DateTimeButtonRange-CT1zOoCf.js +0 -71
  33. package/dist/DateTimeButtonRange.d.ts +0 -19
  34. package/dist/DateTimeButtonRange.js +0 -15
  35. package/dist/DateTimeButtonSingle-DZk5fW35.js +0 -48
  36. package/dist/DateTimeButtonSingle.d.ts +0 -17
  37. package/dist/DateTimeButtonSingle.js +0 -14
  38. package/dist/DateTimePicker-CuGwz86U.js +0 -532
  39. package/dist/DateTimePicker.d.ts +0 -69
  40. package/dist/DateTimePicker.js +0 -13
  41. package/dist/EllipsisMenu-CNWSo-qQ.js +0 -116
  42. package/dist/EllipsisMenu.d.ts +0 -20
  43. package/dist/EllipsisMenu.js +0 -6
  44. package/dist/Enums-CEhu18PC.d.ts +0 -12
  45. package/dist/EventsTable-mjoOfc0E.js +0 -553
  46. package/dist/EventsTable.d.ts +0 -34
  47. package/dist/EventsTable.js +0 -10
  48. package/dist/GeoProcessGraphic-CSsTL4zj.js +0 -145
  49. package/dist/GeoProcessGraphic.d.ts +0 -34
  50. package/dist/GeoProcessGraphic.js +0 -7
  51. package/dist/Grid-ByDh3Qdn.js +0 -874
  52. package/dist/Grid.d.ts +0 -43
  53. package/dist/Grid.js +0 -6
  54. package/dist/GroupedBarChart-DrSrSHNj.js +0 -579
  55. package/dist/GroupedBarChart.d.ts +0 -22
  56. package/dist/GroupedBarChart.js +0 -17
  57. package/dist/GroupedBarChartData-CpJKvTDQ.js +0 -121
  58. package/dist/GroupedBarChartData-DK30DLVh.d.ts +0 -20
  59. package/dist/Heatmap-BbWcAgp6.js +0 -524
  60. package/dist/Heatmap.d.ts +0 -31
  61. package/dist/Heatmap.js +0 -14
  62. package/dist/Hierarchy-BsvoKnCY.js +0 -260
  63. package/dist/Hierarchy.d.ts +0 -39
  64. package/dist/Hierarchy.js +0 -6
  65. package/dist/HierarchyNavigation-C5yoj--u.js +0 -336
  66. package/dist/HierarchyNavigation.d.ts +0 -34
  67. package/dist/HierarchyNavigation.js +0 -6
  68. package/dist/HistoryPlayback-DIhAsAOi.d.ts +0 -68
  69. package/dist/HistoryPlayback-DiflRzRf.js +0 -175
  70. package/dist/Interfaces-CdAVFIA6.d.ts +0 -6
  71. package/dist/Legend-CQ5yaF8f.js +0 -497
  72. package/dist/LineChart-DcUenMrZ.js +0 -3181
  73. package/dist/LineChart.d.ts +0 -163
  74. package/dist/LineChart.js +0 -18
  75. package/dist/ModelAutocomplete-sxVy4m65.js +0 -100
  76. package/dist/ModelAutocomplete.d.ts +0 -12
  77. package/dist/ModelAutocomplete.js +0 -7
  78. package/dist/ModelSearch-DEg5KwKw.js +0 -189
  79. package/dist/ModelSearch.d.ts +0 -23
  80. package/dist/ModelSearch.js +0 -9
  81. package/dist/PieChart-DDxMXcXE.js +0 -258
  82. package/dist/PieChart.d.ts +0 -26
  83. package/dist/PieChart.js +0 -17
  84. package/dist/PlaybackControls-DSoUncDP.js +0 -195
  85. package/dist/PlaybackControls.d.ts +0 -39
  86. package/dist/PlaybackControls.js +0 -13
  87. package/dist/ProcessGraphic-1f-FoGDy.js +0 -154
  88. package/dist/ProcessGraphic.d.ts +0 -31
  89. package/dist/ProcessGraphic.js +0 -7
  90. package/dist/README.MD +0 -171
  91. package/dist/ScatterPlot-BAn6r8ml.js +0 -924
  92. package/dist/ScatterPlot.d.ts +0 -115
  93. package/dist/ScatterPlot.js +0 -17
  94. package/dist/SingleDateTimePicker-BrFB5iPu.js +0 -213
  95. package/dist/SingleDateTimePicker.d.ts +0 -45
  96. package/dist/SingleDateTimePicker.js +0 -12
  97. package/dist/Slider-BpNCqoBD.js +0 -186
  98. package/dist/Slider.d.ts +0 -31
  99. package/dist/Slider.js +0 -6
  100. package/dist/TemporalXAxisComponent-BsTQyVO6.js +0 -129
  101. package/dist/TemporalXAxisComponent-DohbI08i.d.ts +0 -23
  102. package/dist/TimezonePicker-DHkC2iKE.js +0 -58
  103. package/dist/TimezonePicker.d.ts +0 -16
  104. package/dist/TimezonePicker.js +0 -10
  105. package/dist/Tooltip-B-mIKo4g.js +0 -104
  106. package/dist/TsqExpression.d.ts +0 -36
  107. package/dist/TsqExpression.js +0 -89
  108. package/dist/UXClient-BTulvzpq.js +0 -230
  109. package/dist/UXClient.d.ts +0 -74
  110. package/dist/UXClient.js +0 -47
  111. package/dist/Utils-CdKMmmwx.js +0 -1138
  112. package/dist/Utils-ChzaAbch.d.ts +0 -104
  113. package/dist/Utils.d.ts +0 -7
  114. package/dist/Utils.js +0 -7
  115. package/dist/_tslib-DYvz7dIO.js +0 -96
  116. package/dist/package.json +0 -125
  117. package/dist/pikaday-C_DS7oEN.js +0 -1252
  118. package/dist/tsiclient.cjs.js +0 -3
  119. package/dist/tsiclient.cjs.js.LICENSE.txt +0 -19
  120. package/dist/tsiclient.cjs.js.map +0 -1
  121. package/dist/tsiclient.d.ts +0 -46
  122. package/dist/tsiclient.esm.js +0 -3
  123. package/dist/tsiclient.esm.js.LICENSE.txt +0 -19
  124. package/dist/tsiclient.esm.js.map +0 -1
  125. package/dist/tsiclient.js +0 -58
  126. package/dist/tsiclient.min.css +0 -6
  127. package/dist/tsiclient.min.css.map +0 -1
  128. package/dist/tsiclient.umd.js +0 -3
  129. package/dist/tsiclient.umd.js.LICENSE.txt +0 -19
  130. package/dist/tsiclient.umd.js.map +0 -1
  131. package/dist/tsiclient.umd.min.js +0 -3
  132. package/dist/tsiclient.umd.min.js.LICENSE.txt +0 -19
  133. package/dist/tsiclient.umd.min.js.map +0 -1
@@ -1,497 +0,0 @@
1
- import { _ as __extends } from './_tslib-DYvz7dIO.js';
2
- import * as d3 from 'd3';
3
- import { D as DataTypes, U as Utils, E as EventElementTypes } from './Utils-CdKMmmwx.js';
4
- import { C as Component } from './Component-C9fQU2ia.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 };