@perses-dev/components 0.36.1 → 0.37.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.
Files changed (111) hide show
  1. package/dist/FontSizeSelector/FontSizeSelector.d.ts +8 -0
  2. package/dist/FontSizeSelector/FontSizeSelector.d.ts.map +1 -0
  3. package/dist/FontSizeSelector/FontSizeSelector.js +124 -0
  4. package/dist/FontSizeSelector/FontSizeSelector.js.map +1 -0
  5. package/dist/FontSizeSelector/index.d.ts +2 -0
  6. package/dist/FontSizeSelector/index.d.ts.map +1 -0
  7. package/dist/FontSizeSelector/index.js +15 -0
  8. package/dist/FontSizeSelector/index.js.map +1 -0
  9. package/dist/LineChart/LineChart.d.ts +5 -25
  10. package/dist/LineChart/LineChart.d.ts.map +1 -1
  11. package/dist/LineChart/LineChart.js +6 -6
  12. package/dist/LineChart/LineChart.js.map +1 -1
  13. package/dist/LineChart/index.d.ts +0 -1
  14. package/dist/LineChart/index.d.ts.map +1 -1
  15. package/dist/LineChart/index.js +0 -1
  16. package/dist/LineChart/index.js.map +1 -1
  17. package/dist/StatChart/StatChart.d.ts +2 -0
  18. package/dist/StatChart/StatChart.d.ts.map +1 -1
  19. package/dist/StatChart/StatChart.js +7 -5
  20. package/dist/StatChart/StatChart.js.map +1 -1
  21. package/dist/StatChart/calculateFontSize.d.ts +3 -1
  22. package/dist/StatChart/calculateFontSize.d.ts.map +1 -1
  23. package/dist/StatChart/calculateFontSize.js +5 -1
  24. package/dist/StatChart/calculateFontSize.js.map +1 -1
  25. package/dist/TimeChart/TimeChart.d.ts +23 -0
  26. package/dist/TimeChart/TimeChart.d.ts.map +1 -0
  27. package/dist/TimeChart/TimeChart.js +313 -0
  28. package/dist/TimeChart/TimeChart.js.map +1 -0
  29. package/dist/TimeChart/index.d.ts +2 -0
  30. package/dist/TimeChart/index.d.ts.map +1 -0
  31. package/dist/TimeChart/index.js +15 -0
  32. package/dist/TimeChart/index.js.map +1 -0
  33. package/dist/TimeSeriesTooltip/{TimeSeriesTooltip.d.ts → LineChartTooltip.d.ts} +2 -2
  34. package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts.map +1 -0
  35. package/dist/TimeSeriesTooltip/{TimeSeriesTooltip.js → LineChartTooltip.js} +4 -4
  36. package/dist/TimeSeriesTooltip/LineChartTooltip.js.map +1 -0
  37. package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts +16 -0
  38. package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts.map +1 -0
  39. package/dist/TimeSeriesTooltip/TimeChartTooltip.js +76 -0
  40. package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -0
  41. package/dist/TimeSeriesTooltip/TooltipHeader.d.ts.map +1 -1
  42. package/dist/TimeSeriesTooltip/TooltipHeader.js +3 -4
  43. package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -1
  44. package/dist/TimeSeriesTooltip/index.d.ts +2 -1
  45. package/dist/TimeSeriesTooltip/index.d.ts.map +1 -1
  46. package/dist/TimeSeriesTooltip/index.js +2 -1
  47. package/dist/TimeSeriesTooltip/index.js.map +1 -1
  48. package/dist/TimeSeriesTooltip/nearby-series.d.ts +23 -5
  49. package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -1
  50. package/dist/TimeSeriesTooltip/nearby-series.js +166 -4
  51. package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
  52. package/dist/TimeSeriesTooltip/tooltip-model.d.ts +4 -0
  53. package/dist/TimeSeriesTooltip/tooltip-model.d.ts.map +1 -1
  54. package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
  55. package/dist/TimeSeriesTooltip/utils.d.ts +25 -0
  56. package/dist/TimeSeriesTooltip/utils.d.ts.map +1 -1
  57. package/dist/TimeSeriesTooltip/utils.js +29 -1
  58. package/dist/TimeSeriesTooltip/utils.js.map +1 -1
  59. package/dist/cjs/FontSizeSelector/FontSizeSelector.js +130 -0
  60. package/dist/cjs/FontSizeSelector/index.js +28 -0
  61. package/dist/cjs/LineChart/LineChart.js +5 -44
  62. package/dist/cjs/LineChart/index.js +0 -1
  63. package/dist/cjs/StatChart/StatChart.js +7 -5
  64. package/dist/cjs/StatChart/calculateFontSize.js +5 -1
  65. package/dist/cjs/TimeChart/TimeChart.js +319 -0
  66. package/dist/cjs/TimeChart/index.js +28 -0
  67. package/dist/cjs/TimeSeriesTooltip/{TimeSeriesTooltip.js → LineChartTooltip.js} +4 -4
  68. package/dist/cjs/TimeSeriesTooltip/TimeChartTooltip.js +87 -0
  69. package/dist/cjs/TimeSeriesTooltip/TooltipHeader.js +3 -4
  70. package/dist/cjs/TimeSeriesTooltip/index.js +2 -1
  71. package/dist/cjs/TimeSeriesTooltip/nearby-series.js +162 -4
  72. package/dist/cjs/TimeSeriesTooltip/utils.js +35 -3
  73. package/dist/cjs/index.js +2 -0
  74. package/dist/cjs/utils/axis.js +58 -0
  75. package/dist/cjs/{LineChart/utils.js → utils/chart-actions.js} +0 -54
  76. package/dist/cjs/utils/format.js +47 -1
  77. package/dist/cjs/utils/index.js +3 -1
  78. package/dist/cjs/utils/theme-gen.js +37 -0
  79. package/dist/index.d.ts +2 -0
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +2 -0
  82. package/dist/index.js.map +1 -1
  83. package/dist/model/graph.d.ts +19 -2
  84. package/dist/model/graph.d.ts.map +1 -1
  85. package/dist/model/graph.js.map +1 -1
  86. package/dist/utils/axis.d.ts +14 -0
  87. package/dist/utils/axis.d.ts.map +1 -0
  88. package/dist/utils/axis.js +45 -0
  89. package/dist/utils/axis.js.map +1 -0
  90. package/dist/utils/chart-actions.d.ts +18 -0
  91. package/dist/utils/chart-actions.d.ts.map +1 -0
  92. package/dist/utils/chart-actions.js +52 -0
  93. package/dist/utils/chart-actions.js.map +1 -0
  94. package/dist/utils/format.d.ts +6 -0
  95. package/dist/utils/format.d.ts.map +1 -1
  96. package/dist/utils/format.js +47 -0
  97. package/dist/utils/format.js.map +1 -1
  98. package/dist/utils/index.d.ts +3 -1
  99. package/dist/utils/index.d.ts.map +1 -1
  100. package/dist/utils/index.js +3 -1
  101. package/dist/utils/index.js.map +1 -1
  102. package/dist/utils/theme-gen.d.ts.map +1 -1
  103. package/dist/utils/theme-gen.js +37 -0
  104. package/dist/utils/theme-gen.js.map +1 -1
  105. package/package.json +3 -3
  106. package/dist/LineChart/utils.d.ts +0 -31
  107. package/dist/LineChart/utils.d.ts.map +0 -1
  108. package/dist/LineChart/utils.js +0 -103
  109. package/dist/LineChart/utils.js.map +0 -1
  110. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts.map +0 -1
  111. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js.map +0 -1
