@perses-dev/components 0.37.2 → 0.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/BarChart/BarChart.d.ts +16 -0
- package/dist/BarChart/BarChart.d.ts.map +1 -0
- package/dist/BarChart/BarChart.js +129 -0
- package/dist/BarChart/BarChart.js.map +1 -0
- package/dist/BarChart/index.d.ts +2 -0
- package/dist/BarChart/index.d.ts.map +1 -0
- package/dist/BarChart/index.js +15 -0
- package/dist/BarChart/index.js.map +1 -0
- package/dist/Dialog/DiscardChangesConfirmationDialog.d.ts +10 -0
- package/dist/Dialog/DiscardChangesConfirmationDialog.d.ts.map +1 -0
- package/dist/Dialog/DiscardChangesConfirmationDialog.js +47 -0
- package/dist/Dialog/DiscardChangesConfirmationDialog.js.map +1 -0
- package/dist/Dialog/index.d.ts +1 -0
- package/dist/Dialog/index.d.ts.map +1 -1
- package/dist/Dialog/index.js +1 -0
- package/dist/Dialog/index.js.map +1 -1
- package/dist/GaugeChart/GaugeChart.js +1 -1
- package/dist/GaugeChart/GaugeChart.js.map +1 -1
- package/dist/Legend/ListLegendItem.d.ts +1 -1
- package/dist/LineChart/LineChart.d.ts.map +1 -1
- package/dist/LineChart/LineChart.js +9 -9
- package/dist/LineChart/LineChart.js.map +1 -1
- package/dist/ModeSelector/ModeSelector.d.ts +9 -0
- package/dist/ModeSelector/ModeSelector.d.ts.map +1 -0
- package/dist/ModeSelector/ModeSelector.js +43 -0
- package/dist/ModeSelector/ModeSelector.js.map +1 -0
- package/dist/ModeSelector/index.d.ts +2 -0
- package/dist/ModeSelector/index.d.ts.map +1 -0
- package/dist/ModeSelector/index.js +15 -0
- package/dist/ModeSelector/index.js.map +1 -0
- package/dist/SortSelector/SortSelector.d.ts +8 -0
- package/dist/SortSelector/SortSelector.d.ts.map +1 -0
- package/dist/SortSelector/SortSelector.js +42 -0
- package/dist/SortSelector/SortSelector.js.map +1 -0
- package/dist/SortSelector/index.d.ts +2 -0
- package/dist/SortSelector/index.d.ts.map +1 -0
- package/dist/SortSelector/index.js +15 -0
- package/dist/SortSelector/index.js.map +1 -0
- package/dist/StatChart/StatChart.js +1 -1
- package/dist/StatChart/StatChart.js.map +1 -1
- package/dist/StatChart/calculateFontSize.js +3 -3
- package/dist/StatChart/calculateFontSize.js.map +1 -1
- package/dist/ThresholdsEditor/ThresholdColorPicker.js +1 -1
- package/dist/ThresholdsEditor/ThresholdColorPicker.js.map +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.d.ts.map +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.js +3 -2
- package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
- package/dist/TimeChart/TimeChart.d.ts +2 -1
- package/dist/TimeChart/TimeChart.d.ts.map +1 -1
- package/dist/TimeChart/TimeChart.js +120 -36
- package/dist/TimeChart/TimeChart.js.map +1 -1
- package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts +6 -0
- package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/LineChartTooltip.js +14 -6
- package/dist/TimeSeriesTooltip/LineChartTooltip.js.map +1 -1
- package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts +1 -0
- package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js +3 -2
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipHeader.d.ts +1 -0
- package/dist/TimeSeriesTooltip/TooltipHeader.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipHeader.js +5 -5
- package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.d.ts +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.js +97 -110
- package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
- package/dist/TimeSeriesTooltip/tooltip-model.d.ts +4 -0
- package/dist/TimeSeriesTooltip/tooltip-model.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/tooltip-model.js +6 -0
- package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
- package/dist/UnitSelector/UnitSelector.d.ts +2 -1
- package/dist/UnitSelector/UnitSelector.d.ts.map +1 -1
- package/dist/UnitSelector/UnitSelector.js +3 -2
- package/dist/UnitSelector/UnitSelector.js.map +1 -1
- package/dist/cjs/BarChart/BarChart.js +135 -0
- package/dist/cjs/BarChart/index.js +28 -0
- package/dist/cjs/Dialog/DiscardChangesConfirmationDialog.js +53 -0
- package/dist/cjs/Dialog/index.js +1 -0
- package/dist/cjs/GaugeChart/GaugeChart.js +2 -2
- package/dist/cjs/LineChart/LineChart.js +8 -8
- package/dist/cjs/ModeSelector/ModeSelector.js +49 -0
- package/dist/cjs/ModeSelector/index.js +28 -0
- package/dist/cjs/SortSelector/SortSelector.js +48 -0
- package/dist/cjs/SortSelector/index.js +28 -0
- package/dist/cjs/StatChart/StatChart.js +2 -2
- package/dist/cjs/StatChart/calculateFontSize.js +3 -3
- package/dist/cjs/ThresholdsEditor/ThresholdColorPicker.js +2 -2
- package/dist/cjs/ThresholdsEditor/ThresholdsEditor.js +3 -2
- package/dist/cjs/TimeChart/TimeChart.js +121 -32
- package/dist/cjs/TimeSeriesTooltip/LineChartTooltip.js +13 -5
- package/dist/cjs/TimeSeriesTooltip/TimeChartTooltip.js +3 -2
- package/dist/cjs/TimeSeriesTooltip/TooltipHeader.js +4 -4
- package/dist/cjs/TimeSeriesTooltip/nearby-series.js +97 -110
- package/dist/cjs/TimeSeriesTooltip/tooltip-model.js +10 -1
- package/dist/cjs/UnitSelector/UnitSelector.js +3 -2
- package/dist/cjs/context/{ChartsThemeProvider.js → ChartsProvider.js} +24 -5
- package/dist/cjs/context/index.js +30 -0
- package/dist/cjs/index.js +4 -3
- package/dist/cjs/model/graph.js +35 -3
- package/dist/cjs/test-utils/theme.js +32 -19
- package/dist/cjs/utils/axis.js +4 -4
- package/dist/cjs/utils/chart-actions.js +99 -1
- package/dist/cjs/utils/theme-gen.js +34 -6
- package/dist/context/ChartsProvider.d.ts +19 -0
- package/dist/context/ChartsProvider.d.ts.map +1 -0
- package/dist/context/{ChartsThemeProvider.js → ChartsProvider.js} +24 -6
- package/dist/context/ChartsProvider.js.map +1 -0
- package/dist/context/index.d.ts +4 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +17 -0
- package/dist/context/index.js.map +1 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/model/graph.d.ts +11 -2
- package/dist/model/graph.d.ts.map +1 -1
- package/dist/model/graph.js +25 -0
- package/dist/model/graph.js.map +1 -1
- package/dist/test-utils/theme.d.ts +2 -0
- package/dist/test-utils/theme.d.ts.map +1 -1
- package/dist/test-utils/theme.js +23 -16
- package/dist/test-utils/theme.js.map +1 -1
- package/dist/utils/axis.d.ts +3 -3
- package/dist/utils/axis.d.ts.map +1 -1
- package/dist/utils/axis.js +4 -4
- package/dist/utils/axis.js.map +1 -1
- package/dist/utils/chart-actions.d.ts +7 -0
- package/dist/utils/chart-actions.d.ts.map +1 -1
- package/dist/utils/chart-actions.js +108 -0
- package/dist/utils/chart-actions.js.map +1 -1
- package/dist/utils/theme-gen.d.ts.map +1 -1
- package/dist/utils/theme-gen.js +34 -6
- package/dist/utils/theme-gen.js.map +1 -1
- package/package.json +3 -3
- package/dist/context/ChartsThemeProvider.d.ts +0 -10
- package/dist/context/ChartsThemeProvider.d.ts.map +0 -1
- package/dist/context/ChartsThemeProvider.js.map +0 -1
|
@@ -33,23 +33,33 @@ _export(exports, {
|
|
|
33
33
|
});
|
|
34
34
|
const _core = require("@perses-dev/core");
|
|
35
35
|
const _model = require("../model");
|
|
36
|
+
const _utils = require("../utils");
|
|
36
37
|
const INCREASE_NEARBY_SERIES_MULTIPLIER = 5.5; // adjusts how many series show in tooltip (higher == more series shown)
|
|
37
38
|
const DYNAMIC_NEARBY_SERIES_MULTIPLIER = 30; // used for adjustment after series number divisor
|
|
38
39
|
const SHOW_FEWER_SERIES_LIMIT = 5;
|
|
39
40
|
function checkforNearbyTimeSeries(data, seriesMapping, pointInGrid, yBuffer, chart, unit) {
|
|
40
|
-
const currentNearbySeriesData = [];
|
|
41
41
|
var ref;
|
|
42
|
-
const
|
|
42
|
+
const currentNearbySeriesData = [];
|
|
43
43
|
var ref1;
|
|
44
|
-
const
|
|
44
|
+
const cursorX = (ref1 = pointInGrid[0]) !== null && ref1 !== void 0 ? ref1 : null;
|
|
45
|
+
var ref2;
|
|
46
|
+
const cursorY = (ref2 = pointInGrid[1]) !== null && ref2 !== void 0 ? ref2 : null;
|
|
45
47
|
if (cursorX === null || cursorY === null) return currentNearbySeriesData;
|
|
48
|
+
if (chart.dispatchAction === undefined) return currentNearbySeriesData;
|
|
46
49
|
if (!Array.isArray(data)) return currentNearbySeriesData;
|
|
47
50
|
const nearbySeriesIndexes = [];
|
|
48
51
|
const emphasizedSeriesIndexes = [];
|
|
49
52
|
const nonEmphasizedSeriesIndexes = [];
|
|
53
|
+
const emphasizedDatapoints = [];
|
|
54
|
+
const duplicateDatapoints = [];
|
|
50
55
|
const totalSeries = data.length;
|
|
51
|
-
|
|
52
|
-
|
|
56
|
+
const yValueCounts = new Map();
|
|
57
|
+
// Only need to loop through first dataset source since getCommonTimeScale ensures xAxis timestamps are consistent
|
|
58
|
+
const firstTimeSeriesValues = (ref = data[0]) === null || ref === void 0 ? void 0 : ref.values;
|
|
59
|
+
const closestTimestamp = (0, _utils.getClosestTimestamp)(firstTimeSeriesValues, cursorX);
|
|
60
|
+
if (closestTimestamp === null) {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
53
63
|
// find the timestamp with data that is closest to cursorX
|
|
54
64
|
for(let seriesIdx = 0; seriesIdx < totalSeries; seriesIdx++){
|
|
55
65
|
const currentSeries = seriesMapping[seriesIdx];
|
|
@@ -57,15 +67,6 @@ function checkforNearbyTimeSeries(data, seriesMapping, pointInGrid, yBuffer, cha
|
|
|
57
67
|
const currentDataset = totalSeries > 0 ? data[seriesIdx] : null;
|
|
58
68
|
if (currentDataset == null) break;
|
|
59
69
|
const currentDatasetValues = currentDataset.values;
|
|
60
|
-
// Determine closestTimestamp before checking whether it is equal to xValue. Consolidating
|
|
61
|
-
// with second currentDatasetValues loop below would result in duplicate nearby series
|
|
62
|
-
for (const [timestamp] of currentDatasetValues){
|
|
63
|
-
const distance = Math.abs(timestamp - cursorX);
|
|
64
|
-
if (distance < closestDistance) {
|
|
65
|
-
closestTimestamp = timestamp;
|
|
66
|
-
closestDistance = distance;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
70
|
if (currentDatasetValues === undefined || !Array.isArray(currentDatasetValues)) break;
|
|
70
71
|
const lineSeries = currentSeries;
|
|
71
72
|
const currentSeriesName = lineSeries.name ? lineSeries.name.toString() : '';
|
|
@@ -90,16 +91,35 @@ function checkforNearbyTimeSeries(data, seriesMapping, pointInGrid, yBuffer, cha
|
|
|
90
91
|
percentage: percentRangeToCheck
|
|
91
92
|
});
|
|
92
93
|
if (isClosestToCursor) {
|
|
94
|
+
// shows as bold in tooltip, customize 'emphasis' options in getTimeSeries util
|
|
93
95
|
emphasizedSeriesIndexes.push(seriesIdx);
|
|
96
|
+
var ref3;
|
|
97
|
+
// Used to determine which datapoint to apply select styles to.
|
|
98
|
+
// Accounts for cases where lines may be rendered directly on top of eachother.
|
|
99
|
+
const duplicateValuesCount = (ref3 = yValueCounts.get(yValue)) !== null && ref3 !== void 0 ? ref3 : 0;
|
|
100
|
+
yValueCounts.set(yValue, duplicateValuesCount + 1);
|
|
101
|
+
if (duplicateValuesCount > 0) {
|
|
102
|
+
duplicateDatapoints.push({
|
|
103
|
+
seriesIndex: seriesIdx,
|
|
104
|
+
dataIndex: datumIdx,
|
|
105
|
+
seriesName: currentSeriesName,
|
|
106
|
+
yValue: yValue
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
// keep track of all bold datapoints in tooltip so that 'select' state only applied to topmost
|
|
110
|
+
emphasizedDatapoints.push({
|
|
111
|
+
seriesIndex: seriesIdx,
|
|
112
|
+
dataIndex: datumIdx,
|
|
113
|
+
seriesName: currentSeriesName,
|
|
114
|
+
yValue: yValue
|
|
115
|
+
});
|
|
94
116
|
} else {
|
|
95
117
|
nonEmphasizedSeriesIndexes.push(seriesIdx);
|
|
96
118
|
// ensure series far away from cursor are not highlighted
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
});
|
|
102
|
-
}
|
|
119
|
+
chart.dispatchAction({
|
|
120
|
+
type: 'downplay',
|
|
121
|
+
seriesIndex: seriesIdx
|
|
122
|
+
});
|
|
103
123
|
}
|
|
104
124
|
const formattedY = (0, _core.formatValue)(yValue, unit);
|
|
105
125
|
currentNearbySeriesData.push({
|
|
@@ -120,32 +140,7 @@ function checkforNearbyTimeSeries(data, seriesMapping, pointInGrid, yBuffer, cha
|
|
|
120
140
|
}
|
|
121
141
|
}
|
|
122
142
|
}
|
|
123
|
-
|
|
124
|
-
// Clears emphasis state of all lines that are not emphasized.
|
|
125
|
-
// Emphasized is a subset of just the nearby series that are closest to cursor.
|
|
126
|
-
chart.dispatchAction({
|
|
127
|
-
type: 'downplay',
|
|
128
|
-
seriesIndex: nonEmphasizedSeriesIndexes
|
|
129
|
-
});
|
|
130
|
-
// https://echarts.apache.org/en/api.html#action.highlight
|
|
131
|
-
if (emphasizedSeriesIndexes.length > 0) {
|
|
132
|
-
// Fadeout opacity of all series not closest to cursor.
|
|
133
|
-
chart.dispatchAction({
|
|
134
|
-
type: 'highlight',
|
|
135
|
-
seriesIndex: emphasizedSeriesIndexes,
|
|
136
|
-
notBlur: false,
|
|
137
|
-
escapeConnect: true
|
|
138
|
-
});
|
|
139
|
-
} else {
|
|
140
|
-
// When no emphasized series with bold text, notBlur allows opacity fadeout to not trigger.
|
|
141
|
-
chart.dispatchAction({
|
|
142
|
-
type: 'highlight',
|
|
143
|
-
seriesIndex: nearbySeriesIndexes,
|
|
144
|
-
notBlur: true,
|
|
145
|
-
escapeConnect: true
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
}
|
|
143
|
+
(0, _utils.batchDispatchNearbySeriesActions)(chart, nearbySeriesIndexes, emphasizedSeriesIndexes, nonEmphasizedSeriesIndexes, emphasizedDatapoints, duplicateDatapoints);
|
|
149
144
|
return currentNearbySeriesData;
|
|
150
145
|
}
|
|
151
146
|
function legacyCheckforNearbySeries(data, pointInGrid, yBuffer, chart, unit) {
|
|
@@ -164,55 +159,54 @@ function legacyCheckforNearbySeries(data, pointInGrid, yBuffer, chart, unit) {
|
|
|
164
159
|
if (Array.isArray(data.xAxis) && Array.isArray(data.timeSeries)) {
|
|
165
160
|
for(let seriesIdx = 0; seriesIdx < totalSeries; seriesIdx++){
|
|
166
161
|
const currentSeries = data.timeSeries[seriesIdx];
|
|
162
|
+
if (currentSeries === undefined) break;
|
|
167
163
|
if (currentNearbySeriesData.length >= _model.OPTIMIZED_MODE_SERIES_LIMIT) break;
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if (yValue !==
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
});
|
|
198
|
-
}
|
|
164
|
+
const currentSeriesName = currentSeries.name ? currentSeries.name.toString() : '';
|
|
165
|
+
var _color;
|
|
166
|
+
const markerColor = (_color = currentSeries.color) !== null && _color !== void 0 ? _color : '#000';
|
|
167
|
+
if (Array.isArray(currentSeries.data)) {
|
|
168
|
+
for(let datumIdx = 0; datumIdx < currentSeries.data.length; datumIdx++){
|
|
169
|
+
var _datumIdx;
|
|
170
|
+
const xValue = (_datumIdx = data.xAxis[datumIdx]) !== null && _datumIdx !== void 0 ? _datumIdx : 0;
|
|
171
|
+
const yValue = currentSeries.data[datumIdx];
|
|
172
|
+
// ensure null values not displayed in tooltip
|
|
173
|
+
if (yValue !== undefined && yValue !== null && cursorX === datumIdx) {
|
|
174
|
+
if (yValue !== '-' && cursorY <= yValue + yBuffer && cursorY >= yValue - yBuffer) {
|
|
175
|
+
// show fewer bold series in tooltip when many total series
|
|
176
|
+
const minPercentRange = totalSeries > SHOW_FEWER_SERIES_LIMIT ? 2 : 5;
|
|
177
|
+
const percentRangeToCheck = Math.max(minPercentRange, 100 / totalSeries);
|
|
178
|
+
const isClosestToCursor = isWithinPercentageRange({
|
|
179
|
+
valueToCheck: cursorY,
|
|
180
|
+
baseValue: yValue,
|
|
181
|
+
percentage: percentRangeToCheck
|
|
182
|
+
});
|
|
183
|
+
if (isClosestToCursor) {
|
|
184
|
+
emphasizedSeriesIndexes.push(seriesIdx);
|
|
185
|
+
} else {
|
|
186
|
+
nonEmphasizedSeriesIndexes.push(seriesIdx);
|
|
187
|
+
// ensure series not close to cursor are not highlighted
|
|
188
|
+
if ((chart === null || chart === void 0 ? void 0 : chart.dispatchAction) !== undefined) {
|
|
189
|
+
chart.dispatchAction({
|
|
190
|
+
type: 'downplay',
|
|
191
|
+
seriesIndex: seriesIdx
|
|
192
|
+
});
|
|
199
193
|
}
|
|
200
|
-
// determine whether to convert timestamp to ms, see: https://stackoverflow.com/a/23982005/17575201
|
|
201
|
-
const xValueMilliSeconds = xValue > 99999999999 ? xValue : xValue * 1000;
|
|
202
|
-
const formattedY = (0, _core.formatValue)(yValue, unit);
|
|
203
|
-
currentNearbySeriesData.push({
|
|
204
|
-
seriesIdx: seriesIdx,
|
|
205
|
-
datumIdx: datumIdx,
|
|
206
|
-
seriesName: currentSeriesName,
|
|
207
|
-
date: xValueMilliSeconds,
|
|
208
|
-
x: xValue,
|
|
209
|
-
y: yValue,
|
|
210
|
-
formattedY: formattedY,
|
|
211
|
-
markerColor: markerColor.toString(),
|
|
212
|
-
isClosestToCursor
|
|
213
|
-
});
|
|
214
|
-
nearbySeriesIndexes.push(seriesIdx);
|
|
215
194
|
}
|
|
195
|
+
// determine whether to convert timestamp to ms, see: https://stackoverflow.com/a/23982005/17575201
|
|
196
|
+
const xValueMilliSeconds = xValue > 99999999999 ? xValue : xValue * 1000;
|
|
197
|
+
const formattedY = (0, _core.formatValue)(yValue, unit);
|
|
198
|
+
currentNearbySeriesData.push({
|
|
199
|
+
seriesIdx: seriesIdx,
|
|
200
|
+
datumIdx: datumIdx,
|
|
201
|
+
seriesName: currentSeriesName,
|
|
202
|
+
date: xValueMilliSeconds,
|
|
203
|
+
x: xValue,
|
|
204
|
+
y: yValue,
|
|
205
|
+
formattedY: formattedY,
|
|
206
|
+
markerColor: markerColor.toString(),
|
|
207
|
+
isClosestToCursor
|
|
208
|
+
});
|
|
209
|
+
nearbySeriesIndexes.push(seriesIdx);
|
|
216
210
|
}
|
|
217
211
|
}
|
|
218
212
|
}
|
|
@@ -270,24 +264,17 @@ function getNearbySeriesData({ mousePos , pinnedPos , data , seriesMapping , cha
|
|
|
270
264
|
}
|
|
271
265
|
if (cursorTargetMatchesChart === false) return [];
|
|
272
266
|
if (chart['_model'] === undefined || data === null) return [];
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
(
|
|
284
|
-
(_y = mousePos.plotCanvas.y) !== null && _y !== void 0 ? _y : 0
|
|
285
|
-
];
|
|
286
|
-
if (chart.containPixel('grid', pointInPixel)) {
|
|
287
|
-
const pointInGrid = chart.convertFromPixel('grid', pointInPixel);
|
|
288
|
-
if (pointInGrid[0] !== undefined && pointInGrid[1] !== undefined) {
|
|
289
|
-
return checkforNearbyTimeSeries(data, seriesMapping, pointInGrid, yBuffer, chart, unit);
|
|
290
|
-
}
|
|
267
|
+
const pointInGrid = (0, _utils.getPointInGrid)(mousePos.plotCanvas.x, mousePos.plotCanvas.y, chart);
|
|
268
|
+
if (pointInGrid !== null) {
|
|
269
|
+
const chartModel = chart['_model'];
|
|
270
|
+
const yInterval = chartModel.getComponent('yAxis').axis.scale._interval;
|
|
271
|
+
const totalSeries = data.length;
|
|
272
|
+
const yBuffer = getYBuffer({
|
|
273
|
+
yInterval,
|
|
274
|
+
totalSeries,
|
|
275
|
+
showAllSeries
|
|
276
|
+
});
|
|
277
|
+
return checkforNearbyTimeSeries(data, seriesMapping, pointInGrid, yBuffer, chart, unit);
|
|
291
278
|
}
|
|
292
279
|
return [];
|
|
293
280
|
}
|
|
@@ -34,7 +34,10 @@ _export(exports, {
|
|
|
34
34
|
TOOLTIP_DATE_FORMAT: ()=>TOOLTIP_DATE_FORMAT,
|
|
35
35
|
defaultCursorData: ()=>defaultCursorData,
|
|
36
36
|
emptyTooltipData: ()=>emptyTooltipData,
|
|
37
|
-
useMousePosition: ()=>useMousePosition
|
|
37
|
+
useMousePosition: ()=>useMousePosition,
|
|
38
|
+
DEFAULT_TOOLTIP_CONFIG: ()=>DEFAULT_TOOLTIP_CONFIG,
|
|
39
|
+
PIN_TOOLTIP_HELP_TEXT: ()=>PIN_TOOLTIP_HELP_TEXT,
|
|
40
|
+
UNPIN_TOOLTIP_HELP_TEXT: ()=>UNPIN_TOOLTIP_HELP_TEXT
|
|
38
41
|
});
|
|
39
42
|
const _react = require("react");
|
|
40
43
|
const TOOLTIP_MIN_WIDTH = 375;
|
|
@@ -108,3 +111,9 @@ const useMousePosition = ()=>{
|
|
|
108
111
|
}, []);
|
|
109
112
|
return coords;
|
|
110
113
|
};
|
|
114
|
+
const DEFAULT_TOOLTIP_CONFIG = {
|
|
115
|
+
wrapLabels: true,
|
|
116
|
+
enablePinning: true
|
|
117
|
+
};
|
|
118
|
+
const PIN_TOOLTIP_HELP_TEXT = 'Click chart to pin';
|
|
119
|
+
const UNPIN_TOOLTIP_HELP_TEXT = 'Click chart to unpin';
|
|
@@ -64,7 +64,7 @@ const DECIMAL_PLACES_OPTIONS = [
|
|
|
64
64
|
function getOptionByDecimalPlaces(decimal_places) {
|
|
65
65
|
return DECIMAL_PLACES_OPTIONS.find((o)=>o.decimal_places === decimal_places);
|
|
66
66
|
}
|
|
67
|
-
function UnitSelector({ value , onChange }) {
|
|
67
|
+
function UnitSelector({ value , onChange , disabled =false }) {
|
|
68
68
|
const hasDecimalPlaces = (0, _core.isUnitWithDecimalPlaces)(value);
|
|
69
69
|
const hasAbbreviate = (0, _core.isUnitWithAbbreviate)(value);
|
|
70
70
|
const handleKindChange = (_, newValue)=>{
|
|
@@ -109,7 +109,8 @@ function UnitSelector({ value , onChange }) {
|
|
|
109
109
|
options: KIND_OPTIONS,
|
|
110
110
|
groupBy: (option)=>option.group,
|
|
111
111
|
onChange: handleKindChange,
|
|
112
|
-
disableClearable: true
|
|
112
|
+
disableClearable: true,
|
|
113
|
+
disabled: disabled
|
|
113
114
|
})
|
|
114
115
|
}),
|
|
115
116
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_optionsEditorLayout.OptionsEditorControl, {
|
|
@@ -21,8 +21,9 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
-
|
|
24
|
+
ChartsProvider: ()=>ChartsProvider,
|
|
25
25
|
ChartsThemeContext: ()=>ChartsThemeContext,
|
|
26
|
+
useChartsContext: ()=>useChartsContext,
|
|
26
27
|
useChartsTheme: ()=>useChartsTheme
|
|
27
28
|
});
|
|
28
29
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -66,18 +67,36 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
66
67
|
}
|
|
67
68
|
return newObj;
|
|
68
69
|
}
|
|
69
|
-
function
|
|
70
|
-
const { children , chartsTheme } = props;
|
|
70
|
+
function ChartsProvider(props) {
|
|
71
|
+
const { children , chartsTheme , enablePinning =false } = props;
|
|
72
|
+
const [lastTooltipPinnedCoords, setLastTooltipPinnedCoords] = (0, _react.useState)(null);
|
|
73
|
+
const ctx = (0, _react.useMemo)(()=>{
|
|
74
|
+
return {
|
|
75
|
+
chartsTheme,
|
|
76
|
+
enablePinning,
|
|
77
|
+
lastTooltipPinnedCoords,
|
|
78
|
+
setLastTooltipPinnedCoords
|
|
79
|
+
};
|
|
80
|
+
}, [
|
|
81
|
+
chartsTheme,
|
|
82
|
+
enablePinning,
|
|
83
|
+
lastTooltipPinnedCoords,
|
|
84
|
+
setLastTooltipPinnedCoords
|
|
85
|
+
]);
|
|
71
86
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(ChartsThemeContext.Provider, {
|
|
72
|
-
value:
|
|
87
|
+
value: ctx,
|
|
73
88
|
children: children
|
|
74
89
|
});
|
|
75
90
|
}
|
|
76
91
|
const ChartsThemeContext = /*#__PURE__*/ (0, _react.createContext)(undefined);
|
|
77
|
-
function
|
|
92
|
+
function useChartsContext() {
|
|
78
93
|
const ctx = (0, _react.useContext)(ChartsThemeContext);
|
|
79
94
|
if (ctx === undefined) {
|
|
80
95
|
throw new Error('No ChartsThemeContext found. Did you forget a Provider?');
|
|
81
96
|
}
|
|
82
97
|
return ctx;
|
|
83
98
|
}
|
|
99
|
+
function useChartsTheme() {
|
|
100
|
+
const ctx = useChartsContext();
|
|
101
|
+
return ctx.chartsTheme;
|
|
102
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
_exportStar(require("./ChartsProvider"), exports);
|
|
18
|
+
_exportStar(require("./SnackbarProvider"), exports);
|
|
19
|
+
_exportStar(require("./TimeZoneProvider"), exports);
|
|
20
|
+
function _exportStar(from, to) {
|
|
21
|
+
Object.keys(from).forEach(function(k) {
|
|
22
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function() {
|
|
25
|
+
return from[k];
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
return from;
|
|
30
|
+
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
+
_exportStar(require("./BarChart"), exports);
|
|
17
18
|
_exportStar(require("./ColorPicker"), exports);
|
|
18
19
|
_exportStar(require("./ContentWithLegend"), exports);
|
|
19
20
|
_exportStar(require("./DateTimeRangePicker"), exports);
|
|
@@ -28,8 +29,10 @@ _exportStar(require("./InfoTooltip"), exports);
|
|
|
28
29
|
_exportStar(require("./JSONEditor"), exports);
|
|
29
30
|
_exportStar(require("./Legend"), exports);
|
|
30
31
|
_exportStar(require("./LineChart"), exports);
|
|
32
|
+
_exportStar(require("./ModeSelector"), exports);
|
|
31
33
|
_exportStar(require("./OptionsEditorLayout"), exports);
|
|
32
34
|
_exportStar(require("./SettingsAutocomplete"), exports);
|
|
35
|
+
_exportStar(require("./SortSelector"), exports);
|
|
33
36
|
_exportStar(require("./StatChart"), exports);
|
|
34
37
|
_exportStar(require("./Table"), exports);
|
|
35
38
|
_exportStar(require("./ThresholdsEditor"), exports);
|
|
@@ -37,9 +40,7 @@ _exportStar(require("./TimeChart"), exports);
|
|
|
37
40
|
_exportStar(require("./TimeSeriesTooltip"), exports);
|
|
38
41
|
_exportStar(require("./UnitSelector"), exports);
|
|
39
42
|
_exportStar(require("./YAxisLabel"), exports);
|
|
40
|
-
_exportStar(require("./context
|
|
41
|
-
_exportStar(require("./context/TimeZoneProvider"), exports);
|
|
42
|
-
_exportStar(require("./context/SnackbarProvider"), exports);
|
|
43
|
+
_exportStar(require("./context"), exports);
|
|
43
44
|
_exportStar(require("./utils"), exports);
|
|
44
45
|
_exportStar(require("./model"), exports);
|
|
45
46
|
_exportStar(require("./test-utils"), exports);
|
package/dist/cjs/model/graph.js
CHANGED
|
@@ -14,8 +14,40 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
+
OPTIMIZED_MODE_SERIES_LIMIT: ()=>OPTIMIZED_MODE_SERIES_LIMIT,
|
|
25
|
+
PINNED_CROSSHAIR_SERIES_NAME: ()=>PINNED_CROSSHAIR_SERIES_NAME,
|
|
26
|
+
DEFAULT_PINNED_CROSSHAIR: ()=>DEFAULT_PINNED_CROSSHAIR
|
|
20
27
|
});
|
|
21
28
|
const OPTIMIZED_MODE_SERIES_LIMIT = 1000;
|
|
29
|
+
const PINNED_CROSSHAIR_SERIES_NAME = 'Pinned Crosshair';
|
|
30
|
+
const DEFAULT_PINNED_CROSSHAIR = {
|
|
31
|
+
name: PINNED_CROSSHAIR_SERIES_NAME,
|
|
32
|
+
type: 'line',
|
|
33
|
+
// https://echarts.apache.org/en/option.html#series-line.markLine
|
|
34
|
+
markLine: {
|
|
35
|
+
data: [],
|
|
36
|
+
lineStyle: {
|
|
37
|
+
type: 'dashed',
|
|
38
|
+
width: 2
|
|
39
|
+
},
|
|
40
|
+
emphasis: {
|
|
41
|
+
lineStyle: {
|
|
42
|
+
width: 2,
|
|
43
|
+
opacity: 1
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
blur: {
|
|
47
|
+
lineStyle: {
|
|
48
|
+
width: 2,
|
|
49
|
+
opacity: 1
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
@@ -14,28 +14,41 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
+
testChartsTheme: ()=>testChartsTheme,
|
|
25
|
+
mockChartsContext: ()=>mockChartsContext
|
|
20
26
|
});
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
const _material = require("@mui/material");
|
|
28
|
+
const _utils = require("../utils");
|
|
29
|
+
// app specific echarts option overrides
|
|
30
|
+
const TEST_ECHARTS_THEME_OVERRIDES = {
|
|
31
|
+
textStyle: {
|
|
32
|
+
fontFamily: 'Lato'
|
|
27
33
|
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
categoryAxis: {
|
|
35
|
+
splitLine: {
|
|
36
|
+
show: false
|
|
31
37
|
}
|
|
32
38
|
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
timeAxis: {
|
|
40
|
+
splitLine: {
|
|
41
|
+
show: false
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
bar: {
|
|
45
|
+
barCategoryGap: 2
|
|
40
46
|
}
|
|
41
47
|
};
|
|
48
|
+
const testChartsTheme = (0, _utils.generateChartsTheme)((0, _material.createTheme)({}), TEST_ECHARTS_THEME_OVERRIDES);
|
|
49
|
+
const mockChartsContext = {
|
|
50
|
+
chartsTheme: testChartsTheme,
|
|
51
|
+
enablePinning: false,
|
|
52
|
+
lastTooltipPinnedCoords: null,
|
|
53
|
+
setLastTooltipPinnedCoords: ()=>null
|
|
54
|
+
};
|
package/dist/cjs/utils/axis.js
CHANGED
|
@@ -21,7 +21,7 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
-
|
|
24
|
+
getFormattedAxis: ()=>getFormattedAxis,
|
|
25
25
|
getDateRange: ()=>getDateRange
|
|
26
26
|
});
|
|
27
27
|
const _merge = /*#__PURE__*/ _interopRequireDefault(require("lodash/merge"));
|
|
@@ -31,9 +31,9 @@ function _interopRequireDefault(obj) {
|
|
|
31
31
|
default: obj
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function getFormattedAxis(axis, unit) {
|
|
35
35
|
// TODO: support alternate yAxis that shows on right side
|
|
36
|
-
const
|
|
36
|
+
const AXIS_DEFAULT = {
|
|
37
37
|
type: 'value',
|
|
38
38
|
boundaryGap: [
|
|
39
39
|
0,
|
|
@@ -46,7 +46,7 @@ function getYAxes(yAxis, unit) {
|
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
return [
|
|
49
|
-
(0, _merge.default)(
|
|
49
|
+
(0, _merge.default)(AXIS_DEFAULT, axis)
|
|
50
50
|
];
|
|
51
51
|
}
|
|
52
52
|
function getDateRange(data) {
|