UNPKG

23.3 kBJavaScriptView Raw
1import { f as InterpolationFunctions, U as Utils, g as DefaultHierarchyNavigationOptions } from './Utils-38a0872e.js';
2import { curveLinear, curveStep, curveStepBefore, curveStepAfter, curveBasis, curveCardinal, curveMonotoneX, curveCatmullRom } from 'd3';
3
4var Strings = /** @class */ (function () {
5 function Strings() {
6 this.stringValueDefaults = {
7 "Last 30 mins": "Last 30 mins",
8 "Last Hour": "Last Hour",
9 "Last 2 Hours": "Last 2 Hours",
10 "Last 4 Hours": "Last 4 Hours",
11 "Last 12 Hours": "Last 12 Hours",
12 "Last 24 Hours": "Last 24 Hours",
13 "Last 7 Days": "Last 7 Days",
14 "Last 30 Days": "Last 30 Days",
15 "Custom": "Custom",
16 "Timeframe": "Timeframe",
17 "Save": "Save",
18 "timezone": "timezone",
19 "start": "start",
20 "end": "end",
21 "Latest": "Latest",
22 "Show ellipsis menu": "Show ellipsis menu",
23 "Hide ellipsis menu": "Hide ellipsis menu",
24 "Download as CSV": "Download as CSV",
25 "Toggle all columns": "Toggle all columns",
26 "All Columns": "All Columns",
27 "only": "only",
28 "Invalid Date": "Invalid Date",
29 "Stack/Unstack Bars": "Stack/Unstack Bars",
30 "Stack bars": "Stack bars",
31 "Unstack bars": "Unstack bars",
32 "No filter results": "No filter results",
33 "All hierarchies": "All hierarchies",
34 "Selected": "Selected",
35 "toggle visibility for": "toggle visibility for",
36 "Series type selection for": "Series type selection for",
37 "shifted": "shifted",
38 "Click to drop marker": "Click to drop marker",
39 "drag to reposition": "drag to reposition",
40 "Delete marker at": "Delete marker at",
41 "set axis state to": "set axis state to",
42 "Drop a Marker": "Drop a Marker",
43 "Search Time Series Instances": "Search Time Series Instances",
44 "No results": "No results",
45 "No instances": "No instances found",
46 "No search result": "No instances found for entered search term.",
47 "Instance not found": "Instance not found under selected hierarchy.",
48 "Show more": "Show more",
49 "No description": "No description",
50 "Time Series ID": "Time Series ID",
51 "Currently displayed time is": "Currently displayed time is",
52 "Left arrow to go back in time": "Left arrow to go back in time",
53 "right arrow to go forward": "right arrow to go forward",
54 "Local": "Local",
55 "Display Grid": "Display Grid",
56 "Previous Month": "Previous Month",
57 "Next Month": "Next Month",
58 "Unassigned Time Series Instances": "Unassigned Time Series Instances",
59 "Search globally": "Search globally",
60 "Lookup globally": "Lookup globally",
61 "Show More Instances": "Show more instances",
62 "Show More Hierarchies": "Show more hierarchies",
63 "Add to Filter Path": "Add to Filter Path",
64 "Empty": "Empty",
65 "Date/Time": "Date/Time",
66 "show series": "show series",
67 "hide series": "hide series",
68 "in group": "in group",
69 "show group": "show group",
70 "hide group": "hide group",
71 "Use the arrow keys to navigate the values of each cell": "Use the arrow keys to navigate the values of each cell",
72 "A grid of values": "A grid of values",
73 "close grid": "close grid",
74 "column header for date": "column header for date",
75 "row header for": "row header for",
76 "values for cell at": "values for cell at",
77 "no values at": "no values at",
78 "and": "and",
79 "are": "are",
80 "timezone selection": "timezone selection",
81 "Start time input": "Start time input",
82 "End time input": "End time input",
83 "*": "*",
84 "snap end time to latest": "snap end time to latest",
85 "zoom in": "zoom in",
86 "zoom out": "zoom out",
87 "A line chart zoom in": "A line chart zoom in",
88 "A line chart zoom out": "A line chart zoom out",
89 "select quick time of": "select quick time of",
90 "a time selection control dialog": "a time selection control dialog.",
91 "a button to launch a time selection dialog current selected time is ": "a button to launch a time selection dialog. current selected time is ",
92 "No color": "No color",
93 "Change y-axis type": "Change y-axis type",
94 "Show/Hide values": "Show/Hide values",
95 "Line chart": "Line chart",
96 "Bar chart": "Bar chart",
97 "Heatmap": "Heatmap",
98 "Pie chart": "Pie chart",
99 "Scatter plot": "Scatter plot",
100 "Select color": "Select color",
101 "Search suggestion instruction": "When autocomplete results are available use up and down arrows to review and enter to select",
102 "Search suggestions available": " results available, keyboard users, use up and down arrows to review and enter to select.",
103 "Hierarchy list": "Hierarchy list",
104 "event in series": "Event in series",
105 "at time": "at time",
106 "measure with key": "measure with key",
107 "and value": "and value",
108 "Looking for": "Looking for",
109 "Hierarchy error": "Error occured! Refreshing hierarchy...",
110 "Failed to get token": "Failed to get token",
111 "Error in hierarchy navigation": "Error in hierarchy navigation",
112 "Failed to load types for navigation": "Failed to load types for navigation",
113 "Failed to load hierarchies for navigation": "Failed to load hierarchies for navigation",
114 "Failed to complete search": "Failed to complete search",
115 "Failed to get instance details": "Failed to get instance details",
116 "Add": "Add",
117 "Search": "Search",
118 "Marker": "Marker",
119 "Start at": "Start at",
120 "Dismiss": "Dismiss"
121 };
122 this.stringValues = {};
123 this.stringValues = this.stringValueDefaults;
124 }
125 Strings.prototype.mergeStrings = function (stringKeyValues) {
126 var _this = this;
127 Object.keys(this.stringValues).forEach(function (stringKey) {
128 if (stringKey in stringKeyValues) {
129 _this.stringValues[stringKey] = stringKeyValues[stringKey];
130 }
131 });
132 };
133 Strings.prototype.getString = function (stringKey) {
134 if (stringKey in this.stringValues) {
135 return this.stringValues[stringKey];
136 }
137 return stringKey;
138 };
139 Strings.prototype.toObject = function () {
140 return this.stringValues;
141 };
142 return Strings;
143}());
144
145var ChartOptions = /** @class */ (function () {
146 function ChartOptions() {
147 this.stringsInstance = new Strings();
148 }
149 ChartOptions.prototype.getInterpolationFunction = function (interpolationName) {
150 if (interpolationName == InterpolationFunctions.CurveLinear)
151 return curveLinear;
152 if (interpolationName == InterpolationFunctions.CurveStep)
153 return curveStep;
154 if (interpolationName == InterpolationFunctions.CurveStepBefore)
155 return curveStepBefore;
156 if (interpolationName == InterpolationFunctions.CurveStepAfter)
157 return curveStepAfter;
158 if (interpolationName == InterpolationFunctions.CurveBasis)
159 return curveBasis;
160 if (interpolationName == InterpolationFunctions.CurveCardinal)
161 return curveCardinal;
162 if (interpolationName == InterpolationFunctions.CurveMonotoneX)
163 return curveMonotoneX;
164 if (interpolationName == InterpolationFunctions.CurveCatmullRom)
165 return curveCatmullRom;
166 // default
167 return curveMonotoneX;
168 };
169 ChartOptions.prototype.setOptions = function (chartOptionsObj) {
170 chartOptionsObj = !chartOptionsObj ? {} : chartOptionsObj;
171 this.grid = this.mergeValue(chartOptionsObj, 'grid', false);
172 this.preserveAvailabilityState = this.mergeValue(chartOptionsObj, 'preserveAvailabilityState', false);
173 this.persistDateTimeButtonRange = this.mergeValue(chartOptionsObj, 'persistDateTimeButtonRange', false);
174 this.isCompact = this.mergeValue(chartOptionsObj, 'isCompact', false);
175 this.keepBrush = this.mergeValue(chartOptionsObj, 'keepBrush', false);
176 this.isArea = this.mergeValue(chartOptionsObj, 'isArea', false);
177 this.noAnimate = this.mergeValue(chartOptionsObj, 'noAnimate', false);
178 this.updateInterval = this.mergeValue(chartOptionsObj, 'updateInterval', 0);
179 this.minutesForTimeLabels = this.mergeValue(chartOptionsObj, 'minutesForTimeLabels', false);
180 this.aggTopMargin = this.mergeValue(chartOptionsObj, 'aggTopMargin', 12);
181 this.color = this.mergeValue(chartOptionsObj, 'color', null);
182 this.maxBuckets = this.mergeValue(chartOptionsObj, 'maxBuckets', 500);
183 this.yAxisHidden = this.mergeValue(chartOptionsObj, 'yAxisHidden', false);
184 this.focusHidden = this.mergeValue(chartOptionsObj, 'focusHidden', false);
185 this.singleLineXAxisLabel = this.mergeValue(chartOptionsObj, 'singleLineXAxisLabel', false);
186 this.legend = this.mergeValue(chartOptionsObj, 'legend', 'shown');
187 this.tooltip = this.mergeValue(chartOptionsObj, 'tooltip', false);
188 this.throttleSlider = this.mergeValue(chartOptionsObj, 'throttleSlider', false);
189 this.snapBrush = this.mergeValue(chartOptionsObj, 'snapBrush', false);
190 this.minBrushWidth = this.mergeValue(chartOptionsObj, 'minBrushWidth', 0);
191 this.theme = this.mergeValue(chartOptionsObj, 'theme', 'dark');
192 this.keepSplitByColor = this.mergeValue(chartOptionsObj, 'keepSplitByColor', false);
193 this.brushContextMenuActions = this.mergeValue(chartOptionsObj, 'brushContextMenuActions', null);
194 this.timeFrame = this.mergeValue(chartOptionsObj, 'timeFrame', null);
195 this.fromChart = this.mergeValue(chartOptionsObj, 'fromChart', false);
196 this.timestamp = this.mergeValue(chartOptionsObj, 'timestamp', null);
197 this.stacked = this.mergeValue(chartOptionsObj, 'stacked', false);
198 this.scaledToCurrentTime = this.mergeValue(chartOptionsObj, 'scaledToCurrentTime', false);
199 this.zeroYAxis = this.mergeValue(chartOptionsObj, 'zeroYAxis', true);
200 this.arcWidthRatio = this.mergeValue(chartOptionsObj, 'arcWidthRatio', 0);
201 this.bucketSizeMillis = this.mergeValue(chartOptionsObj, 'bucketSizeMillis', 0);
202 this.brushClearable = this.mergeValue(chartOptionsObj, 'brushClearable', true);
203 this.brushMoveAction = this.mergeValue(chartOptionsObj, 'brushMoveAction', function () { });
204 this.brushMoveEndAction = this.mergeValue(chartOptionsObj, 'brushMoveEndAction', function () { });
205 this.yAxisState = this.mergeValue(chartOptionsObj, 'yAxisState', 'stacked');
206 this.xAxisHidden = this.mergeValue(chartOptionsObj, 'xAxisHidden', false);
207 this.suppressResizeListener = this.mergeValue(chartOptionsObj, 'suppressResizeListener', false);
208 this.onMouseout = this.mergeValue(chartOptionsObj, 'onMouseout', function () { });
209 this.onMouseover = this.mergeValue(chartOptionsObj, 'onMouseover', function () { });
210 this.onSticky = this.mergeValue(chartOptionsObj, 'onSticky', function () { });
211 this.onUnsticky = this.mergeValue(chartOptionsObj, 'onUnsticky', function () { });
212 this.onKeydown = this.mergeValue(chartOptionsObj, 'onKeydown', function () { });
213 this.onInput = this.mergeValue(chartOptionsObj, 'onInput', function () { });
214 this.brushHandlesVisible = this.mergeValue(chartOptionsObj, 'brushHandlesVisible', false);
215 this.hideChartControlPanel = this.mergeValue(chartOptionsObj, 'hideChartControlPanel', false);
216 this.offset = this.mergeValue(chartOptionsObj, 'offset', 0);
217 this.is24HourTime = this.mergeValue(chartOptionsObj, 'is24HourTime', true);
218 this.includeTimezones = this.mergeValue(chartOptionsObj, 'includeTimezones', true);
219 this.availabilityLeftMargin = this.mergeValue(chartOptionsObj, 'availabilityLeftMargin', 60);
220 this.onInstanceClick = this.mergeValue(chartOptionsObj, 'onInstanceClick', function () { return {}; });
221 this.interpolationFunction = this.getInterpolationFunction(this.mergeValue(chartOptionsObj, 'interpolationFunction', InterpolationFunctions.None));
222 this.includeEnvelope = this.mergeValue(chartOptionsObj, 'includeEnvelope', false);
223 this.canDownload = this.mergeValue(chartOptionsObj, 'canDownload', true);
224 this.withContextMenu = this.mergeValue(chartOptionsObj, 'withContextMenu', false);
225 this.autoTriggerBrushContextMenu = this.mergeValue(chartOptionsObj, 'autoTriggerBrushContextMenu', false);
226 this.includeDots = this.mergeValue(chartOptionsObj, 'includeDots', false);
227 this.yExtent = this.mergeValue(chartOptionsObj, 'yExtent', null);
228 this.ellipsisItems = this.mergeValue(chartOptionsObj, 'ellipsisItems', []);
229 this.markers = Utils.getValueOrDefault(chartOptionsObj, 'markers', null); // intentionally not mergeValue
230 this.onMarkersChange = this.mergeValue(chartOptionsObj, 'onMarkersChange', function (markers) { });
231 this.spMeasures = this.mergeValue(chartOptionsObj, 'spMeasures', null);
232 this.scatterPlotRadius = this.mergeValue(chartOptionsObj, 'scatterPlotRadius', [4, 10]);
233 this.spAxisLabels = this.mergeValue(chartOptionsObj, 'spAxisLabels', null);
234 this.isTemporal = this.mergeValue(chartOptionsObj, "isTemporal", false);
235 this.xAxisTimeFormat = this.mergeValue(chartOptionsObj, 'xAxisTimeFormat', null);
236 this.brushRangeVisible = this.mergeValue(chartOptionsObj, 'brushRangeVisible', true);
237 this.strings = this.mergeStrings(Utils.getValueOrDefault(chartOptionsObj, 'strings', {}));
238 this.dateLocale = this.mergeValue(chartOptionsObj, 'dateLocale', Utils.languageGuess());
239 this.defaultAvailabilityZoomRangeMillis = this.mergeValue(chartOptionsObj, 'defaultAvailabilityZoomRangeMillis', null);
240 this.warmStoreRange = this.mergeValue(chartOptionsObj, 'warmStoreRange', null);
241 this.initialValue = this.mergeValue(chartOptionsObj, 'initialValue', null);
242 this.dTPIsModal = this.mergeValue(chartOptionsObj, 'dTPIsModal', false);
243 this.defaultColor = this.mergeValue(chartOptionsObj, 'defaultColor', null);
244 this.numberOfColors = this.mergeValue(chartOptionsObj, 'numberOfColors', 15);
245 this.colors = Utils.generateColors(this.numberOfColors, chartOptionsObj['colors'] ? chartOptionsObj['colors'] : null);
246 this.isColorValueHidden = this.mergeValue(chartOptionsObj, 'isColorValueHidden', false);
247 this.onClick = this.mergeValue(chartOptionsObj, 'onClick', function () { });
248 this.onSelect = this.mergeValue(chartOptionsObj, 'onSelect', function () { });
249 this.swimLaneOptions = this.mergeValue(chartOptionsObj, 'swimLaneOptions', null);
250 this.hierarchyOptions = this.mergeValue(chartOptionsObj, 'hierarchyOptions', Object.assign({}, DefaultHierarchyNavigationOptions));
251 this.labelSeriesWithMarker = this.mergeValue(chartOptionsObj, 'labelSeriesWithMarker', false);
252 this.onError = this.mergeValue(chartOptionsObj, 'onError', function (titleKey, messageKey, xhr) { });
253 this.timeSeriesIdProperties = Utils.getValueOrDefault(chartOptionsObj, 'timeSeriesIdProperties', []);
254 this.shouldSticky = this.mergeValue(chartOptionsObj, 'shouldSticky', true);
255 };
256 ChartOptions.prototype.mergeStrings = function (strings) {
257 this.stringsInstance.mergeStrings(strings);
258 return this.stringsInstance.toObject();
259 };
260 ChartOptions.prototype.mergeValue = function (chartOptionsObj, propertyName, defaultValue) {
261 if (this[propertyName] !== undefined && chartOptionsObj[propertyName] === undefined) {
262 return this[propertyName];
263 }
264 return Utils.getValueOrDefault(chartOptionsObj, propertyName, defaultValue);
265 };
266 ChartOptions.prototype.toObject = function () {
267 return {
268 grid: this.grid,
269 preserveAvailabilityState: this.preserveAvailabilityState,
270 persistDateTimeButtonRange: this.persistDateTimeButtonRange,
271 isCompact: this.isCompact,
272 keepBrush: this.keepBrush,
273 isArea: this.isArea,
274 noAnimate: this.noAnimate,
275 minutesForTimeLabels: this.minutesForTimeLabels,
276 aggTopMargin: this.aggTopMargin,
277 color: this.color,
278 maxBuckets: this.maxBuckets,
279 yAxisHidden: this.yAxisHidden,
280 focusHidden: this.focusHidden,
281 singleLineXAxisLabel: this.singleLineXAxisLabel,
282 legend: this.legend,
283 tooltip: this.tooltip,
284 throttleSlider: this.throttleSlider,
285 snapBrush: this.snapBrush,
286 minBrushWidth: this.minBrushWidth,
287 theme: this.theme,
288 keepSplitByColor: this.keepSplitByColor,
289 brushContextMenuActions: this.brushContextMenuActions,
290 timeFrame: this.timeFrame,
291 fromChart: this.fromChart,
292 timestamp: this.timestamp,
293 stacked: this.stacked,
294 scaledToCurrentTime: this.scaledToCurrentTime,
295 zeroYAxis: this.zeroYAxis,
296 arcWidthRatio: this.arcWidthRatio,
297 brushClearable: this.brushClearable,
298 brushMoveAction: this.brushMoveAction,
299 yAxisState: this.yAxisState,
300 xAxisHidden: this.xAxisHidden,
301 suppressResizeListener: this.suppressResizeListener,
302 brushMoveEndAction: this.brushMoveEndAction,
303 onMouseout: this.onMouseout,
304 onMouseover: this.onMouseover,
305 onSticky: this.onSticky,
306 onUnsticky: this.onUnsticky,
307 onKeydown: this.onKeydown,
308 onInput: this.onInput,
309 brushHandlesVisible: this.brushHandlesVisible,
310 hideChartControlPanel: this.hideChartControlPanel,
311 offset: this.offset,
312 is24HourTime: this.is24HourTime.valueOf,
313 includeTimezones: this.includeTimezones,
314 availabilityLeftMargin: this.availabilityLeftMargin,
315 onInstanceClick: this.onInstanceClick,
316 interpolationFunction: this.interpolationFunction,
317 includeEnvelope: this.includeEnvelope,
318 canDownload: this.canDownload,
319 withContextMenu: this.withContextMenu,
320 autoTriggerBrushContextMenu: this.autoTriggerBrushContextMenu,
321 includeDots: this.includeDots,
322 yExtent: this.yExtent,
323 ellipsisItems: this.ellipsisItems,
324 markers: this.markers,
325 onMarkersChange: this.onMarkersChange,
326 xAxisTimeFormat: this.xAxisTimeFormat,
327 spMeasures: this.spMeasures,
328 scatterPlotRadius: this.scatterPlotRadius,
329 spAxisLabels: this.spAxisLabels,
330 brushRangeVisible: this.brushRangeVisible,
331 strings: this.strings.toObject(),
332 dateLocale: this.dateLocale,
333 defaultAvailabilityZoomRangeMillis: this.defaultAvailabilityZoomRangeMillis,
334 warmStoreRange: this.warmStoreRange,
335 initialValue: this.initialValue,
336 bucketSizeMillis: this.bucketSizeMillis,
337 updateInterval: this.updateInterval,
338 dTPIsModal: this.dTPIsModal,
339 numberOfColors: this.numberOfColors,
340 defaultColor: this.defaultColor,
341 isColorValueHidden: this.isColorValueHidden,
342 onClick: this.onClick,
343 onSelect: this.onSelect,
344 colors: this.colors,
345 swimLaneOptions: this.swimLaneOptions,
346 hierarchyOptions: this.hierarchyOptions,
347 onError: this.onError,
348 labelSeriesWithMarker: this.labelSeriesWithMarker,
349 timeSeriesIdProperties: this.timeSeriesIdProperties,
350 shouldSticky: this.shouldSticky
351 };
352 };
353 return ChartOptions;
354}());
355
356var Component = /** @class */ (function () {
357 function Component(renderTarget) {
358 this.TRANSDURATION = (window.navigator.userAgent.indexOf("Edge") > -1) ? 0 : 400;
359 this.usesSeconds = false;
360 this.usesMillis = false;
361 this.chartOptions = new ChartOptions();
362 this.teardropD = function (width, height) {
363 return "M" + width / 2 + " " + height / 14 + " \n Q" + width / 1.818 + " " + height / 6.17 + " " + width / 1.2 + " " + height / 2.33 + "\n A" + width / 2.35 + " " + width / 2.35 + " 0 1 1 " + width / 6 + " " + width / 2.33 + "\n Q" + width / 2.22 + " " + height / 6.18 + " " + width / 2 + " " + height / 14 + "z";
364 };
365 this.renderTarget = renderTarget;
366 }
367 Component.prototype.getString = function (str) {
368 return this.chartOptions.stringsInstance.getString(str);
369 };
370 Component.prototype.themify = function (targetElement, theme) {
371 var theme = Utils.getTheme(theme);
372 targetElement === null || targetElement === void 0 ? void 0 : targetElement.classed(this.currentTheme, false);
373 targetElement === null || targetElement === void 0 ? void 0 : targetElement.classed('tsi-light', false);
374 targetElement === null || targetElement === void 0 ? void 0 : targetElement.classed('tsi-dark', false);
375 targetElement === null || targetElement === void 0 ? void 0 : targetElement.classed(theme, true);
376 this.currentTheme = theme;
377 };
378 Component.prototype.tooltipFormat = function (d, text, measureFormat, xyrMeasures) {
379 };
380 Component.prototype.createTooltipSeriesInfo = function (d, group, cDO) {
381 var title = group.append('h2').attr('class', 'tsi-tooltipGroupName tsi-tooltipTitle');
382 Utils.appendFormattedElementsFromString(title, d.aggregateName);
383 if (d.splitBy && d.splitBy != "") {
384 var splitBy = group.append('p')
385 .attr('class', 'tsi-tooltipSeriesName tsi-tooltipSubtitle');
386 Utils.appendFormattedElementsFromString(splitBy, d.splitBy);
387 }
388 if (cDO.variableAlias && cDO.isVariableAliasShownOnTooltip) {
389 group.append('p')
390 .text(cDO.variableAlias)
391 .attr('class', 'tsi-tooltipVariableAlias tsi-tooltipSubtitle');
392 }
393 };
394 return Component;
395}());
396
397export { Component as C, ChartOptions as a };