@@ -24,8 +24,10 @@ _export(exports, {
24
24
  INCREASE_NEARBY_SERIES_MULTIPLIER: ()=>INCREASE_NEARBY_SERIES_MULTIPLIER,
25
25
  DYNAMIC_NEARBY_SERIES_MULTIPLIER: ()=>DYNAMIC_NEARBY_SERIES_MULTIPLIER,
26
26
  SHOW_FEWER_SERIES_LIMIT: ()=>SHOW_FEWER_SERIES_LIMIT,
27
- checkforNearbySeries: ()=>checkforNearbySeries,
27
+ checkforNearbyTimeSeries: ()=>checkforNearbyTimeSeries,
28
+ legacyCheckforNearbySeries: ()=>legacyCheckforNearbySeries,
28
29
  getNearbySeriesData: ()=>getNearbySeriesData,
30
+ legacyGetNearbySeriesData: ()=>legacyGetNearbySeriesData,
29
31
  isWithinPercentageRange: ()=>isWithinPercentageRange,
30
32
  getYBuffer: ()=>getYBuffer
31
33
  });
@@ -34,7 +36,119 @@ const _model = require("../model");
34
36
  const INCREASE_NEARBY_SERIES_MULTIPLIER = 5.5; // adjusts how many series show in tooltip (higher == more series shown)
35
37
  const DYNAMIC_NEARBY_SERIES_MULTIPLIER = 30; // used for adjustment after series number divisor
36
38
  const SHOW_FEWER_SERIES_LIMIT = 5;
