tsichart-core 2.0.0-beta.2 → 2.0.0-beta.6
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.
- package/dist/index.js +122 -158
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +122 -158
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +45264 -0
- package/dist/index.umd.js.map +1 -0
- package/package.json +30 -12
- package/src/styles.d.ts +25 -0
package/dist/index.mjs
CHANGED
|
@@ -1047,8 +1047,7 @@ Utils.getTimeSeriesIdToDisplay = (instance, emptyDisplayString) => {
|
|
|
1047
1047
|
return Utils.instanceHasEmptyTSID(instance) ? emptyDisplayString : instance.timeSeriesId.map(id => id === null ? Utils.guidForNullTSID : id).join(', ');
|
|
1048
1048
|
};
|
|
1049
1049
|
Utils.getHighlightedTimeSeriesIdToDisplay = (instance) => {
|
|
1050
|
-
|
|
1051
|
-
return (_a = instance.highlights) === null || _a === void 0 ? void 0 : _a.timeSeriesId.map((id, idx) => instance.timeSeriesId[idx] === null ? Utils.guidForNullTSID : id).join(', ');
|
|
1050
|
+
return instance.highlights?.timeSeriesId.map((id, idx) => instance.timeSeriesId[idx] === null ? Utils.guidForNullTSID : id).join(', ');
|
|
1052
1051
|
};
|
|
1053
1052
|
Utils.instanceHasEmptyTSID = (instance) => {
|
|
1054
1053
|
return !instance.timeSeriesId || instance.timeSeriesId.length === 0;
|
|
@@ -1481,10 +1480,10 @@ class Component {
|
|
|
1481
1480
|
}
|
|
1482
1481
|
themify(targetElement, theme) {
|
|
1483
1482
|
var theme = Utils.getTheme(theme);
|
|
1484
|
-
targetElement
|
|
1485
|
-
targetElement
|
|
1486
|
-
targetElement
|
|
1487
|
-
targetElement
|
|
1483
|
+
targetElement?.classed(this.currentTheme, false);
|
|
1484
|
+
targetElement?.classed('tsi-light', false);
|
|
1485
|
+
targetElement?.classed('tsi-dark', false);
|
|
1486
|
+
targetElement?.classed(theme, true);
|
|
1488
1487
|
this.currentTheme = theme;
|
|
1489
1488
|
}
|
|
1490
1489
|
tooltipFormat(d, text, measureFormat, xyrMeasures = null) {
|
|
@@ -1707,7 +1706,7 @@ class Legend extends Component {
|
|
|
1707
1706
|
}
|
|
1708
1707
|
labelMouseoutWrapper(labelMouseout, svgSelection, event) {
|
|
1709
1708
|
return (svgSelection, aggKey) => {
|
|
1710
|
-
event
|
|
1709
|
+
event?.stopPropagation();
|
|
1711
1710
|
svgSelection.selectAll(".tsi-valueElement")
|
|
1712
1711
|
.filter(function () { return !d3.select(this).classed("tsi-valueEnvelope"); })
|
|
1713
1712
|
.attr("stroke-opacity", 1)
|
|
@@ -2073,7 +2072,7 @@ class ChartComponentData {
|
|
|
2073
2072
|
let aggKeys = Utils.getAggKeys(this.data);
|
|
2074
2073
|
this.data = this.data.map((aggregate, i) => {
|
|
2075
2074
|
var aggName = Object.keys(aggregate)[0];
|
|
2076
|
-
let aggregateCopy =
|
|
2075
|
+
let aggregateCopy = { ...aggregate };
|
|
2077
2076
|
let aggKey = aggKeys[i];
|
|
2078
2077
|
this.data[i].aggKey = aggKey;
|
|
2079
2078
|
aggregateCopy.aggKey = aggKey;
|
|
@@ -4010,7 +4009,7 @@ class LinePlot extends Plot {
|
|
|
4010
4009
|
}
|
|
4011
4010
|
let envelopeData = {};
|
|
4012
4011
|
if ((self.chartComponentData.displayState[aggKey].includeEnvelope || self.chartOptions.includeEnvelope) && self.chartComponentData.isPossibleEnvelope(aggKey, splitBy)) {
|
|
4013
|
-
envelopeData = self.chartComponentData.timeArrays[aggKey][splitBy].map((d) => (
|
|
4012
|
+
envelopeData = self.chartComponentData.timeArrays[aggKey][splitBy].map((d) => ({ ...d, isEnvelope: true }));
|
|
4014
4013
|
}
|
|
4015
4014
|
let envelope = d3.select(this).selectAll(".tsi-valueEnvelope")
|
|
4016
4015
|
.data([envelopeData]);
|
|
@@ -6100,7 +6099,6 @@ class LineChart extends TemporalXAxisComponent {
|
|
|
6100
6099
|
let visibleCDOs = this.aggregateExpressionOptions.filter((cDO) => this.chartComponentData.displayState[cDO.aggKey]["visible"]);
|
|
6101
6100
|
const markerList = [];
|
|
6102
6101
|
const pushMarker = (cDO, marker, markerList) => {
|
|
6103
|
-
var _a, _b;
|
|
6104
6102
|
if (this.chartOptions.yAxisState === YAxisStates.Overlap) {
|
|
6105
6103
|
return;
|
|
6106
6104
|
}
|
|
@@ -6109,10 +6107,10 @@ class LineChart extends TemporalXAxisComponent {
|
|
|
6109
6107
|
this.swimlaneYExtents[0];
|
|
6110
6108
|
// filter out markers not in the y range of that lane and in lanes that have overlap axis
|
|
6111
6109
|
if (domain &&
|
|
6112
|
-
|
|
6110
|
+
this.chartOptions.swimLaneOptions?.[cDO.swimLane]?.yAxisType !== YAxisStates.Overlap &&
|
|
6113
6111
|
marker.value >= domain[0] &&
|
|
6114
6112
|
marker.value <= domain[1]) {
|
|
6115
|
-
markerList.push(
|
|
6113
|
+
markerList.push({ yScale: this.yMap[cDO.aggKey], ...marker });
|
|
6116
6114
|
}
|
|
6117
6115
|
};
|
|
6118
6116
|
visibleCDOs.forEach((cDO) => {
|
|
@@ -6128,9 +6126,8 @@ class LineChart extends TemporalXAxisComponent {
|
|
|
6128
6126
|
};
|
|
6129
6127
|
if (this.chartOptions.yAxisState !== YAxisStates.Overlap && this.chartOptions.swimLaneOptions) {
|
|
6130
6128
|
Object.keys(this.chartOptions.swimLaneOptions).forEach((swimlaneNumber) => {
|
|
6131
|
-
var _a;
|
|
6132
6129
|
const swimlaneOptions = this.chartOptions.swimLaneOptions[swimlaneNumber];
|
|
6133
|
-
|
|
6130
|
+
swimlaneOptions.horizontalMarkers?.forEach((horizontalMarkerParams) => {
|
|
6134
6131
|
const firstVisibleCDO = findFirstVisibleCDO(Number(swimlaneNumber));
|
|
6135
6132
|
if (firstVisibleCDO) {
|
|
6136
6133
|
pushMarker(firstVisibleCDO, horizontalMarkerParams, markerList);
|
|
@@ -6199,17 +6196,16 @@ class LineChart extends TemporalXAxisComponent {
|
|
|
6199
6196
|
current height of the lane.
|
|
6200
6197
|
*/
|
|
6201
6198
|
const useAggForLaneLabel = (aggGroup) => {
|
|
6202
|
-
var _a, _b, _c, _d, _e, _f;
|
|
6203
6199
|
let swimLane = aggGroup.swimLane;
|
|
6204
6200
|
let aggIndex = visibleCDOs.findIndex(el => el.aggKey === aggGroup.aggKey);
|
|
6205
6201
|
let onClick = null;
|
|
6206
|
-
if (typeof
|
|
6207
|
-
onClick = () =>
|
|
6202
|
+
if (typeof this.chartOptions?.swimLaneOptions?.[swimLane]?.onClick === 'function') {
|
|
6203
|
+
onClick = () => this.chartOptions?.swimLaneOptions?.[swimLane]?.onClick?.(swimLane);
|
|
6208
6204
|
}
|
|
6209
6205
|
swimLaneLabels[swimLane] = {
|
|
6210
6206
|
offset: offsetsAndHeights[aggIndex][0],
|
|
6211
6207
|
height: offsetsAndHeights[aggIndex][1],
|
|
6212
|
-
label:
|
|
6208
|
+
label: this.chartOptions?.swimLaneOptions?.[swimLane]?.label,
|
|
6213
6209
|
onClick
|
|
6214
6210
|
};
|
|
6215
6211
|
};
|
|
@@ -6221,13 +6217,12 @@ class LineChart extends TemporalXAxisComponent {
|
|
|
6221
6217
|
});
|
|
6222
6218
|
// Then, map over any non-numeric dataType and increment heights if they're sharing a lane
|
|
6223
6219
|
visibleCDOs.filter(aggGroup => aggGroup.dataType !== DataTypes.Numeric).forEach(aggGroup => {
|
|
6224
|
-
var _a, _b, _c;
|
|
6225
6220
|
let aggIndex = visibleCDOs.findIndex(el => el.aggKey === aggGroup.aggKey);
|
|
6226
6221
|
if (!(aggGroup.swimLane in swimLaneLabels)) { // Only add swimlanes once to swimLaneLabels map
|
|
6227
6222
|
useAggForLaneLabel(aggGroup);
|
|
6228
6223
|
}
|
|
6229
6224
|
else { // if lane contains non-numeric data and is being added to another lane
|
|
6230
|
-
if (!
|
|
6225
|
+
if (!this.chartOptions?.swimLaneOptions?.[aggGroup.swimLane]?.collapseEvents) { // Only increment event heights if collapseEvents === false
|
|
6231
6226
|
swimLaneLabels[aggGroup.swimLane].height += offsetsAndHeights[aggIndex][1]; // add heights (non-numerics don't share Y axis)
|
|
6232
6227
|
}
|
|
6233
6228
|
}
|
|
@@ -6285,6 +6280,7 @@ class LineChart extends TemporalXAxisComponent {
|
|
|
6285
6280
|
});
|
|
6286
6281
|
}
|
|
6287
6282
|
render(data, options, aggregateExpressionOptions) {
|
|
6283
|
+
console.log('LineChart render called a');
|
|
6288
6284
|
super.render(data, options, aggregateExpressionOptions);
|
|
6289
6285
|
this.originalSwimLanes = this.aggregateExpressionOptions.map((aEO) => {
|
|
6290
6286
|
return aEO.swimLane;
|
|
@@ -6339,7 +6335,7 @@ class LineChart extends TemporalXAxisComponent {
|
|
|
6339
6335
|
.attr("type", "button")
|
|
6340
6336
|
.on("click", function () {
|
|
6341
6337
|
self.overwriteSwimLanes();
|
|
6342
|
-
self.render(self.data,
|
|
6338
|
+
self.render(self.data, { ...self.chartOptions, yAxisState: self.nextStackedState() }, self.aggregateExpressionOptions);
|
|
6343
6339
|
d3.select(this).attr("aria-label", () => self.getString("set axis state to") + ' ' + self.nextStackedState());
|
|
6344
6340
|
setTimeout(() => d3.select(this).node().focus(), 200);
|
|
6345
6341
|
});
|
|
@@ -6429,8 +6425,7 @@ class LineChart extends TemporalXAxisComponent {
|
|
|
6429
6425
|
this.aggregateExpressionOptions.filter((aggExpOpt) => {
|
|
6430
6426
|
return this.chartComponentData.displayState[aggExpOpt.aggKey]["visible"];
|
|
6431
6427
|
}).forEach(visibleAgg => {
|
|
6432
|
-
|
|
6433
|
-
if ((_b = (_a = this.originalSwimLaneOptions) === null || _a === void 0 ? void 0 : _a[visibleAgg.swimLane]) === null || _b === void 0 ? void 0 : _b.label) {
|
|
6428
|
+
if (this.originalSwimLaneOptions?.[visibleAgg.swimLane]?.label) {
|
|
6434
6429
|
isLabelVisible = true;
|
|
6435
6430
|
}
|
|
6436
6431
|
});
|
|
@@ -6587,7 +6582,6 @@ class LineChart extends TemporalXAxisComponent {
|
|
|
6587
6582
|
return self.chartOptions.isArea ? null : 'translate(0,' + offsetsAndHeights[i][0] + ')';
|
|
6588
6583
|
})
|
|
6589
6584
|
.each(function (agg, i) {
|
|
6590
|
-
var _a, _b, _c;
|
|
6591
6585
|
let yExtent;
|
|
6592
6586
|
let aggVisible = true;
|
|
6593
6587
|
var aggValues = [];
|
|
@@ -6627,8 +6621,8 @@ class LineChart extends TemporalXAxisComponent {
|
|
|
6627
6621
|
}
|
|
6628
6622
|
let axisState = new AxisState(self.getAggAxisType(agg), yExtent, positionInGroup);
|
|
6629
6623
|
let yAxisOnClick = null;
|
|
6630
|
-
if (typeof
|
|
6631
|
-
yAxisOnClick = () =>
|
|
6624
|
+
if (typeof self.chartOptions?.swimLaneOptions?.[swimLane]?.onClick === 'function') {
|
|
6625
|
+
yAxisOnClick = () => self.chartOptions.swimLaneOptions[swimLane].onClick?.(swimLane);
|
|
6632
6626
|
}
|
|
6633
6627
|
self.plotComponents[aggKey].render(self.chartOptions, visibleNumericI, agg, true, d3.select(this), self.chartComponentData, axisState, self.chartHeight, self.visibleAggCount, self.colorMap, self.previousAggregateData, self.x, self.areaPath, self.strokeOpacity, self.y, self.yMap, defs, visibleCDOs[i], self.previousIncludeDots, offsetsAndHeights[i], g, mouseoverFunction, mouseoutFunction, yAxisOnClick);
|
|
6634
6628
|
//increment index of visible numerics if appropriate
|
|
@@ -8556,7 +8550,7 @@ class DateTimePicker extends ChartComponent {
|
|
|
8556
8550
|
const MAXCARD = 150000;
|
|
8557
8551
|
class AggregateExpression extends ChartDataOptions {
|
|
8558
8552
|
constructor(predicateObject, measureObject, measureTypes, searchSpan, splitByObject = null, colorOrOptionsObject, alias, contextMenu) {
|
|
8559
|
-
super((typeof (colorOrOptionsObject) === 'object' && !!colorOrOptionsObject) ?
|
|
8553
|
+
super((typeof (colorOrOptionsObject) === 'object' && !!colorOrOptionsObject) ? { ...colorOrOptionsObject, searchSpan: searchSpan, measureTypes: measureTypes } : { color: colorOrOptionsObject, searchSpan: searchSpan, measureTypes: measureTypes, alias: alias, contextMenu: contextMenu });
|
|
8560
8554
|
this.visibleSplitByCap = 10;
|
|
8561
8555
|
this.predicate = predicateObject;
|
|
8562
8556
|
this.splitByObject = splitByObject;
|
|
@@ -8743,16 +8737,18 @@ class AvailabilityChart extends ChartComponent {
|
|
|
8743
8737
|
event.preventDefault && event.preventDefault();
|
|
8744
8738
|
}
|
|
8745
8739
|
setChartOptions(chartOptions) {
|
|
8746
|
-
this.chartOptions.setOptions(
|
|
8747
|
-
|
|
8748
|
-
|
|
8749
|
-
|
|
8750
|
-
|
|
8751
|
-
|
|
8752
|
-
|
|
8753
|
-
|
|
8754
|
-
|
|
8755
|
-
|
|
8740
|
+
this.chartOptions.setOptions({
|
|
8741
|
+
...chartOptions, ...{
|
|
8742
|
+
keepBrush: true,
|
|
8743
|
+
isArea: true,
|
|
8744
|
+
noAnimate: true,
|
|
8745
|
+
minutesForTimeLabels: true,
|
|
8746
|
+
aggTopMargin: 0,
|
|
8747
|
+
yAxisHidden: true,
|
|
8748
|
+
focusHidden: true,
|
|
8749
|
+
singleLineXAxisLabel: false
|
|
8750
|
+
}
|
|
8751
|
+
});
|
|
8756
8752
|
}
|
|
8757
8753
|
dateTimePickerAction(fromMillis, toMillis) {
|
|
8758
8754
|
this.setBrush(fromMillis, toMillis, true);
|
|
@@ -9114,12 +9110,14 @@ class AvailabilityChart extends ChartComponent {
|
|
|
9114
9110
|
this.zoomedToMillis = toMillis;
|
|
9115
9111
|
var visibileAvailability = this.createDisplayBuckets(fromMillis, toMillis);
|
|
9116
9112
|
this.chartOptions.keepBrush = true;
|
|
9117
|
-
var aeWithNewTimeSpan =
|
|
9118
|
-
|
|
9119
|
-
|
|
9120
|
-
|
|
9113
|
+
var aeWithNewTimeSpan = {
|
|
9114
|
+
...this.ae[0], ...{
|
|
9115
|
+
searchSpan: {
|
|
9116
|
+
from: (new Date(fromMillis)),
|
|
9117
|
+
to: (new Date(toMillis))
|
|
9118
|
+
}
|
|
9121
9119
|
}
|
|
9122
|
-
}
|
|
9120
|
+
};
|
|
9123
9121
|
this.timePickerLineChart.render(visibileAvailability, this.chartOptions, [aeWithNewTimeSpan]);
|
|
9124
9122
|
this.setTicks();
|
|
9125
9123
|
this.drawWarmRange();
|
|
@@ -9562,7 +9560,7 @@ class PieChart extends ChartVisualizationComponent {
|
|
|
9562
9560
|
var yPos = mousePosition[1];
|
|
9563
9561
|
tooltip.render(self.chartOptions.theme);
|
|
9564
9562
|
let color = Utils.colorSplitBy(self.chartComponentData.displayState, d.data.splitByI, d.data.aggKey, self.chartOptions.keepSplitByColor);
|
|
9565
|
-
tooltip.draw(d, self.chartComponentData, xPos, yPos,
|
|
9563
|
+
tooltip.draw(d, self.chartComponentData, xPos, yPos, { ...self.chartMargins, top: 0, bottom: 0 }, (text) => {
|
|
9566
9564
|
self.tooltipFormat(self.convertToTimeValueFormat(d.data), text, TooltipMeasureFormat.SingleValue);
|
|
9567
9565
|
}, null, 20, 20, color);
|
|
9568
9566
|
}
|
|
@@ -10106,8 +10104,7 @@ class ScatterPlot extends ChartVisualizationComponent {
|
|
|
10106
10104
|
let connectedSeriesMap = {};
|
|
10107
10105
|
// Find measure by which to connect series of points
|
|
10108
10106
|
const getPointConnectionMeasure = (point => {
|
|
10109
|
-
|
|
10110
|
-
let pConMes = (_a = this.aggregateExpressionOptions[point.aggregateKeyI]) === null || _a === void 0 ? void 0 : _a.pointConnectionMeasure;
|
|
10107
|
+
let pConMes = this.aggregateExpressionOptions[point.aggregateKeyI]?.pointConnectionMeasure;
|
|
10111
10108
|
return pConMes && pConMes in point.measures ? pConMes : null;
|
|
10112
10109
|
});
|
|
10113
10110
|
// Map data into groups of connected points, if connectedPoints enabled for agg
|
|
@@ -11769,7 +11766,7 @@ class Heatmap extends TemporalXAxisComponent {
|
|
|
11769
11766
|
super.render(data, chartOptions, aggregateExpressionOptions);
|
|
11770
11767
|
// override visibleSplitByCap
|
|
11771
11768
|
this.aggregateExpressionOptions = this.aggregateExpressionOptions.map((aE) => {
|
|
11772
|
-
return
|
|
11769
|
+
return { ...aE, visibleSplitByCap: 10000 };
|
|
11773
11770
|
});
|
|
11774
11771
|
this.chartOptions.setOptions(chartOptions);
|
|
11775
11772
|
var targetElement = d3.select(this.renderTarget).classed("tsi-heatmapComponent", true);
|
|
@@ -12540,9 +12537,13 @@ class ModelSearch extends Component {
|
|
|
12540
12537
|
}
|
|
12541
12538
|
};
|
|
12542
12539
|
let modelAutocomplete = new ModelAutocomplete(inputWrapper.node());
|
|
12543
|
-
modelAutocomplete.render(environmentFqdn, getToken,
|
|
12540
|
+
modelAutocomplete.render(environmentFqdn, getToken, {
|
|
12541
|
+
onInput: autocompleteOnInput,
|
|
12542
|
+
onKeydown: (event, ap) => {
|
|
12544
12543
|
this.handleKeydown(event, ap);
|
|
12545
|
-
}
|
|
12544
|
+
},
|
|
12545
|
+
...chartOptions,
|
|
12546
|
+
});
|
|
12546
12547
|
modelAutocomplete.ap;
|
|
12547
12548
|
let results = this.wrapper
|
|
12548
12549
|
.append("div")
|
|
@@ -12577,7 +12578,10 @@ class ModelSearch extends Component {
|
|
|
12577
12578
|
.append("div")
|
|
12578
12579
|
.attr("class", "tsi-hierarchyWrapper");
|
|
12579
12580
|
let hierarchy = new Hierarchy(hierarchyElement.node());
|
|
12580
|
-
hierarchy.render(hierarchyData,
|
|
12581
|
+
hierarchy.render(hierarchyData, {
|
|
12582
|
+
...this.chartOptions,
|
|
12583
|
+
withContextMenu: true,
|
|
12584
|
+
});
|
|
12581
12585
|
let searchInstances = (searchText, ct = null) => {
|
|
12582
12586
|
var self = this;
|
|
12583
12587
|
if (ct === "END")
|
|
@@ -12676,13 +12680,18 @@ class TsqExpression extends ChartDataOptions {
|
|
|
12676
12680
|
// new TsqExpression(instanceObject, variableObject, searchSpan, color, alias, contextMenu)
|
|
12677
12681
|
// Here we differentiate between both and call the parent class's constructor as appropriate.
|
|
12678
12682
|
let optionsObject = (typeof (colorOrOptionsObject) === 'object' && !!colorOrOptionsObject)
|
|
12679
|
-
?
|
|
12680
|
-
|
|
12681
|
-
|
|
12682
|
-
|
|
12683
|
-
|
|
12684
|
-
|
|
12685
|
-
|
|
12683
|
+
? {
|
|
12684
|
+
...colorOrOptionsObject,
|
|
12685
|
+
searchSpan: searchSpan,
|
|
12686
|
+
measureTypes: Object.keys(variableObject)
|
|
12687
|
+
}
|
|
12688
|
+
: {
|
|
12689
|
+
color: colorOrOptionsObject,
|
|
12690
|
+
searchSpan: searchSpan,
|
|
12691
|
+
measureTypes: Object.keys(variableObject),
|
|
12692
|
+
alias: alias,
|
|
12693
|
+
contextMenu: contextMenu
|
|
12694
|
+
};
|
|
12686
12695
|
super(optionsObject);
|
|
12687
12696
|
this.instanceObject = instanceObject;
|
|
12688
12697
|
this.variableObject = variableObject;
|
|
@@ -12705,13 +12714,13 @@ class TsqExpression extends ChartDataOptions {
|
|
|
12705
12714
|
return { getEvents: tsq };
|
|
12706
12715
|
}
|
|
12707
12716
|
else if (getSeries) {
|
|
12708
|
-
tsq['inlineVariables'] =
|
|
12717
|
+
tsq['inlineVariables'] = { ...this.variableObject };
|
|
12709
12718
|
tsq['projectedVariables'] = Object.keys(this.variableObject);
|
|
12710
12719
|
return { getSeries: tsq };
|
|
12711
12720
|
}
|
|
12712
12721
|
else {
|
|
12713
12722
|
tsq['interval'] = Utils.bucketSizeToTsqInterval(this.searchSpan.bucketSize);
|
|
12714
|
-
tsq['inlineVariables'] =
|
|
12723
|
+
tsq['inlineVariables'] = { ...this.variableObject };
|
|
12715
12724
|
tsq['projectedVariables'] = Object.keys(this.variableObject);
|
|
12716
12725
|
return { aggregateSeries: tsq };
|
|
12717
12726
|
}
|
|
@@ -12740,38 +12749,6 @@ class TsqExpression extends ChartDataOptions {
|
|
|
12740
12749
|
}
|
|
12741
12750
|
}
|
|
12742
12751
|
|
|
12743
|
-
/******************************************************************************
|
|
12744
|
-
Copyright (c) Microsoft Corporation.
|
|
12745
|
-
|
|
12746
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
12747
|
-
purpose with or without fee is hereby granted.
|
|
12748
|
-
|
|
12749
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
12750
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
12751
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12752
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
12753
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12754
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
12755
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
12756
|
-
***************************************************************************** */
|
|
12757
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
12758
|
-
|
|
12759
|
-
|
|
12760
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
12761
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
12762
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
12763
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12764
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12765
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
12766
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12767
|
-
});
|
|
12768
|
-
}
|
|
12769
|
-
|
|
12770
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
12771
|
-
var e = new Error(message);
|
|
12772
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
12773
|
-
};
|
|
12774
|
-
|
|
12775
12752
|
class HierarchyNavigation extends Component {
|
|
12776
12753
|
constructor(renderTarget) {
|
|
12777
12754
|
super(renderTarget);
|
|
@@ -12780,24 +12757,23 @@ class HierarchyNavigation extends Component {
|
|
|
12780
12757
|
this.selectedIds = [];
|
|
12781
12758
|
this.searchEnabled = true;
|
|
12782
12759
|
this.renderSearchResult = (r, payload, target) => {
|
|
12783
|
-
|
|
12784
|
-
const hierarchyData = ((_b = (_a = r.hierarchyNodes) === null || _a === void 0 ? void 0 : _a.hits) === null || _b === void 0 ? void 0 : _b.length)
|
|
12760
|
+
const hierarchyData = r.hierarchyNodes?.hits?.length
|
|
12785
12761
|
? this.fillDataRecursively(r.hierarchyNodes, payload, payload)
|
|
12786
12762
|
: {};
|
|
12787
|
-
const instancesData =
|
|
12763
|
+
const instancesData = r.instances?.hits?.length
|
|
12788
12764
|
? r.instances.hits.reduce((acc, i) => {
|
|
12789
12765
|
acc[this.instanceNodeIdentifier(i)] = new InstanceNode(i.timeSeriesId, i.name, payload.path.length - this.path.length, i.id, i.description);
|
|
12790
12766
|
return acc;
|
|
12791
12767
|
}, {})
|
|
12792
12768
|
: {};
|
|
12793
|
-
if (
|
|
12769
|
+
if (r.hierarchyNodes?.hits?.length) {
|
|
12794
12770
|
let hitCountElem = target.select(".tsi-hitCount");
|
|
12795
12771
|
if (hitCountElem.size() === 0) {
|
|
12796
12772
|
hitCountElem = target.append('span').classed('tsi-hitCount', true).text('');
|
|
12797
12773
|
}
|
|
12798
12774
|
hitCountElem.text(r.hierarchyNodes.hitCount);
|
|
12799
12775
|
}
|
|
12800
|
-
this.renderTree(
|
|
12776
|
+
this.renderTree({ ...hierarchyData, ...instancesData }, target);
|
|
12801
12777
|
};
|
|
12802
12778
|
this.hierarchyNodeIdentifier = (hName) => {
|
|
12803
12779
|
return hName ? hName : '(' + this.getString("Empty") + ')';
|
|
@@ -12806,31 +12782,25 @@ class HierarchyNavigation extends Component {
|
|
|
12806
12782
|
return `instance-${Utils.getInstanceKey(instance)}`;
|
|
12807
12783
|
};
|
|
12808
12784
|
this.instanceNodeStringToDisplay = (instance) => {
|
|
12809
|
-
|
|
12810
|
-
return ((_a = instance.highlights) === null || _a === void 0 ? void 0 : _a.name) || Utils.getHighlightedTimeSeriesIdToDisplay(instance)
|
|
12785
|
+
return instance.highlights?.name || Utils.getHighlightedTimeSeriesIdToDisplay(instance)
|
|
12811
12786
|
|| instance.name || Utils.getTimeSeriesIdToDisplay(instance, this.getString('Empty'));
|
|
12812
12787
|
};
|
|
12813
12788
|
this.instanceNodeString = (instance) => {
|
|
12814
12789
|
return instance.name || Utils.getTimeSeriesIdString(instance);
|
|
12815
12790
|
};
|
|
12816
12791
|
}
|
|
12817
|
-
render(
|
|
12818
|
-
|
|
12819
|
-
|
|
12820
|
-
|
|
12821
|
-
|
|
12822
|
-
|
|
12823
|
-
|
|
12824
|
-
|
|
12825
|
-
|
|
12826
|
-
|
|
12827
|
-
|
|
12828
|
-
|
|
12829
|
-
_super.themify.call(this, this.hierarchyNavWrapper, this.chartOptions.theme);
|
|
12830
|
-
const results = this.createResultsWrapper(this.hierarchyNavWrapper);
|
|
12831
|
-
this.hierarchyElem = this.createHierarchyElem(results);
|
|
12832
|
-
this.pathSearchAndRenderResult({ search: { payload: this.requestPayload() }, render: { target: this.hierarchyElem } });
|
|
12833
|
-
});
|
|
12792
|
+
async render(searchF, hierarchyNavOptions = {}, preselectedIds) {
|
|
12793
|
+
this.chartOptions.setOptions(hierarchyNavOptions);
|
|
12794
|
+
this.searchFunction = searchF;
|
|
12795
|
+
const targetElement = d3.select(this.renderTarget).text('');
|
|
12796
|
+
this.hierarchyNavWrapper = this.createHierarchyNavWrapper(targetElement);
|
|
12797
|
+
this.selectedIds = preselectedIds;
|
|
12798
|
+
//render search wrapper
|
|
12799
|
+
//this.renderSearchBox()
|
|
12800
|
+
super.themify(this.hierarchyNavWrapper, this.chartOptions.theme);
|
|
12801
|
+
const results = this.createResultsWrapper(this.hierarchyNavWrapper);
|
|
12802
|
+
this.hierarchyElem = this.createHierarchyElem(results);
|
|
12803
|
+
this.pathSearchAndRenderResult({ search: { payload: this.requestPayload() }, render: { target: this.hierarchyElem } });
|
|
12834
12804
|
}
|
|
12835
12805
|
createHierarchyNavWrapper(targetElement) {
|
|
12836
12806
|
return targetElement.append('div').attr('class', 'tsi-hierarchy-nav-wrapper');
|
|
@@ -12843,8 +12813,7 @@ class HierarchyNavigation extends Component {
|
|
|
12843
12813
|
}
|
|
12844
12814
|
// prepares the parameters for search request
|
|
12845
12815
|
requestPayload(hierarchy = null) {
|
|
12846
|
-
|
|
12847
|
-
const path = (_a = hierarchy === null || hierarchy === void 0 ? void 0 : hierarchy.path) !== null && _a !== void 0 ? _a : this.path;
|
|
12816
|
+
const path = hierarchy?.path ?? this.path;
|
|
12848
12817
|
return { path, hierarchy };
|
|
12849
12818
|
}
|
|
12850
12819
|
// renders tree for both 'Navigate' and 'Filter' mode (with Hierarchy View option selected), locInTarget refers to the 'show more' element -either hierarchy or instance- within the target
|
|
@@ -12908,22 +12877,20 @@ class HierarchyNavigation extends Component {
|
|
|
12908
12877
|
}
|
|
12909
12878
|
});
|
|
12910
12879
|
}
|
|
12911
|
-
pathSearchAndRenderResult(
|
|
12912
|
-
|
|
12913
|
-
|
|
12914
|
-
|
|
12915
|
-
|
|
12916
|
-
throw result.error;
|
|
12917
|
-
}
|
|
12918
|
-
this.renderSearchResult(result, payload, target);
|
|
12880
|
+
async pathSearchAndRenderResult({ search: { payload, bubbleUpReject = false }, render: { target, locInTarget = null } }) {
|
|
12881
|
+
try {
|
|
12882
|
+
const result = await this.searchFunction(payload);
|
|
12883
|
+
if (result.error) {
|
|
12884
|
+
throw result.error;
|
|
12919
12885
|
}
|
|
12920
|
-
|
|
12921
|
-
|
|
12922
|
-
|
|
12923
|
-
|
|
12924
|
-
|
|
12886
|
+
this.renderSearchResult(result, payload, target);
|
|
12887
|
+
}
|
|
12888
|
+
catch (err) {
|
|
12889
|
+
this.chartOptions.onError("Error in hierarchy navigation", "Failed to complete search", err instanceof XMLHttpRequest ? err : null);
|
|
12890
|
+
if (bubbleUpReject) {
|
|
12891
|
+
throw err;
|
|
12925
12892
|
}
|
|
12926
|
-
}
|
|
12893
|
+
}
|
|
12927
12894
|
}
|
|
12928
12895
|
filterTree(searchText) {
|
|
12929
12896
|
let tree = this.hierarchyElem.selectAll('ul').nodes()[0];
|
|
@@ -12942,7 +12909,6 @@ class HierarchyNavigation extends Component {
|
|
|
12942
12909
|
fillDataRecursively(hierarchyNodes, payload, payloadForContinuation = null) {
|
|
12943
12910
|
let data = {};
|
|
12944
12911
|
hierarchyNodes.hits.forEach((h) => {
|
|
12945
|
-
var _a;
|
|
12946
12912
|
let hierarchy = new HierarchyNode(h.name, payload.path, payload.path.length - this.path.length, h.cumulativeInstanceCount, h.id);
|
|
12947
12913
|
hierarchy.expand = () => {
|
|
12948
12914
|
hierarchy.isExpanded = true;
|
|
@@ -12953,7 +12919,7 @@ class HierarchyNavigation extends Component {
|
|
|
12953
12919
|
});
|
|
12954
12920
|
};
|
|
12955
12921
|
data[this.hierarchyNodeIdentifier(h.name)] = hierarchy;
|
|
12956
|
-
if (
|
|
12922
|
+
if (h.hierarchyNodes?.hits.length) {
|
|
12957
12923
|
hierarchy.children = this.fillDataRecursively(h.hierarchyNodes, this.requestPayload(hierarchy), payloadForContinuation);
|
|
12958
12924
|
}
|
|
12959
12925
|
});
|
|
@@ -12970,36 +12936,34 @@ class HierarchyNavigation extends Component {
|
|
|
12970
12936
|
.attr('arialabel', isHierarchyNode ? key : self.getAriaLabel(hORi))
|
|
12971
12937
|
.attr('title', isHierarchyNode ? key : self.getAriaLabel(hORi))
|
|
12972
12938
|
.attr("role", "treeitem").attr('aria-expanded', hORi.isExpanded)
|
|
12973
|
-
.on('click keydown', function (event) {
|
|
12974
|
-
|
|
12975
|
-
|
|
12976
|
-
|
|
12977
|
-
|
|
12978
|
-
|
|
12979
|
-
|
|
12980
|
-
|
|
12981
|
-
|
|
12982
|
-
if (self.
|
|
12983
|
-
|
|
12984
|
-
|
|
12985
|
-
hORi.node.classed('tsi-selected', false);
|
|
12986
|
-
}
|
|
12987
|
-
else {
|
|
12988
|
-
self.selectedIds.push(hORi.id);
|
|
12989
|
-
hORi.node.classed('tsi-selected', true);
|
|
12990
|
-
}
|
|
12991
|
-
}
|
|
12992
|
-
self.chartOptions.onInstanceClick(hORi);
|
|
12993
|
-
}
|
|
12994
|
-
else {
|
|
12995
|
-
if (hORi.isExpanded) {
|
|
12996
|
-
hORi.collapse();
|
|
12939
|
+
.on('click keydown', async function (event) {
|
|
12940
|
+
if (Utils.isKeyDownAndNotEnter(event)) {
|
|
12941
|
+
return;
|
|
12942
|
+
}
|
|
12943
|
+
if (!isHierarchyNode) { // means it is an instance
|
|
12944
|
+
event.stopPropagation();
|
|
12945
|
+
//we want to store clicked instance and hightlight it in the hierarchy
|
|
12946
|
+
//if the instance is already selected, we want to deselect it
|
|
12947
|
+
if (self.chartOptions.onInstanceClick) {
|
|
12948
|
+
if (self.selectedIds && self.selectedIds.includes(hORi.id)) {
|
|
12949
|
+
self.selectedIds = self.selectedIds.filter(id => id !== hORi.id);
|
|
12950
|
+
hORi.node.classed('tsi-selected', false);
|
|
12997
12951
|
}
|
|
12998
12952
|
else {
|
|
12999
|
-
|
|
12953
|
+
self.selectedIds.push(hORi.id);
|
|
12954
|
+
hORi.node.classed('tsi-selected', true);
|
|
13000
12955
|
}
|
|
13001
12956
|
}
|
|
13002
|
-
|
|
12957
|
+
self.chartOptions.onInstanceClick(hORi);
|
|
12958
|
+
}
|
|
12959
|
+
else {
|
|
12960
|
+
if (hORi.isExpanded) {
|
|
12961
|
+
hORi.collapse();
|
|
12962
|
+
}
|
|
12963
|
+
else {
|
|
12964
|
+
await hORi.expand();
|
|
12965
|
+
}
|
|
12966
|
+
}
|
|
13003
12967
|
});
|
|
13004
12968
|
if (isHierarchyNode) {
|
|
13005
12969
|
hierarchyItemElem.append('span').classed('tsi-caret-icon', true).attr('style', `left: ${(hORi.level) * 18 + 20}px`);
|