@perses-dev/components 0.0.0-snapshot-tooltip-highlight-c995fc8 → 0.0.0-snapshot-saving-defaults-refinements-1b25cec
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/ContentWithLegend/ContentWithLegend.d.ts +11 -0
- package/dist/ContentWithLegend/ContentWithLegend.d.ts.map +1 -0
- package/dist/ContentWithLegend/ContentWithLegend.js +65 -0
- package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -0
- package/dist/ContentWithLegend/index.d.ts +2 -0
- package/dist/ContentWithLegend/index.d.ts.map +1 -0
- package/dist/ContentWithLegend/index.js +15 -0
- package/dist/ContentWithLegend/index.js.map +1 -0
- package/dist/ContentWithLegend/model/content-with-legend-model.d.ts +68 -0
- package/dist/ContentWithLegend/model/content-with-legend-model.d.ts.map +1 -0
- package/dist/ContentWithLegend/model/content-with-legend-model.js +90 -0
- package/dist/ContentWithLegend/model/content-with-legend-model.js.map +1 -0
- package/dist/EChart/EChart.d.ts.map +1 -1
- package/dist/EChart/EChart.js +10 -8
- package/dist/EChart/EChart.js.map +1 -1
- package/dist/Legend/CompactLegend.d.ts +6 -4
- package/dist/Legend/CompactLegend.d.ts.map +1 -1
- package/dist/Legend/CompactLegend.js +4 -1
- package/dist/Legend/CompactLegend.js.map +1 -1
- package/dist/Legend/Legend.d.ts +11 -9
- package/dist/Legend/Legend.d.ts.map +1 -1
- package/dist/Legend/Legend.js +70 -21
- package/dist/Legend/Legend.js.map +1 -1
- package/dist/Legend/ListLegend.d.ts +5 -8
- package/dist/Legend/ListLegend.d.ts.map +1 -1
- package/dist/Legend/ListLegend.js +17 -103
- package/dist/Legend/ListLegend.js.map +1 -1
- package/dist/Legend/ListLegendItem.d.ts +8 -8
- package/dist/Legend/ListLegendItem.d.ts.map +1 -1
- package/dist/Legend/ListLegendItem.js +9 -12
- package/dist/Legend/ListLegendItem.js.map +1 -1
- package/dist/Legend/TableLegend.d.ts +12 -0
- package/dist/Legend/TableLegend.d.ts.map +1 -0
- package/dist/Legend/TableLegend.js +61 -0
- package/dist/Legend/TableLegend.js.map +1 -0
- package/dist/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -1
- package/dist/LegendOptionsEditor/LegendOptionsEditor.js +35 -3
- package/dist/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
- package/dist/LineChart/LineChart.d.ts +2 -1
- package/dist/LineChart/LineChart.d.ts.map +1 -1
- package/dist/LineChart/LineChart.js +79 -32
- package/dist/LineChart/LineChart.js.map +1 -1
- package/dist/StatChart/StatChart.d.ts.map +1 -1
- package/dist/StatChart/StatChart.js +13 -2
- package/dist/StatChart/StatChart.js.map +1 -1
- package/dist/Table/InnerTable.d.ts +9 -0
- package/dist/Table/InnerTable.d.ts.map +1 -0
- package/dist/Table/InnerTable.js +38 -0
- package/dist/Table/InnerTable.js.map +1 -0
- package/dist/Table/Table.d.ts +10 -0
- package/dist/Table/Table.d.ts.map +1 -0
- package/dist/Table/Table.js +101 -0
- package/dist/Table/Table.js.map +1 -0
- package/dist/Table/TableBody.d.ts +6 -0
- package/dist/Table/TableBody.d.ts.map +1 -0
- package/dist/Table/TableBody.js +23 -0
- package/dist/Table/TableBody.js.map +1 -0
- package/dist/Table/TableCell.d.ts +18 -0
- package/dist/Table/TableCell.d.ts.map +1 -0
- package/dist/Table/TableCell.js +91 -0
- package/dist/Table/TableCell.js.map +1 -0
- package/dist/Table/TableCheckbox.d.ts +9 -0
- package/dist/Table/TableCheckbox.d.ts.map +1 -0
- package/dist/Table/TableCheckbox.js +49 -0
- package/dist/Table/TableCheckbox.js.map +1 -0
- package/dist/Table/TableHead.d.ts +6 -0
- package/dist/Table/TableHead.d.ts.map +1 -0
- package/dist/Table/TableHead.js +23 -0
- package/dist/Table/TableHead.js.map +1 -0
- package/dist/Table/TableRow.d.ts +9 -0
- package/dist/Table/TableRow.d.ts.map +1 -0
- package/dist/Table/TableRow.js +29 -0
- package/dist/Table/TableRow.js.map +1 -0
- package/dist/Table/VirtualizedTable.d.ts +11 -0
- package/dist/Table/VirtualizedTable.d.ts.map +1 -0
- package/dist/Table/VirtualizedTable.js +152 -0
- package/dist/Table/VirtualizedTable.js.map +1 -0
- package/dist/Table/VirtualizedTableContainer.d.ts +6 -0
- package/dist/Table/VirtualizedTableContainer.d.ts.map +1 -0
- package/dist/Table/VirtualizedTableContainer.js +24 -0
- package/dist/Table/VirtualizedTableContainer.js.map +1 -0
- package/dist/Table/hooks/useTableKeyboardNav.d.ts +32 -0
- package/dist/Table/hooks/useTableKeyboardNav.d.ts.map +1 -0
- package/dist/Table/hooks/useTableKeyboardNav.js +98 -0
- package/dist/Table/hooks/useTableKeyboardNav.js.map +1 -0
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts +29 -0
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts.map +1 -0
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js +89 -0
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js.map +1 -0
- package/dist/Table/index.d.ts +4 -0
- package/dist/Table/index.d.ts.map +1 -0
- package/dist/Table/index.js +16 -0
- package/dist/Table/index.js.map +1 -0
- package/dist/Table/model/table-model.d.ts +83 -0
- package/dist/Table/model/table-model.d.ts.map +1 -0
- package/dist/Table/model/table-model.js +73 -0
- package/dist/Table/model/table-model.js.map +1 -0
- package/dist/TimeSeriesTooltip/SeriesInfo.d.ts +1 -0
- package/dist/TimeSeriesTooltip/SeriesInfo.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.js +11 -9
- package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts +5 -4
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js +50 -22
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.d.ts +3 -3
- package/dist/TimeSeriesTooltip/TooltipContent.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.js +28 -67
- package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipHeader.d.ts +12 -0
- package/dist/TimeSeriesTooltip/TooltipHeader.d.ts.map +1 -0
- package/dist/TimeSeriesTooltip/TooltipHeader.js +160 -0
- package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -0
- package/dist/TimeSeriesTooltip/index.d.ts +2 -1
- package/dist/TimeSeriesTooltip/index.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/index.js +2 -1
- package/dist/TimeSeriesTooltip/index.js.map +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.d.ts +46 -0
- package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -0
- package/dist/TimeSeriesTooltip/nearby-series.js +200 -0
- package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -0
- package/dist/TimeSeriesTooltip/tooltip-model.d.ts +17 -13
- package/dist/TimeSeriesTooltip/tooltip-model.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/tooltip-model.js +11 -2
- package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
- package/dist/TimeSeriesTooltip/utils.d.ts +1 -1
- package/dist/TimeSeriesTooltip/utils.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/utils.js +9 -17
- package/dist/TimeSeriesTooltip/utils.js.map +1 -1
- package/dist/UnitSelector/UnitSelector.d.ts.map +1 -1
- package/dist/UnitSelector/UnitSelector.js +2 -1
- package/dist/UnitSelector/UnitSelector.js.map +1 -1
- package/dist/cjs/ContentWithLegend/ContentWithLegend.js +70 -0
- package/dist/cjs/ContentWithLegend/index.js +28 -0
- package/dist/cjs/ContentWithLegend/model/content-with-legend-model.js +100 -0
- package/dist/cjs/EChart/EChart.js +10 -8
- package/dist/cjs/Legend/CompactLegend.js +4 -1
- package/dist/cjs/Legend/Legend.js +70 -21
- package/dist/cjs/Legend/ListLegend.js +17 -103
- package/dist/cjs/Legend/ListLegendItem.js +8 -11
- package/dist/cjs/Legend/TableLegend.js +67 -0
- package/dist/cjs/LegendOptionsEditor/LegendOptionsEditor.js +34 -2
- package/dist/cjs/LineChart/LineChart.js +79 -32
- package/dist/cjs/StatChart/StatChart.js +13 -2
- package/dist/cjs/Table/InnerTable.js +44 -0
- package/dist/cjs/Table/Table.js +102 -0
- package/dist/cjs/Table/TableBody.js +29 -0
- package/dist/cjs/Table/TableCell.js +97 -0
- package/dist/cjs/Table/TableCheckbox.js +55 -0
- package/dist/cjs/Table/TableHead.js +29 -0
- package/dist/cjs/Table/TableRow.js +35 -0
- package/dist/cjs/Table/VirtualizedTable.js +155 -0
- package/dist/cjs/Table/VirtualizedTableContainer.js +30 -0
- package/dist/cjs/Table/hooks/useTableKeyboardNav.js +99 -0
- package/dist/cjs/Table/hooks/useVirtualizedTableKeyboardNav.js +93 -0
- package/dist/cjs/Table/index.js +33 -0
- package/dist/cjs/Table/model/table-model.js +80 -0
- package/dist/cjs/TimeSeriesTooltip/SeriesInfo.js +10 -8
- package/dist/cjs/TimeSeriesTooltip/TimeSeriesTooltip.js +54 -21
- package/dist/cjs/TimeSeriesTooltip/TooltipContent.js +26 -65
- package/dist/cjs/TimeSeriesTooltip/TooltipHeader.js +171 -0
- package/dist/cjs/TimeSeriesTooltip/index.js +2 -1
- package/dist/cjs/TimeSeriesTooltip/nearby-series.js +206 -0
- package/dist/cjs/TimeSeriesTooltip/tooltip-model.js +17 -3
- package/dist/cjs/TimeSeriesTooltip/utils.js +8 -16
- package/dist/cjs/UnitSelector/UnitSelector.js +2 -1
- package/dist/cjs/context/SnackbarProvider.js +66 -0
- package/dist/cjs/index.js +3 -0
- package/dist/cjs/model/legend.js +37 -2
- package/dist/cjs/model/units/bytes.js +9 -7
- package/dist/cjs/model/units/decimal.js +2 -2
- package/dist/cjs/model/units/percent.js +2 -2
- package/dist/cjs/model/units/time.js +2 -2
- package/dist/cjs/theme/palette/grey.js +6 -2
- package/dist/context/SnackbarProvider.d.ts +23 -0
- package/dist/context/SnackbarProvider.d.ts.map +1 -0
- package/dist/context/SnackbarProvider.js +59 -0
- package/dist/context/SnackbarProvider.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/model/legend.d.ts +19 -5
- package/dist/model/legend.d.ts.map +1 -1
- package/dist/model/legend.js +31 -1
- package/dist/model/legend.js.map +1 -1
- package/dist/model/units/bytes.d.ts.map +1 -1
- package/dist/model/units/bytes.js +9 -7
- package/dist/model/units/bytes.js.map +1 -1
- package/dist/model/units/decimal.js +2 -2
- package/dist/model/units/decimal.js.map +1 -1
- package/dist/model/units/percent.js +2 -2
- package/dist/model/units/percent.js.map +1 -1
- package/dist/model/units/time.js +2 -2
- package/dist/model/units/time.js.map +1 -1
- package/dist/theme/palette/grey.d.ts.map +1 -1
- package/dist/theme/palette/grey.js +6 -2
- package/dist/theme/palette/grey.js.map +1 -1
- package/package.json +6 -6
- package/dist/TimeSeriesTooltip/focused-series.d.ts +0 -28
- package/dist/TimeSeriesTooltip/focused-series.d.ts.map +0 -1
- package/dist/TimeSeriesTooltip/focused-series.js +0 -140
- package/dist/TimeSeriesTooltip/focused-series.js.map +0 -1
- package/dist/cjs/TimeSeriesTooltip/focused-series.js +0 -148
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
// Copyright 2023 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
import { formatValue } from '../model';
|
|
14
|
-
import { TOOLTIP_MAX_ITEMS } from './tooltip-model';
|
|
15
|
-
// increase multipliers to show more series in tooltip
|
|
16
|
-
export const DEFAULT_NEARBY_SERIES_RANGE_MULTIPLIER = 5.5; // adjusts how many focused series show in tooltip
|
|
17
|
-
export const NARROW_NEARBY_SERIES_RANGE_MULTIPLIER = 2; // used to reduce number of focused series for heavy queries
|
|
18
|
-
export const SHOW_MORE_NEARBY_SERIES_LIMIT = 5;
|
|
19
|
-
/**
|
|
20
|
-
* Returns formatted series data for the points that are close to the user's cursor
|
|
21
|
-
* Adjust yBuffer to increase or decrease number of series shown
|
|
22
|
-
*/ export function getNearbySeries(data, pointInGrid, yBuffer, chart, unit) {
|
|
23
|
-
const currentFocusedData = [];
|
|
24
|
-
var ref;
|
|
25
|
-
const focusedX = (ref = pointInGrid[0]) !== null && ref !== void 0 ? ref : null;
|
|
26
|
-
var ref1;
|
|
27
|
-
const focusedY = (ref1 = pointInGrid[1]) !== null && ref1 !== void 0 ? ref1 : null;
|
|
28
|
-
if (focusedX === null || focusedY === null) {
|
|
29
|
-
return currentFocusedData;
|
|
30
|
-
}
|
|
31
|
-
if (Array.isArray(data.xAxis) && Array.isArray(data.timeSeries)) {
|
|
32
|
-
for(let seriesIdx = 0; seriesIdx < data.timeSeries.length; seriesIdx++){
|
|
33
|
-
const currentSeries = data.timeSeries[seriesIdx];
|
|
34
|
-
if (currentFocusedData.length >= TOOLTIP_MAX_ITEMS) break;
|
|
35
|
-
if (currentSeries !== undefined) {
|
|
36
|
-
const currentSeriesName = currentSeries.name ? currentSeries.name.toString() : '';
|
|
37
|
-
var _color;
|
|
38
|
-
const markerColor = (_color = currentSeries.color) !== null && _color !== void 0 ? _color : '#000';
|
|
39
|
-
if (Array.isArray(currentSeries.data)) {
|
|
40
|
-
for(let datumIdx = 0; datumIdx < currentSeries.data.length; datumIdx++){
|
|
41
|
-
var _datumIdx;
|
|
42
|
-
const xValue = (_datumIdx = data.xAxis[datumIdx]) !== null && _datumIdx !== void 0 ? _datumIdx : 0;
|
|
43
|
-
const yValue = currentSeries.data[datumIdx];
|
|
44
|
-
// ensure null values not displayed in tooltip
|
|
45
|
-
if (yValue !== undefined && yValue !== null && focusedX === datumIdx) {
|
|
46
|
-
if (yValue !== '-' && focusedY <= yValue + yBuffer && focusedY >= yValue - yBuffer) {
|
|
47
|
-
// determine whether to convert timestamp to ms, see: https://stackoverflow.com/a/23982005/17575201
|
|
48
|
-
const xValueMilliSeconds = xValue > 99999999999 ? xValue : xValue * 1000;
|
|
49
|
-
const formattedY = formatValue(yValue, unit);
|
|
50
|
-
// trigger emphasis state of nearby series so tooltip matches highlighted lines
|
|
51
|
-
// https://echarts.apache.org/en/api.html#action.highlight
|
|
52
|
-
if ((chart === null || chart === void 0 ? void 0 : chart.dispatchAction) !== undefined) {
|
|
53
|
-
chart.dispatchAction({
|
|
54
|
-
type: 'highlight',
|
|
55
|
-
seriesIndex: seriesIdx
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
currentFocusedData.push({
|
|
59
|
-
seriesIdx: seriesIdx,
|
|
60
|
-
datumIdx: datumIdx,
|
|
61
|
-
seriesName: currentSeriesName,
|
|
62
|
-
dateMs: xValueMilliSeconds,
|
|
63
|
-
x: xValue,
|
|
64
|
-
y: yValue,
|
|
65
|
-
formattedY: formattedY,
|
|
66
|
-
markerColor: markerColor.toString()
|
|
67
|
-
});
|
|
68
|
-
} else {
|
|
69
|
-
// clear emphasis state of lines that are not focused
|
|
70
|
-
if ((chart === null || chart === void 0 ? void 0 : chart.dispatchAction) !== undefined) {
|
|
71
|
-
chart.dispatchAction({
|
|
72
|
-
type: 'downplay',
|
|
73
|
-
seriesIndex: seriesIdx
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return currentFocusedData;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Uses mouse position to determine whether user is hovering over a chart canvas
|
|
87
|
-
* If yes, convert from pixel values to logical cartesian coordinates and return all focused series
|
|
88
|
-
*/ export function getFocusedSeriesData(mousePos, chartData, pinnedPos, chart, unit) {
|
|
89
|
-
if (chart === undefined || mousePos === null) return [];
|
|
90
|
-
// prevents multiple tooltips showing from adjacent charts
|
|
91
|
-
let cursorTargetMatchesChart = false;
|
|
92
|
-
if (mousePos.target !== null) {
|
|
93
|
-
const currentParent = mousePos.target.parentElement;
|
|
94
|
-
if (currentParent !== null) {
|
|
95
|
-
const currentGrandparent = currentParent.parentElement;
|
|
96
|
-
if (currentGrandparent !== null) {
|
|
97
|
-
const chartDom = chart.getDom();
|
|
98
|
-
if (chartDom === currentGrandparent) {
|
|
99
|
-
cursorTargetMatchesChart = true;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
// allows moving cursor inside tooltip
|
|
105
|
-
if (pinnedPos !== null) {
|
|
106
|
-
mousePos = pinnedPos;
|
|
107
|
-
cursorTargetMatchesChart = true;
|
|
108
|
-
}
|
|
109
|
-
if (cursorTargetMatchesChart === false) return [];
|
|
110
|
-
if (chart['_model'] === undefined) return [];
|
|
111
|
-
const chartModel = chart['_model'];
|
|
112
|
-
const yAxisInterval = chartModel.getComponent('yAxis').axis.scale._interval;
|
|
113
|
-
const seriesNum = chartData.timeSeries.length;
|
|
114
|
-
// tooltip trigger area gets smaller with more series, increase yAxisInterval multiplier to expand nearby series range
|
|
115
|
-
const yBuffer = seriesNum > SHOW_MORE_NEARBY_SERIES_LIMIT ? yAxisInterval * NARROW_NEARBY_SERIES_RANGE_MULTIPLIER : yAxisInterval * DEFAULT_NEARBY_SERIES_RANGE_MULTIPLIER;
|
|
116
|
-
var _x, _y;
|
|
117
|
-
const pointInPixel = [
|
|
118
|
-
(_x = mousePos.plotCanvas.x) !== null && _x !== void 0 ? _x : 0,
|
|
119
|
-
(_y = mousePos.plotCanvas.y) !== null && _y !== void 0 ? _y : 0
|
|
120
|
-
];
|
|
121
|
-
if (chart.containPixel('grid', pointInPixel)) {
|
|
122
|
-
const pointInGrid = chart.convertFromPixel('grid', pointInPixel);
|
|
123
|
-
if (pointInGrid[0] !== undefined && pointInGrid[1] !== undefined) {
|
|
124
|
-
return getNearbySeries(chartData, pointInGrid, yBuffer, chart, unit);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
// clear all highlighted series when cursor exits canvas
|
|
128
|
-
// https://echarts.apache.org/en/api.html#action.downplay
|
|
129
|
-
for(let i = 0; i < seriesNum; i++){
|
|
130
|
-
if ((chart === null || chart === void 0 ? void 0 : chart.dispatchAction) !== undefined) {
|
|
131
|
-
chart.dispatchAction({
|
|
132
|
-
type: 'downplay',
|
|
133
|
-
seriesIndex: i
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return [];
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
//# sourceMappingURL=focused-series.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/TimeSeriesTooltip/focused-series.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ECharts as EChartsInstance } from 'echarts/core';\nimport { formatValue, UnitOptions, EChartsDataFormat } from '../model';\nimport { CursorData, TOOLTIP_MAX_ITEMS } from './tooltip-model';\n\n// increase multipliers to show more series in tooltip\nexport const DEFAULT_NEARBY_SERIES_RANGE_MULTIPLIER = 5.5; // adjusts how many focused series show in tooltip\nexport const NARROW_NEARBY_SERIES_RANGE_MULTIPLIER = 2; // used to reduce number of focused series for heavy queries\nexport const SHOW_MORE_NEARBY_SERIES_LIMIT = 5;\n\nexport interface FocusedSeriesInfo {\n seriesIdx: number | null;\n datumIdx: number | null;\n seriesName: string;\n dateMs: number;\n markerColor: string;\n x: number;\n y: number;\n formattedY: string;\n}\n\nexport type FocusedSeriesArray = FocusedSeriesInfo[];\n\n/**\n * Returns formatted series data for the points that are close to the user's cursor\n * Adjust yBuffer to increase or decrease number of series shown\n */\nexport function getNearbySeries(\n data: EChartsDataFormat,\n pointInGrid: number[],\n yBuffer: number,\n chart?: EChartsInstance,\n unit?: UnitOptions\n): FocusedSeriesArray {\n const currentFocusedData: FocusedSeriesArray = [];\n const focusedX: number | null = pointInGrid[0] ?? null;\n const focusedY: number | null = pointInGrid[1] ?? null;\n\n if (focusedX === null || focusedY === null) {\n return currentFocusedData;\n }\n\n if (Array.isArray(data.xAxis) && Array.isArray(data.timeSeries)) {\n for (let seriesIdx = 0; seriesIdx < data.timeSeries.length; seriesIdx++) {\n const currentSeries = data.timeSeries[seriesIdx];\n if (currentFocusedData.length >= TOOLTIP_MAX_ITEMS) break;\n if (currentSeries !== undefined) {\n const currentSeriesName = currentSeries.name ? currentSeries.name.toString() : '';\n const markerColor = currentSeries.color ?? '#000';\n if (Array.isArray(currentSeries.data)) {\n for (let datumIdx = 0; datumIdx < currentSeries.data.length; datumIdx++) {\n const xValue = data.xAxis[datumIdx] ?? 0;\n const yValue = currentSeries.data[datumIdx];\n // ensure null values not displayed in tooltip\n if (yValue !== undefined && yValue !== null && focusedX === datumIdx) {\n if (yValue !== '-' && focusedY <= yValue + yBuffer && focusedY >= yValue - yBuffer) {\n // determine whether to convert timestamp to ms, see: https://stackoverflow.com/a/23982005/17575201\n const xValueMilliSeconds = xValue > 99999999999 ? xValue : xValue * 1000;\n const formattedY = formatValue(yValue, unit);\n // trigger emphasis state of nearby series so tooltip matches highlighted lines\n // https://echarts.apache.org/en/api.html#action.highlight\n if (chart?.dispatchAction !== undefined) {\n chart.dispatchAction({\n type: 'highlight',\n seriesIndex: seriesIdx,\n });\n }\n currentFocusedData.push({\n seriesIdx: seriesIdx,\n datumIdx: datumIdx,\n seriesName: currentSeriesName,\n dateMs: xValueMilliSeconds,\n x: xValue,\n y: yValue,\n formattedY: formattedY,\n markerColor: markerColor.toString(),\n });\n } else {\n // clear emphasis state of lines that are not focused\n if (chart?.dispatchAction !== undefined) {\n chart.dispatchAction({\n type: 'downplay',\n seriesIndex: seriesIdx,\n });\n }\n }\n }\n }\n }\n }\n }\n }\n return currentFocusedData;\n}\n\n/**\n * Uses mouse position to determine whether user is hovering over a chart canvas\n * If yes, convert from pixel values to logical cartesian coordinates and return all focused series\n */\nexport function getFocusedSeriesData(\n mousePos: CursorData['coords'],\n chartData: EChartsDataFormat,\n pinnedPos: CursorData['coords'],\n chart?: EChartsInstance,\n unit?: UnitOptions\n) {\n if (chart === undefined || mousePos === null) return [];\n\n // prevents multiple tooltips showing from adjacent charts\n let cursorTargetMatchesChart = false;\n if (mousePos.target !== null) {\n const currentParent = (<HTMLElement>mousePos.target).parentElement;\n if (currentParent !== null) {\n const currentGrandparent = currentParent.parentElement;\n if (currentGrandparent !== null) {\n const chartDom = chart.getDom();\n if (chartDom === currentGrandparent) {\n cursorTargetMatchesChart = true;\n }\n }\n }\n }\n\n // allows moving cursor inside tooltip\n if (pinnedPos !== null) {\n mousePos = pinnedPos;\n cursorTargetMatchesChart = true;\n }\n\n if (cursorTargetMatchesChart === false) return [];\n\n if (chart['_model'] === undefined) return [];\n const chartModel = chart['_model'];\n const yAxisInterval = chartModel.getComponent('yAxis').axis.scale._interval;\n\n const seriesNum = chartData.timeSeries.length;\n\n // tooltip trigger area gets smaller with more series, increase yAxisInterval multiplier to expand nearby series range\n const yBuffer =\n seriesNum > SHOW_MORE_NEARBY_SERIES_LIMIT\n ? yAxisInterval * NARROW_NEARBY_SERIES_RANGE_MULTIPLIER\n : yAxisInterval * DEFAULT_NEARBY_SERIES_RANGE_MULTIPLIER;\n\n const pointInPixel = [mousePos.plotCanvas.x ?? 0, mousePos.plotCanvas.y ?? 0];\n if (chart.containPixel('grid', pointInPixel)) {\n const pointInGrid = chart.convertFromPixel('grid', pointInPixel);\n if (pointInGrid[0] !== undefined && pointInGrid[1] !== undefined) {\n return getNearbySeries(chartData, pointInGrid, yBuffer, chart, unit);\n }\n }\n\n // clear all highlighted series when cursor exits canvas\n // https://echarts.apache.org/en/api.html#action.downplay\n for (let i = 0; i < seriesNum; i++) {\n if (chart?.dispatchAction !== undefined) {\n chart.dispatchAction({\n type: 'downplay',\n seriesIndex: i,\n });\n }\n }\n return [];\n}\n"],"names":["formatValue","TOOLTIP_MAX_ITEMS","DEFAULT_NEARBY_SERIES_RANGE_MULTIPLIER","NARROW_NEARBY_SERIES_RANGE_MULTIPLIER","SHOW_MORE_NEARBY_SERIES_LIMIT","getNearbySeries","data","pointInGrid","yBuffer","chart","unit","currentFocusedData","focusedX","focusedY","Array","isArray","xAxis","timeSeries","seriesIdx","length","currentSeries","undefined","currentSeriesName","name","toString","markerColor","color","datumIdx","xValue","yValue","xValueMilliSeconds","formattedY","dispatchAction","type","seriesIndex","push","seriesName","dateMs","x","y","getFocusedSeriesData","mousePos","chartData","pinnedPos","cursorTargetMatchesChart","target","currentParent","parentElement","currentGrandparent","chartDom","getDom","chartModel","yAxisInterval","getComponent","axis","scale","_interval","seriesNum","pointInPixel","plotCanvas","containPixel","convertFromPixel","i"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,WAAW,QAAwC,UA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WAAW,GAAGE,KAAK,CAACoD,gBAAgB,CAAC,MAAM,EAAEH,YAAY,CAAC,AAAC;QACjE,IAAInD,WAAW,CAAC,CAAC,CAAC,KAAKc,SAAS,IAAId,WAAW,CAAC,CAAC,CAAC,KAAKc,SAAS,EAAE;YAChE,OAAOhB,eAAe,CAACqC,SAAS,EAAEnC,WAAW,EAAEC,OAAO,EAAEC,KAAK,EAAEC,IAAI,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;IAED,wDAAwD;IACxD,yDAAyD;IACzD,IAAK,IAAIoD,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGL,SAAS,EAAEK,CAAC,EAAE,CAAE;QAClC,IAAIrD,CAAAA,KAAK,aAALA,KAAK,WAAgB,GAArBA,KAAAA,CAAqB,GAArBA,KAAK,CAAEuB,cAAc,CAAA,KAAKX,SAAS,EAAE;YACvCZ,KAAK,CAACuB,cAAc,CAAC;gBACnBC,IAAI,EAAE,UAAU;gBAChBC,WAAW,EAAE4B,CAAC;aACf,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
// Copyright 2023 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
|
17
|
-
function _export(target, all) {
|
|
18
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: all[name]
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
_export(exports, {
|
|
24
|
-
DEFAULT_NEARBY_SERIES_RANGE_MULTIPLIER: ()=>DEFAULT_NEARBY_SERIES_RANGE_MULTIPLIER,
|
|
25
|
-
NARROW_NEARBY_SERIES_RANGE_MULTIPLIER: ()=>NARROW_NEARBY_SERIES_RANGE_MULTIPLIER,
|
|
26
|
-
SHOW_MORE_NEARBY_SERIES_LIMIT: ()=>SHOW_MORE_NEARBY_SERIES_LIMIT,
|
|
27
|
-
getNearbySeries: ()=>getNearbySeries,
|
|
28
|
-
getFocusedSeriesData: ()=>getFocusedSeriesData
|
|
29
|
-
});
|
|
30
|
-
const _model = require("../model");
|
|
31
|
-
const _tooltipModel = require("./tooltip-model");
|
|
32
|
-
const DEFAULT_NEARBY_SERIES_RANGE_MULTIPLIER = 5.5; // adjusts how many focused series show in tooltip
|
|
33
|
-
const NARROW_NEARBY_SERIES_RANGE_MULTIPLIER = 2; // used to reduce number of focused series for heavy queries
|
|
34
|
-
const SHOW_MORE_NEARBY_SERIES_LIMIT = 5;
|
|
35
|
-
function getNearbySeries(data, pointInGrid, yBuffer, chart, unit) {
|
|
36
|
-
const currentFocusedData = [];
|
|
37
|
-
var ref;
|
|
38
|
-
const focusedX = (ref = pointInGrid[0]) !== null && ref !== void 0 ? ref : null;
|
|
39
|
-
var ref1;
|
|
40
|
-
const focusedY = (ref1 = pointInGrid[1]) !== null && ref1 !== void 0 ? ref1 : null;
|
|
41
|
-
if (focusedX === null || focusedY === null) {
|
|
42
|
-
return currentFocusedData;
|
|
43
|
-
}
|
|
44
|
-
if (Array.isArray(data.xAxis) && Array.isArray(data.timeSeries)) {
|
|
45
|
-
for(let seriesIdx = 0; seriesIdx < data.timeSeries.length; seriesIdx++){
|
|
46
|
-
const currentSeries = data.timeSeries[seriesIdx];
|
|
47
|
-
if (currentFocusedData.length >= _tooltipModel.TOOLTIP_MAX_ITEMS) break;
|
|
48
|
-
if (currentSeries !== undefined) {
|
|
49
|
-
const currentSeriesName = currentSeries.name ? currentSeries.name.toString() : '';
|
|
50
|
-
var _color;
|
|
51
|
-
const markerColor = (_color = currentSeries.color) !== null && _color !== void 0 ? _color : '#000';
|
|
52
|
-
if (Array.isArray(currentSeries.data)) {
|
|
53
|
-
for(let datumIdx = 0; datumIdx < currentSeries.data.length; datumIdx++){
|
|
54
|
-
var _datumIdx;
|
|
55
|
-
const xValue = (_datumIdx = data.xAxis[datumIdx]) !== null && _datumIdx !== void 0 ? _datumIdx : 0;
|
|
56
|
-
const yValue = currentSeries.data[datumIdx];
|
|
57
|
-
// ensure null values not displayed in tooltip
|
|
58
|
-
if (yValue !== undefined && yValue !== null && focusedX === datumIdx) {
|
|
59
|
-
if (yValue !== '-' && focusedY <= yValue + yBuffer && focusedY >= yValue - yBuffer) {
|
|
60
|
-
// determine whether to convert timestamp to ms, see: https://stackoverflow.com/a/23982005/17575201
|
|
61
|
-
const xValueMilliSeconds = xValue > 99999999999 ? xValue : xValue * 1000;
|
|
62
|
-
const formattedY = (0, _model.formatValue)(yValue, unit);
|
|
63
|
-
// trigger emphasis state of nearby series so tooltip matches highlighted lines
|
|
64
|
-
// https://echarts.apache.org/en/api.html#action.highlight
|
|
65
|
-
if ((chart === null || chart === void 0 ? void 0 : chart.dispatchAction) !== undefined) {
|
|
66
|
-
chart.dispatchAction({
|
|
67
|
-
type: 'highlight',
|
|
68
|
-
seriesIndex: seriesIdx
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
currentFocusedData.push({
|
|
72
|
-
seriesIdx: seriesIdx,
|
|
73
|
-
datumIdx: datumIdx,
|
|
74
|
-
seriesName: currentSeriesName,
|
|
75
|
-
dateMs: xValueMilliSeconds,
|
|
76
|
-
x: xValue,
|
|
77
|
-
y: yValue,
|
|
78
|
-
formattedY: formattedY,
|
|
79
|
-
markerColor: markerColor.toString()
|
|
80
|
-
});
|
|
81
|
-
} else {
|
|
82
|
-
// clear emphasis state of lines that are not focused
|
|
83
|
-
if ((chart === null || chart === void 0 ? void 0 : chart.dispatchAction) !== undefined) {
|
|
84
|
-
chart.dispatchAction({
|
|
85
|
-
type: 'downplay',
|
|
86
|
-
seriesIndex: seriesIdx
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return currentFocusedData;
|
|
97
|
-
}
|
|
98
|
-
function getFocusedSeriesData(mousePos, chartData, pinnedPos, chart, unit) {
|
|
99
|
-
if (chart === undefined || mousePos === null) return [];
|
|
100
|
-
// prevents multiple tooltips showing from adjacent charts
|
|
101
|
-
let cursorTargetMatchesChart = false;
|
|
102
|
-
if (mousePos.target !== null) {
|
|
103
|
-
const currentParent = mousePos.target.parentElement;
|
|
104
|
-
if (currentParent !== null) {
|
|
105
|
-
const currentGrandparent = currentParent.parentElement;
|
|
106
|
-
if (currentGrandparent !== null) {
|
|
107
|
-
const chartDom = chart.getDom();
|
|
108
|
-
if (chartDom === currentGrandparent) {
|
|
109
|
-
cursorTargetMatchesChart = true;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
// allows moving cursor inside tooltip
|
|
115
|
-
if (pinnedPos !== null) {
|
|
116
|
-
mousePos = pinnedPos;
|
|
117
|
-
cursorTargetMatchesChart = true;
|
|
118
|
-
}
|
|
119
|
-
if (cursorTargetMatchesChart === false) return [];
|
|
120
|
-
if (chart['_model'] === undefined) return [];
|
|
121
|
-
const chartModel = chart['_model'];
|
|
122
|
-
const yAxisInterval = chartModel.getComponent('yAxis').axis.scale._interval;
|
|
123
|
-
const seriesNum = chartData.timeSeries.length;
|
|
124
|
-
// tooltip trigger area gets smaller with more series, increase yAxisInterval multiplier to expand nearby series range
|
|
125
|
-
const yBuffer = seriesNum > SHOW_MORE_NEARBY_SERIES_LIMIT ? yAxisInterval * NARROW_NEARBY_SERIES_RANGE_MULTIPLIER : yAxisInterval * DEFAULT_NEARBY_SERIES_RANGE_MULTIPLIER;
|
|
126
|
-
var _x, _y;
|
|
127
|
-
const pointInPixel = [
|
|
128
|
-
(_x = mousePos.plotCanvas.x) !== null && _x !== void 0 ? _x : 0,
|
|
129
|
-
(_y = mousePos.plotCanvas.y) !== null && _y !== void 0 ? _y : 0
|
|
130
|
-
];
|
|
131
|
-
if (chart.containPixel('grid', pointInPixel)) {
|
|
132
|
-
const pointInGrid = chart.convertFromPixel('grid', pointInPixel);
|
|
133
|
-
if (pointInGrid[0] !== undefined && pointInGrid[1] !== undefined) {
|
|
134
|
-
return getNearbySeries(chartData, pointInGrid, yBuffer, chart, unit);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
// clear all highlighted series when cursor exits canvas
|
|
138
|
-
// https://echarts.apache.org/en/api.html#action.downplay
|
|
139
|
-
for(let i = 0; i < seriesNum; i++){
|
|
140
|
-
if ((chart === null || chart === void 0 ? void 0 : chart.dispatchAction) !== undefined) {
|
|
141
|
-
chart.dispatchAction({
|
|
142
|
-
type: 'downplay',
|
|
143
|
-
seriesIndex: i
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
return [];
|
|
148
|
-
}
|