37
- function checkforNearbySeries(data, pointInGrid, yBuffer, chart, unit) {
39
+ function checkforNearbyTimeSeries(data, seriesMapping, pointInGrid, yBuffer, chart, unit) {
40
+ const currentNearbySeriesData = [];
41
+ var ref;
42
+ const cursorX = (ref = pointInGrid[0]) !== null && ref !== void 0 ? ref : null;
43
+ var ref1;
44
+ const cursorY = (ref1 = pointInGrid[1]) !== null && ref1 !== void 0 ? ref1 : null;
45
+ if (cursorX === null || cursorY === null) return currentNearbySeriesData;
46
+ if (!Array.isArray(data)) return currentNearbySeriesData;
47
+ const nearbySeriesIndexes = [];
48
+ const emphasizedSeriesIndexes = [];
49
+ const nonEmphasizedSeriesIndexes = [];
50
+ const totalSeries = data.length;
51
+ let closestTimestamp = null;
52
+ let closestDistance = Infinity;
53
+ // find the timestamp with data that is closest to cursorX
54
+ for(let seriesIdx = 0; seriesIdx < totalSeries; seriesIdx++){
55
+ const currentSeries = seriesMapping[seriesIdx];
56
+ if (currentSeries === undefined) break;
57
+ const currentDataset = totalSeries > 0 ? data[seriesIdx] : null;
58
+ if (currentDataset == null) break;
59
+ 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
+ if (currentDatasetValues === undefined || !Array.isArray(currentDatasetValues)) break;
70
+ const lineSeries = currentSeries;
71
+ const currentSeriesName = lineSeries.name ? lineSeries.name.toString() : '';
72
+ var _color;
73
+ const markerColor = (_color = lineSeries.color) !== null && _color !== void 0 ? _color : '#000';
74
+ if (Array.isArray(data)) {
75
+ for(let datumIdx = 0; datumIdx < currentDatasetValues.length; datumIdx++){
76
+ const nearbyTimeSeries = currentDatasetValues[datumIdx];
77
+ if (nearbyTimeSeries === undefined || !Array.isArray(nearbyTimeSeries)) break;
78
+ const xValue = nearbyTimeSeries[0];
79
+ const yValue = nearbyTimeSeries[1];
80
+ // TODO: ensure null values not displayed in tooltip
81
+ if (yValue !== undefined && yValue !== null) {
82
+ if (closestTimestamp === xValue) {
83
+ if (cursorY <= yValue + yBuffer && cursorY >= yValue - yBuffer) {
84
+ // show fewer bold series in tooltip when many total series
85
+ const minPercentRange = totalSeries > SHOW_FEWER_SERIES_LIMIT ? 2 : 5;
86
+ const percentRangeToCheck = Math.max(minPercentRange, 100 / totalSeries);
87
+ const isClosestToCursor = isWithinPercentageRange({
88
+ valueToCheck: cursorY,
89
+ baseValue: yValue,
90
+ percentage: percentRangeToCheck
91
+ });
92
+ if (isClosestToCursor) {
93
+ emphasizedSeriesIndexes.push(seriesIdx);
94
+ } else {
95
+ nonEmphasizedSeriesIndexes.push(seriesIdx);
96
+ // ensure series far away from cursor are not highlighted
97
+ if ((chart === null || chart === void 0 ? void 0 : chart.dispatchAction) !== undefined) {
98
+ chart.dispatchAction({
99
+ type: 'downplay',
100
+ seriesIndex: seriesIdx
101
+ });
102
+ }
103
+ }
104
+ const formattedY = (0, _core.formatValue)(yValue, unit);
105
+ currentNearbySeriesData.push({
106
+ seriesIdx: seriesIdx,
107
+ datumIdx: datumIdx,
108
+ seriesName: currentSeriesName,
109
+ date: closestTimestamp,
110
+ x: xValue,
111
+ y: yValue,
112
+ formattedY: formattedY,
113
+ markerColor: markerColor.toString(),
114
+ isClosestToCursor
115
+ });
116
+ nearbySeriesIndexes.push(seriesIdx);
117
+ }
118
+ }
119
+ }
120
+ }
121
+ }
122
+ }
123
+ if ((chart === null || chart === void 0 ? void 0 : chart.dispatchAction) !== undefined) {
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
+ }
149
+ return currentNearbySeriesData;
150
+ }
151
+ function legacyCheckforNearbySeries(data, pointInGrid, yBuffer, chart, unit) {
38
152
  const currentNearbySeriesData = [];
39
153
  var ref;
40
154
  const cursorX = (ref = pointInGrid[0]) !== null && ref !== void 0 ? ref : null;
@@ -133,7 +247,51 @@ function checkforNearbySeries(data, pointInGrid, yBuffer, chart, unit) {
133
247
  }
134
248
  return currentNearbySeriesData;
135
249
  }
136
- function getNearbySeriesData({ mousePos , pinnedPos , chartData , chart , unit , showAllSeries =false }) {
250
+ function getNearbySeriesData({ mousePos , pinnedPos , data , seriesMapping , chart , unit , showAllSeries =false }) {
251
+ if (chart === undefined || mousePos === null) return [];
252
+ // prevents multiple tooltips showing from adjacent charts unless tooltip is pinned
253
+ let cursorTargetMatchesChart = false;
254
+ if (mousePos.target !== null) {
255
+ const currentParent = mousePos.target.parentElement;
256
+ if (currentParent !== null) {
257
+ const currentGrandparent = currentParent.parentElement;
258
+ if (currentGrandparent !== null) {
259
+ const chartDom = chart.getDom();
260
+ if (chartDom === currentGrandparent) {
261
+ cursorTargetMatchesChart = true;
262
+ }
263
+ }
264
+ }
265
+ }
266
+ // allows moving cursor inside tooltip without it fading away
267
+ if (pinnedPos !== null) {
268
+ mousePos = pinnedPos;
269
+ cursorTargetMatchesChart = true;
270
+ }
271
+ if (cursorTargetMatchesChart === false) return [];
272
+ if (chart['_model'] === undefined || data === null) return [];
273
+ const chartModel = chart['_model'];
274
+ const yInterval = chartModel.getComponent('yAxis').axis.scale._interval;
275
+ const totalSeries = data.length;
276
+ const yBuffer = getYBuffer({
277
+ yInterval,
278
+ totalSeries,
279
+ showAllSeries
280
+ });
281
+ var _x, _y;
282
+ const pointInPixel = [
283
+ (_x = mousePos.plotCanvas.x) !== null && _x !== void 0 ? _x : 0,
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
+ }
291
+ }
292
+ return [];
293
+ }
294
+ function legacyGetNearbySeriesData({ mousePos , pinnedPos , chartData , chart , unit , showAllSeries =false }) {
137
295
  if (chart === undefined || mousePos === null) return [];
138
296
  // prevents multiple tooltips showing from adjacent charts unless tooltip is pinned
139
297
  let cursorTargetMatchesChart = false;
@@ -172,7 +330,7 @@ function getNearbySeriesData({ mousePos , pinnedPos , chartData , chart , unit ,
172
330
  if (chart.containPixel('grid', pointInPixel)) {
173
331
  const pointInGrid = chart.convertFromPixel('grid', pointInPixel);
174
332
  if (pointInGrid[0] !== undefined && pointInGrid[1] !== undefined) {
175
- return checkforNearbySeries(chartData, pointInGrid, yBuffer, chart, unit);
333
+ return legacyCheckforNearbySeries(chartData, pointInGrid, yBuffer, chart, unit);
176
334
  }
177
335
  }
178
336
  return [];
@@ -14,9 +14,15 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- Object.defineProperty(exports, "assembleTransform", {
18
- enumerable: true,
19
- get: ()=>assembleTransform
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
+ assembleTransform: ()=>assembleTransform,
25
+ getTooltipStyles: ()=>getTooltipStyles
20
26
  });
21
27
  const _tooltipModel = require("./tooltip-model");
22
28
  function assembleTransform(mousePos, chartWidth, pinnedPos, tooltipHeight, tooltipWidth) {
@@ -43,3 +49,29 @@ function assembleTransform(mousePos, chartWidth, pinnedPos, tooltipHeight, toolt
43
49
  // reposition so tooltip is never too close to right side of chart or left side of browser window
44
50
  return mousePos.plotCanvas.x > xPosAdjustThreshold && x > _tooltipModel.TOOLTIP_MAX_WIDTH ? `translate3d(${x - cursorPaddingX}px, ${y}px, 0) translateX(-100%)` : `translate3d(${x + cursorPaddingX}px, ${y}px, 0)`;
45
51
  }
52
+ function getTooltipStyles(theme, pinnedPos) {
53
+ var ref;
54
+ var ref1;
55
+ return {
56
+ minWidth: _tooltipModel.TOOLTIP_MIN_WIDTH,
57
+ maxWidth: _tooltipModel.TOOLTIP_MAX_WIDTH,
58
+ maxHeight: _tooltipModel.TOOLTIP_MAX_HEIGHT,
59
+ padding: 0,
60
+ position: 'absolute',
61
+ top: 0,
62
+ left: 0,
63
+ backgroundColor: (ref1 = (ref = theme.palette.designSystem) === null || ref === void 0 ? void 0 : ref.grey[800]) !== null && ref1 !== void 0 ? ref1 : _tooltipModel.TOOLTIP_BG_COLOR_FALLBACK,
64
+ borderRadius: '6px',
65
+ color: '#fff',
66
+ fontSize: '11px',
67
+ visibility: 'visible',
68
+ opacity: 1,
69
+ transition: 'all 0.1s ease-out',
70
+ // Ensure pinned tooltip shows behind edit panel drawer and sticky header
71
+ zIndex: pinnedPos !== null ? 'auto' : theme.zIndex.tooltip,
72
+ overflow: 'hidden',
73
+ '&:hover': {
74
+ overflowY: 'auto'
75
+ }
76
+ };
77
+ }
package/dist/cjs/index.js CHANGED
@@ -22,6 +22,7 @@ _exportStar(require("./Drawer"), exports);
22
22
  _exportStar(require("./EChart"), exports);
23
23
  _exportStar(require("./ErrorAlert"), exports);
24
24
  _exportStar(require("./ErrorBoundary"), exports);
25
+ _exportStar(require("./FontSizeSelector"), exports);
25
26
  _exportStar(require("./GaugeChart"), exports);
26
27
  _exportStar(require("./InfoTooltip"), exports);
27
28
  _exportStar(require("./JSONEditor"), exports);
@@ -32,6 +33,7 @@ _exportStar(require("./SettingsAutocomplete"), exports);
32
33
  _exportStar(require("./StatChart"), exports);
33
34
  _exportStar(require("./Table"), exports);
34
35
  _exportStar(require("./ThresholdsEditor"), exports);
36
+ _exportStar(require("./TimeChart"), exports);
35
37
  _exportStar(require("./TimeSeriesTooltip"), exports);
36
38
  _exportStar(require("./UnitSelector"), exports);
37
39
  _exportStar(require("./YAxisLabel"), exports);
@@ -0,0 +1,58 @@
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
+ getYAxes: ()=>getYAxes,
25
+ getDateRange: ()=>getDateRange
26
+ });
27
+ const _merge = /*#__PURE__*/ _interopRequireDefault(require("lodash/merge"));
28
+ const _core = require("@perses-dev/core");
29
+ function _interopRequireDefault(obj) {
30
+ return obj && obj.__esModule ? obj : {
31
+ default: obj
32
+ };
33
+ }
34
+ function getYAxes(yAxis, unit) {
35
+ // TODO: support alternate yAxis that shows on right side
36
+ const Y_AXIS_DEFAULT = {
37
+ type: 'value',
38
+ boundaryGap: [
39
+ 0,
40
+ '10%'
41
+ ],
42
+ axisLabel: {
43
+ formatter: (value)=>{
44
+ return (0, _core.formatValue)(value, unit);
45
+ }
46
+ }
47
+ };
48
+ return [
49
+ (0, _merge.default)(Y_AXIS_DEFAULT, yAxis)
50
+ ];
51
+ }
52
+ function getDateRange(data) {
53
+ const defaultRange = 3600000; // hour in ms
54
+ if (data.length === 0) return defaultRange;
55
+ const lastDatum = data[data.length - 1];
56
+ if (data[0] === undefined || lastDatum === undefined) return defaultRange;
57
+ return lastDatum - data[0];
58
+ }
@@ -23,19 +23,8 @@ function _export(target, all) {
23
23
  _export(exports, {
24
24
  enableDataZoom: ()=>enableDataZoom,
25
25
  restoreChart: ()=>restoreChart,
26
- getDateRange: ()=>getDateRange,
27
- getFormattedDate: ()=>getFormattedDate,
28
- getYAxes: ()=>getYAxes,
29
26
  clearHighlightedSeries: ()=>clearHighlightedSeries
30
27
  });
31
- const _core = require("@perses-dev/core");
32
- const _merge = /*#__PURE__*/ _interopRequireDefault(require("lodash/merge"));
33
- const _utils = require("../utils");
34
- function _interopRequireDefault(obj) {
35
- return obj && obj.__esModule ? obj : {
36
- default: obj
37
- };
38
- }
39
28
  function enableDataZoom(chart) {
40
29
  const chartModel = chart['_model'];
41
30
  if (chartModel === undefined) return;
@@ -56,49 +45,6 @@ function restoreChart(chart) {
56
45
  type: 'restore'
57
46
  });
58
47
  }
59
- function getDateRange(data) {
60
- const defaultRange = 3600000; // hour in ms
61
- if (data.length === 0) return defaultRange;
62
- const lastDatum = data[data.length - 1];
63
- if (data[0] === undefined || lastDatum === undefined) return defaultRange;
64
- return lastDatum - data[0];
65
- }
66
- function getFormattedDate(value, rangeMs, timeZone) {
67
- const dateFormatOptions = (0, _utils.dateFormatOptionsWithTimeZone)({
68
- hour: 'numeric',
69
- minute: 'numeric',
70
- hourCycle: 'h23'
71
- }, timeZone);
72
- const thirtyMinMs = 1800000;
73
- const dayMs = 86400000;
74
- if (rangeMs <= thirtyMinMs) {
75
- dateFormatOptions.second = 'numeric';
76
- } else if (rangeMs >= dayMs) {
77
- dateFormatOptions.month = 'numeric';
78
- dateFormatOptions.day = 'numeric';
79
- }
80
- const DATE_FORMAT = new Intl.DateTimeFormat(undefined, dateFormatOptions);
81
- // remove comma when month / day present
82
- return DATE_FORMAT.format(value).replace(/, /g, ' ');
83
- }
84
- function getYAxes(yAxis, unit) {
85
- // TODO: support alternate yAxis that shows on right side
86
- const Y_AXIS_DEFAULT = {
87
- type: 'value',
88
- boundaryGap: [
89
- 0,
90
- '10%'
91
- ],
92
- axisLabel: {
93
- formatter: (value)=>{
94
- return (0, _core.formatValue)(value, unit);
95
- }
96
- }
97
- };
98
- return [
99
- (0, _merge.default)(Y_AXIS_DEFAULT, yAxis)
100
- ];
101
- }
102
48
  function clearHighlightedSeries(chart, totalSeries) {
103
49
  if (chart.dispatchAction !== undefined) {
104
50
  for(let i = 0; i < totalSeries; i++){
@@ -22,7 +22,9 @@ function _export(target, all) {
22
22
  }
23
23
  _export(exports, {
24
24
  dateFormatOptionsWithTimeZone: ()=>dateFormatOptionsWithTimeZone,
25
- formatWithTimeZone: ()=>formatWithTimeZone
25
+ formatWithTimeZone: ()=>formatWithTimeZone,
26
+ getFormattedDate: ()=>getFormattedDate,
27
+ getFormattedAxisLabel: ()=>getFormattedAxisLabel
26
28
  });
27
29
  const _dateFnsTz = require("date-fns-tz");
28
30
  const _dateFns = require("date-fns");
@@ -54,3 +56,47 @@ function formatWithTimeZone(date, formatString, timeZone) {
54
56
  return (0, _dateFnsTz.formatInTimeZone)(date, lowerTimeZone === 'utc' ? 'UTC' : timeZone, formatString);
55
57
  }
56
58
  }
59
+ function getFormattedDate(value, rangeMs, timeZone) {
60
+ const dateFormatOptions = dateFormatOptionsWithTimeZone({
61
+ hour: 'numeric',
62
+ minute: 'numeric',
63
+ hourCycle: 'h23'
64
+ }, timeZone);
65
+ const thirtyMinMs = 1800000;
66
+ const dayMs = 86400000;
67
+ if (rangeMs <= thirtyMinMs) {
68
+ dateFormatOptions.second = 'numeric';
69
+ } else if (rangeMs >= dayMs) {
70
+ dateFormatOptions.month = 'numeric';
71
+ dateFormatOptions.day = 'numeric';
72
+ }
73
+ const DATE_FORMAT = new Intl.DateTimeFormat(undefined, dateFormatOptions);
74
+ // remove comma when month / day present
75
+ return DATE_FORMAT.format(value).replace(/, /g, ' ');
76
+ }
77
+ function getFormattedAxisLabel(rangeMs) {
78
+ const dayMs = 86400000;
79
+ const monthMs = 2629440000;
80
+ const yearMs = 31536000000;
81
+ // more than 5 years
82
+ if (rangeMs > yearMs * 5) {
83
+ return '{yyyy}';
84
+ }
85
+ // more than 2 years
86
+ if (rangeMs > yearMs * 2) {
87
+ return '{MMM} {yyyy}';
88
+ }
89
+ // between 5 days to 6 months
90
+ if (rangeMs > dayMs * 5 && rangeMs < monthMs * 6) {
91
+ return '{MM}/{dd}'; // 12/01
92
+ }
93
+ // between 2 and 5 days
94
+ if (rangeMs > dayMs * 2 && rangeMs <= dayMs * 5) {
95
+ return '{MM}/{dd} {HH}:{mm}'; // 12/01 12:30
96
+ }
97
+ return {
98
+ year: '{yearStyle|{yyyy}}\n{monthStyle|{MMM}}',
99
+ month: '{MMM}',
100
+ day: '{MM}/{dd}'
101
+ };
102
+ }
@@ -14,10 +14,12 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
+ _exportStar(require("./axis"), exports);
18
+ _exportStar(require("./chart-actions"), exports);
17
19
  _exportStar(require("./combine-sx"), exports);
18
- _exportStar(require("./theme-gen"), exports);
19
20
  _exportStar(require("./component-ids"), exports);
20
21
  _exportStar(require("./format"), exports);
22
+ _exportStar(require("./theme-gen"), exports);
21
23
  function _exportStar(from, to) {
22
24
  Object.keys(from).forEach(function(k) {
23
25
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
@@ -92,6 +92,43 @@ function generateChartsTheme(muiTheme, echartsTheme) {
92
92
  }
93
93
  }
94
94
  },
95
+ timeAxis: {
96
+ show: true,
97
+ axisLabel: {
98
+ show: true,
99
+ color: primaryTextColor,
100
+ margin: 15
101
+ },
102
+ axisTick: {
103
+ show: false,
104
+ length: 6,
105
+ lineStyle: {
106
+ color: muiTheme.palette.grey[600]
107
+ }
108
+ },
109
+ axisLine: {
110
+ show: true,
111
+ lineStyle: {
112
+ color: muiTheme.palette.grey[600]
113
+ }
114
+ },
115
+ splitLine: {
116
+ show: true,
117
+ lineStyle: {
118
+ width: 0.5,
119
+ color: muiTheme.palette.grey[300],
120
+ opacity: 0.6
121
+ }
122
+ },
123
+ splitArea: {
124
+ show: false,
125
+ areaStyle: {
126
+ color: [
127
+ muiTheme.palette.grey[300]
128
+ ]
129
+ }
130
+ }
131
+ },
95
132
  valueAxis: {
96
133
  show: true,
97
134
  axisLabel: {
package/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@ export * from './Drawer';
6
6
  export * from './EChart';
7
7
  export * from './ErrorAlert';
8
8
  export * from './ErrorBoundary';
9
+ export * from './FontSizeSelector';
9
10
  export * from './GaugeChart';
10
11
  export * from './InfoTooltip';
11
12
  export * from './JSONEditor';
@@ -16,6 +17,7 @@ export * from './SettingsAutocomplete';
16
17
  export * from './StatChart';
17
18
  export * from './Table';
18
19
  export * from './ThresholdsEditor';
20
+ export * from './TimeChart';
19
21
  export * from './TimeSeriesTooltip';
20
22
  export * from './UnitSelector';
21
23
  export * from './YAxisLabel';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,yBAAyB,CAAC"}
package/dist/index.js CHANGED
@@ -18,6 +18,7 @@ export * from './Drawer';
18
18
  export * from './EChart';
19
19
  export * from './ErrorAlert';
20
20
  export * from './ErrorBoundary';
21
+ export * from './FontSizeSelector';
21
22
  export * from './GaugeChart';
22
23
  export * from './InfoTooltip';
23
24
  export * from './JSONEditor';
@@ -28,6 +29,7 @@ export * from './SettingsAutocomplete';
28
29
  export * from './StatChart';
29
30
  export * from './Table';
30
31
  export * from './ThresholdsEditor';
32
+ export * from './TimeChart';
31
33
  export * from './TimeSeriesTooltip';
32
34
  export * from './UnitSelector';
33
35
  export * from './YAxisLabel';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.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\nexport * from './ColorPicker';\nexport * from './ContentWithLegend';\nexport * from './DateTimeRangePicker';\nexport * from './Dialog';\nexport * from './Drawer';\nexport * from './EChart';\nexport * from './ErrorAlert';\nexport * from './ErrorBoundary';\nexport * from './GaugeChart';\nexport * from './InfoTooltip';\nexport * from './JSONEditor';\nexport * from './Legend';\nexport * from './LineChart';\nexport * from './OptionsEditorLayout';\nexport * from './SettingsAutocomplete';\nexport * from './StatChart';\nexport * from './Table';\nexport * from './ThresholdsEditor';\nexport * from './TimeSeriesTooltip';\nexport * from './UnitSelector';\nexport * from './YAxisLabel';\nexport * from './context/ChartsThemeProvider';\nexport * from './context/TimeZoneProvider';\nexport * from './context/SnackbarProvider';\nexport * from './utils';\nexport * from './model';\nexport * from './test-utils';\nexport * from './theme';\nexport * from './RefreshIntervalPicker';\n"],"names":[],"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;AAEjC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"sources":["../src/index.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\nexport * from './ColorPicker';\nexport * from './ContentWithLegend';\nexport * from './DateTimeRangePicker';\nexport * from './Dialog';\nexport * from './Drawer';\nexport * from './EChart';\nexport * from './ErrorAlert';\nexport * from './ErrorBoundary';\nexport * from './FontSizeSelector';\nexport * from './GaugeChart';\nexport * from './InfoTooltip';\nexport * from './JSONEditor';\nexport * from './Legend';\nexport * from './LineChart';\nexport * from './OptionsEditorLayout';\nexport * from './SettingsAutocomplete';\nexport * from './StatChart';\nexport * from './Table';\nexport * from './ThresholdsEditor';\nexport * from './TimeChart';\nexport * from './TimeSeriesTooltip';\nexport * from './UnitSelector';\nexport * from './YAxisLabel';\nexport * from './context/ChartsThemeProvider';\nexport * from './context/TimeZoneProvider';\nexport * from './context/SnackbarProvider';\nexport * from './utils';\nexport * from './model';\nexport * from './test-utils';\nexport * from './theme';\nexport * from './RefreshIntervalPicker';\n"],"names":[],"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;AAEjC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,yBAAyB,CAAC"}
@@ -6,16 +6,33 @@ export declare type UnixTimeMs = number;
6
6
  export interface GraphSeries {
7
7
  name: string;
8
8
  values: TimeSeriesValueTuple[];
9
+ id?: string;
9
10
  }
10
11
  export declare type EChartsValues = number | null | '-';
11
- export interface EChartsTimeSeries extends Omit<LineSeriesOption, 'data'> {
12
+ export interface LegacyTimeSeries extends Omit<LineSeriesOption, 'data'> {
12
13
  data: EChartsValues[];
13
14
  }
15
+ export declare type TimeChartSeriesMapping = LineSeriesOption[];
16
+ export declare type TimeChartLegendItems = LegendItem[];
14
17
  export declare type EChartsDataFormat = {
15
- timeSeries: EChartsTimeSeries[];
18
+ timeSeries: LegacyTimeSeries[];
16
19
  xAxis: number[];
17
20
  legendItems?: LegendItem[];
18
21
  xAxisMax?: number | string;
19
22
  rangeMs?: number;
20
23
  };
24
+ export declare type ChartInstanceFocusOpts = {
25
+ id?: string;
26
+ name?: string;
27
+ };
28
+ export declare type ChartInstance = {
29
+ /**
30
+ * Highlight the series associated with the specified options.
31
+ */
32
+ highlightSeries: (opts: ChartInstanceFocusOpts) => void;
33
+ /**
34
+ * Clear all highlighted series.
35
+ */
36
+ clearHighlightedSeries: () => void;
37
+ };
21
38
  //# sourceMappingURL=graph.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/model/graph.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGvC,eAAO,MAAM,2BAA2B,OAAO,CAAC;AAEhD,oBAAY,UAAU,GAAG,MAAM,CAAC;AAEhC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,oBAAoB,EAAE,CAAC;CAChC;AAED,oBAAY,aAAa,GAAG,MAAM,GAAG,IAAI,GAAG,GAAG,CAAC;AAEhD,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAEvE,IAAI,EAAE,aAAa,EAAE,CAAC;CACvB;AAED,oBAAY,iBAAiB,GAAG;IAC9B,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC"}
1
+ {"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/model/graph.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGvC,eAAO,MAAM,2BAA2B,OAAO,CAAC;AAEhD,oBAAY,UAAU,GAAG,MAAM,CAAC;AAEhC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,oBAAoB,EAAE,CAAC;IAC/B,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED,oBAAY,aAAa,GAAG,MAAM,GAAG,IAAI,GAAG,GAAG,CAAC;AAEhD,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC;IACtE,IAAI,EAAE,aAAa,EAAE,CAAC;CACvB;AAGD,oBAAY,sBAAsB,GAAG,gBAAgB,EAAE,CAAC;AACxD,oBAAY,oBAAoB,GAAG,UAAU,EAAE,CAAC;AAGhD,oBAAY,iBAAiB,GAAG;IAC9B,UAAU,EAAE,gBAAgB,EAAE,CAAC;IAC/B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAKF,oBAAY,sBAAsB,GAAG;IACnC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,oBAAY,aAAa,GAAG;IAC1B;;OAEG;IACH,eAAe,EAAE,CAAC,IAAI,EAAE,sBAAsB,KAAK,IAAI,CAAC;IAExD;;OAEG;IACH,sBAAsB,EAAE,MAAM,IAAI,CAAC;CACpC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/graph.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 { TimeSeriesValueTuple } from '@perses-dev/core';\nimport { LineSeriesOption } from 'echarts/charts';\nimport { LegendItem } from '../Legend';\n\n// adjust display when there are many time series to help with performance\nexport const OPTIMIZED_MODE_SERIES_LIMIT = 1000;\n\nexport type UnixTimeMs = number;\n\nexport interface GraphSeries {\n name: string;\n values: TimeSeriesValueTuple[];\n}\n\nexport type EChartsValues = number | null | '-';\n\nexport interface EChartsTimeSeries extends Omit<LineSeriesOption, 'data'> {\n // TODO: support dataset and both category / time xAxis types\n data: EChartsValues[];\n}\n\nexport type EChartsDataFormat = {\n timeSeries: EChartsTimeSeries[];\n xAxis: number[];\n legendItems?: LegendItem[];\n xAxisMax?: number | string;\n rangeMs?: number;\n};\n"],"names":["OPTIMIZED_MODE_SERIES_LIMIT"],"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;AAMjC,0EAA0E;AAC1E,OAAO,MAAMA,2BAA2B,GAAG,IAAI,CAAC"}
1
+ {"version":3,"sources":["../../src/model/graph.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 { TimeSeriesValueTuple } from '@perses-dev/core';\nimport { LineSeriesOption } from 'echarts/charts';\nimport { LegendItem } from '../Legend';\n\n// adjust display when there are many time series to help with performance\nexport const OPTIMIZED_MODE_SERIES_LIMIT = 1000;\n\nexport type UnixTimeMs = number;\n\nexport interface GraphSeries {\n name: string;\n values: TimeSeriesValueTuple[];\n id?: string;\n}\n\nexport type EChartsValues = number | null | '-';\n\nexport interface LegacyTimeSeries extends Omit<LineSeriesOption, 'data'> {\n data: EChartsValues[];\n}\n\n// TODO: Continue to simplify TimeChart types, fix legend and thresholds\nexport type TimeChartSeriesMapping = LineSeriesOption[];\nexport type TimeChartLegendItems = LegendItem[];\n\n// TODO: Rename to LegacyEChartsDataFormat\nexport type EChartsDataFormat = {\n timeSeries: LegacyTimeSeries[];\n xAxis: number[];\n legendItems?: LegendItem[];\n xAxisMax?: number | string;\n rangeMs?: number;\n};\n\n// Intentionally making this an object to start because it is plausible we will\n// want to support focusing by other attributes (e.g. index, name) in the future,\n// and starting with an object will make adding them a non-breaking change.\nexport type ChartInstanceFocusOpts = {\n id?: string; // LineChart uses id\n name?: string; // TimeChart uses name\n};\n\nexport type ChartInstance = {\n /**\n * Highlight the series associated with the specified options.\n */\n highlightSeries: (opts: ChartInstanceFocusOpts) => void;\n\n /**\n * Clear all highlighted series.\n */\n clearHighlightedSeries: () => void;\n};\n"],"names":["OPTIMIZED_MODE_SERIES_LIMIT"],"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;AAMjC,0EAA0E;AAC1E,OAAO,MAAMA,2BAA2B,GAAG,IAAI,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { YAXisComponentOption } from 'echarts';
2
+ import { UnitOptions } from '@perses-dev/core';
3
+ export declare function getYAxes(yAxis?: YAXisComponentOption, unit?: UnitOptions): ({
4
+ type: string;
5
+ boundaryGap: (string | number)[];
6
+ axisLabel: {
7
+ formatter: (value: number) => string;
8
+ };
9
+ } & (YAXisComponentOption | undefined))[];
10
+ /**
11
+ * Calculate date range, used as a fallback when xAxis time range not passed as prop
12
+ */
13
+ export declare function getDateRange(data: number[]): number;
14
+ //# sourceMappingURL=axis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"axis.d.ts","sourceRoot":"","sources":["../../src/utils/axis.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAe,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAK5D,wBAAgB,QAAQ,CAAC,KAAK,CAAC,EAAE,oBAAoB,EAAE,IAAI,CAAC,EAAE,WAAW;;;;2BAMhD,MAAM;;0CAM9B;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,UAM1C"}