@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.
Files changed (140) hide show
  1. package/README.md +1 -0
  2. package/dist/BarChart/BarChart.d.ts +16 -0
  3. package/dist/BarChart/BarChart.d.ts.map +1 -0
  4. package/dist/BarChart/BarChart.js +129 -0
  5. package/dist/BarChart/BarChart.js.map +1 -0
  6. package/dist/BarChart/index.d.ts +2 -0
  7. package/dist/BarChart/index.d.ts.map +1 -0
  8. package/dist/BarChart/index.js +15 -0
  9. package/dist/BarChart/index.js.map +1 -0
  10. package/dist/Dialog/DiscardChangesConfirmationDialog.d.ts +10 -0
  11. package/dist/Dialog/DiscardChangesConfirmationDialog.d.ts.map +1 -0
  12. package/dist/Dialog/DiscardChangesConfirmationDialog.js +47 -0
  13. package/dist/Dialog/DiscardChangesConfirmationDialog.js.map +1 -0
  14. package/dist/Dialog/index.d.ts +1 -0
  15. package/dist/Dialog/index.d.ts.map +1 -1
  16. package/dist/Dialog/index.js +1 -0
  17. package/dist/Dialog/index.js.map +1 -1
  18. package/dist/GaugeChart/GaugeChart.js +1 -1
  19. package/dist/GaugeChart/GaugeChart.js.map +1 -1
  20. package/dist/Legend/ListLegendItem.d.ts +1 -1
  21. package/dist/LineChart/LineChart.d.ts.map +1 -1
  22. package/dist/LineChart/LineChart.js +9 -9
  23. package/dist/LineChart/LineChart.js.map +1 -1
  24. package/dist/ModeSelector/ModeSelector.d.ts +9 -0
  25. package/dist/ModeSelector/ModeSelector.d.ts.map +1 -0
  26. package/dist/ModeSelector/ModeSelector.js +43 -0
  27. package/dist/ModeSelector/ModeSelector.js.map +1 -0
  28. package/dist/ModeSelector/index.d.ts +2 -0
  29. package/dist/ModeSelector/index.d.ts.map +1 -0
  30. package/dist/ModeSelector/index.js +15 -0
  31. package/dist/ModeSelector/index.js.map +1 -0
  32. package/dist/SortSelector/SortSelector.d.ts +8 -0
  33. package/dist/SortSelector/SortSelector.d.ts.map +1 -0
  34. package/dist/SortSelector/SortSelector.js +42 -0
  35. package/dist/SortSelector/SortSelector.js.map +1 -0
  36. package/dist/SortSelector/index.d.ts +2 -0
  37. package/dist/SortSelector/index.d.ts.map +1 -0
  38. package/dist/SortSelector/index.js +15 -0
  39. package/dist/SortSelector/index.js.map +1 -0
  40. package/dist/StatChart/StatChart.js +1 -1
  41. package/dist/StatChart/StatChart.js.map +1 -1
  42. package/dist/StatChart/calculateFontSize.js +3 -3
  43. package/dist/StatChart/calculateFontSize.js.map +1 -1
  44. package/dist/ThresholdsEditor/ThresholdColorPicker.js +1 -1
  45. package/dist/ThresholdsEditor/ThresholdColorPicker.js.map +1 -1
  46. package/dist/ThresholdsEditor/ThresholdsEditor.d.ts.map +1 -1
  47. package/dist/ThresholdsEditor/ThresholdsEditor.js +3 -2
  48. package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
  49. package/dist/TimeChart/TimeChart.d.ts +2 -1
  50. package/dist/TimeChart/TimeChart.d.ts.map +1 -1
  51. package/dist/TimeChart/TimeChart.js +120 -36
  52. package/dist/TimeChart/TimeChart.js.map +1 -1
  53. package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts +6 -0
  54. package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts.map +1 -1
  55. package/dist/TimeSeriesTooltip/LineChartTooltip.js +14 -6
  56. package/dist/TimeSeriesTooltip/LineChartTooltip.js.map +1 -1
  57. package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts +1 -0
  58. package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts.map +1 -1
  59. package/dist/TimeSeriesTooltip/TimeChartTooltip.js +3 -2
  60. package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
  61. package/dist/TimeSeriesTooltip/TooltipHeader.d.ts +1 -0
  62. package/dist/TimeSeriesTooltip/TooltipHeader.d.ts.map +1 -1
  63. package/dist/TimeSeriesTooltip/TooltipHeader.js +5 -5
  64. package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -1
  65. package/dist/TimeSeriesTooltip/nearby-series.d.ts +1 -1
  66. package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -1
  67. package/dist/TimeSeriesTooltip/nearby-series.js +97 -110
  68. package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
  69. package/dist/TimeSeriesTooltip/tooltip-model.d.ts +4 -0
  70. package/dist/TimeSeriesTooltip/tooltip-model.d.ts.map +1 -1
  71. package/dist/TimeSeriesTooltip/tooltip-model.js +6 -0
  72. package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
  73. package/dist/UnitSelector/UnitSelector.d.ts +2 -1
  74. package/dist/UnitSelector/UnitSelector.d.ts.map +1 -1
  75. package/dist/UnitSelector/UnitSelector.js +3 -2
  76. package/dist/UnitSelector/UnitSelector.js.map +1 -1
  77. package/dist/cjs/BarChart/BarChart.js +135 -0
  78. package/dist/cjs/BarChart/index.js +28 -0
  79. package/dist/cjs/Dialog/DiscardChangesConfirmationDialog.js +53 -0
  80. package/dist/cjs/Dialog/index.js +1 -0
  81. package/dist/cjs/GaugeChart/GaugeChart.js +2 -2
  82. package/dist/cjs/LineChart/LineChart.js +8 -8
  83. package/dist/cjs/ModeSelector/ModeSelector.js +49 -0
  84. package/dist/cjs/ModeSelector/index.js +28 -0
  85. package/dist/cjs/SortSelector/SortSelector.js +48 -0
  86. package/dist/cjs/SortSelector/index.js +28 -0
  87. package/dist/cjs/StatChart/StatChart.js +2 -2
  88. package/dist/cjs/StatChart/calculateFontSize.js +3 -3
  89. package/dist/cjs/ThresholdsEditor/ThresholdColorPicker.js +2 -2
  90. package/dist/cjs/ThresholdsEditor/ThresholdsEditor.js +3 -2
  91. package/dist/cjs/TimeChart/TimeChart.js +121 -32
  92. package/dist/cjs/TimeSeriesTooltip/LineChartTooltip.js +13 -5
  93. package/dist/cjs/TimeSeriesTooltip/TimeChartTooltip.js +3 -2
  94. package/dist/cjs/TimeSeriesTooltip/TooltipHeader.js +4 -4
  95. package/dist/cjs/TimeSeriesTooltip/nearby-series.js +97 -110
  96. package/dist/cjs/TimeSeriesTooltip/tooltip-model.js +10 -1
  97. package/dist/cjs/UnitSelector/UnitSelector.js +3 -2
  98. package/dist/cjs/context/{ChartsThemeProvider.js → ChartsProvider.js} +24 -5
  99. package/dist/cjs/context/index.js +30 -0
  100. package/dist/cjs/index.js +4 -3
  101. package/dist/cjs/model/graph.js +35 -3
  102. package/dist/cjs/test-utils/theme.js +32 -19
  103. package/dist/cjs/utils/axis.js +4 -4
  104. package/dist/cjs/utils/chart-actions.js +99 -1
  105. package/dist/cjs/utils/theme-gen.js +34 -6
  106. package/dist/context/ChartsProvider.d.ts +19 -0
  107. package/dist/context/ChartsProvider.d.ts.map +1 -0
  108. package/dist/context/{ChartsThemeProvider.js → ChartsProvider.js} +24 -6
  109. package/dist/context/ChartsProvider.js.map +1 -0
  110. package/dist/context/index.d.ts +4 -0
  111. package/dist/context/index.d.ts.map +1 -0
  112. package/dist/context/index.js +17 -0
  113. package/dist/context/index.js.map +1 -0
  114. package/dist/index.d.ts +4 -3
  115. package/dist/index.d.ts.map +1 -1
  116. package/dist/index.js +4 -3
  117. package/dist/index.js.map +1 -1
  118. package/dist/model/graph.d.ts +11 -2
  119. package/dist/model/graph.d.ts.map +1 -1
  120. package/dist/model/graph.js +25 -0
  121. package/dist/model/graph.js.map +1 -1
  122. package/dist/test-utils/theme.d.ts +2 -0
  123. package/dist/test-utils/theme.d.ts.map +1 -1
  124. package/dist/test-utils/theme.js +23 -16
  125. package/dist/test-utils/theme.js.map +1 -1
  126. package/dist/utils/axis.d.ts +3 -3
  127. package/dist/utils/axis.d.ts.map +1 -1
  128. package/dist/utils/axis.js +4 -4
  129. package/dist/utils/axis.js.map +1 -1
  130. package/dist/utils/chart-actions.d.ts +7 -0
  131. package/dist/utils/chart-actions.d.ts.map +1 -1
  132. package/dist/utils/chart-actions.js +108 -0
  133. package/dist/utils/chart-actions.js.map +1 -1
  134. package/dist/utils/theme-gen.d.ts.map +1 -1
  135. package/dist/utils/theme-gen.js +34 -6
  136. package/dist/utils/theme-gen.js.map +1 -1
  137. package/package.json +3 -3
  138. package/dist/context/ChartsThemeProvider.d.ts +0 -10
  139. package/dist/context/ChartsThemeProvider.d.ts.map +0 -1
  140. package/dist/context/ChartsThemeProvider.js.map +0 -1
@@ -23,8 +23,14 @@ function _export(target, all) {
23
23
  _export(exports, {
24
24
  enableDataZoom: ()=>enableDataZoom,
25
25
  restoreChart: ()=>restoreChart,
26
- clearHighlightedSeries: ()=>clearHighlightedSeries
26
+ clearHighlightedSeries: ()=>clearHighlightedSeries,
27
+ getPointInGrid: ()=>getPointInGrid,
28
+ batchDispatchNearbySeriesActions: ()=>batchDispatchNearbySeriesActions,
29
+ checkCrosshairPinnedStatus: ()=>checkCrosshairPinnedStatus,
30
+ getClosestTimestamp: ()=>getClosestTimestamp,
31
+ getClosestTimestampInFullDataset: ()=>getClosestTimestampInFullDataset
27
32
  });
33
+ const _model = require("../model");
28
34
  function enableDataZoom(chart) {
29
35
  const chartModel = chart['_model'];
30
36
  if (chartModel === undefined) return;
@@ -55,3 +61,95 @@ function clearHighlightedSeries(chart, totalSeries) {
55
61
  }
56
62
  }
57
63
  }
64
+ function getPointInGrid(cursorCoordX, cursorCoordY, chart) {
65
+ if (chart === undefined) {
66
+ return null;
67
+ }
68
+ const pointInPixel = [
69
+ cursorCoordX,
70
+ cursorCoordY
71
+ ];
72
+ if (!chart.containPixel('grid', pointInPixel)) {
73
+ return null;
74
+ }
75
+ const pointInGrid = chart.convertFromPixel('grid', pointInPixel);
76
+ return pointInGrid;
77
+ }
78
+ function batchDispatchNearbySeriesActions(chart, nearbySeriesIndexes, emphasizedSeriesIndexes, nonEmphasizedSeriesIndexes, emphasizedDatapoints, duplicateDatapoints) {
79
+ // Accounts for multiple series that are rendered direct on top of eachother.
80
+ // Only applies select state to the datapoint that is visible to avoid color mismatch.
81
+ const lastEmphasizedDatapoint = duplicateDatapoints.length > 0 ? duplicateDatapoints[duplicateDatapoints.length - 1] : emphasizedDatapoints[emphasizedDatapoints.length - 1];
82
+ if (lastEmphasizedDatapoint !== undefined) {
83
+ // Corresponds to select options inside getTimeSeries util.
84
+ // https://echarts.apache.org/en/option.html#series-line.select.itemStyle
85
+ chart.dispatchAction({
86
+ type: 'select',
87
+ seriesIndex: lastEmphasizedDatapoint.seriesIndex,
88
+ dataIndex: lastEmphasizedDatapoint.dataIndex,
89
+ // Shared crosshair should not emphasize datapoints on adjacent charts.
90
+ escapeConnect: true
91
+ });
92
+ }
93
+ // Clears emphasis state of all lines that are not emphasized.
94
+ // Emphasized is a subset of just the nearby series that are closest to cursor.
95
+ chart.dispatchAction({
96
+ type: 'downplay',
97
+ seriesIndex: nonEmphasizedSeriesIndexes
98
+ });
99
+ // https://echarts.apache.org/en/api.html#action.highlight
100
+ if (emphasizedSeriesIndexes.length > 0) {
101
+ // Fadeout opacity of all series not closest to cursor.
102
+ chart.dispatchAction({
103
+ type: 'highlight',
104
+ seriesIndex: emphasizedSeriesIndexes,
105
+ notBlur: false,
106
+ escapeConnect: true
107
+ });
108
+ } else {
109
+ // When no emphasized series with bold text, notBlur allows opacity fadeout to not trigger.
110
+ chart.dispatchAction({
111
+ type: 'highlight',
112
+ seriesIndex: nearbySeriesIndexes,
113
+ notBlur: true,
114
+ escapeConnect: true
115
+ });
116
+ // Clears selected datapoints since no bold series in tooltip, restore does not impact highlighting
117
+ chart.dispatchAction({
118
+ type: 'toggleSelect'
119
+ });
120
+ }
121
+ }
122
+ function checkCrosshairPinnedStatus(seriesMapping) {
123
+ var ref;
124
+ const isCrosshairPinned = ((ref = seriesMapping[seriesMapping.length - 1]) === null || ref === void 0 ? void 0 : ref.name) === _model.PINNED_CROSSHAIR_SERIES_NAME;
125
+ return isCrosshairPinned;
126
+ }
127
+ function getClosestTimestamp(timeSeriesValues, cursorX) {
128
+ if (timeSeriesValues === undefined || cursorX === undefined) {
129
+ return null;
130
+ }
131
+ let currentClosestTimestamp = null;
132
+ let currentClosestDistance = Infinity;
133
+ for (const [timestamp] of timeSeriesValues){
134
+ const distance = Math.abs(timestamp - cursorX);
135
+ if (distance < currentClosestDistance) {
136
+ currentClosestTimestamp = timestamp;
137
+ currentClosestDistance = distance;
138
+ }
139
+ }
140
+ return currentClosestTimestamp;
141
+ }
142
+ function getClosestTimestampInFullDataset(data, cursorX) {
143
+ if (cursorX === undefined) {
144
+ return null;
145
+ }
146
+ const totalSeries = data.length;
147
+ let closestTimestamp = null;
148
+ for(let seriesIdx = 0; seriesIdx < totalSeries; seriesIdx++){
149
+ const currentDataset = totalSeries > 0 ? data[seriesIdx] : null;
150
+ if (currentDataset == null) break;
151
+ const currentValues = currentDataset.values;
152
+ closestTimestamp = getClosestTimestamp(currentValues, cursorX);
153
+ }
154
+ return closestTimestamp;
155
+ }
@@ -29,9 +29,9 @@ function generateChartsTheme(muiTheme, echartsTheme, /**
29
29
  * The id of the container that will have the chart tooltip appended to it.
30
30
  * By default, chart tooltip uses the body of the top-level document object.
31
31
  */ tooltipPortalContainerId) {
32
- var ref, ref1, ref2, ref3, ref4;
33
- var ref5;
34
- const primaryTextColor = (ref5 = (ref = muiTheme.palette.text) === null || ref === void 0 ? void 0 : ref.primary) !== null && ref5 !== void 0 ? ref5 : DEFAULT_TEXT_COLOR;
32
+ var ref, ref1, ref2, ref3, ref4, ref5, ref6;
33
+ var ref7;
34
+ const primaryTextColor = (ref7 = (ref = muiTheme.palette.text) === null || ref === void 0 ? void 0 : ref.primary) !== null && ref7 !== void 0 ? ref7 : DEFAULT_TEXT_COLOR;
35
35
  const muiConvertedTheme = {
36
36
  title: {
37
37
  show: false
@@ -83,7 +83,7 @@ function generateChartsTheme(muiTheme, echartsTheme, /**
83
83
  lineStyle: {
84
84
  width: 0.5,
85
85
  color: muiTheme.palette.grey[300],
86
- opacity: 0.6
86
+ opacity: 0.4
87
87
  }
88
88
  },
89
89
  splitArea: {
@@ -120,7 +120,7 @@ function generateChartsTheme(muiTheme, echartsTheme, /**
120
120
  lineStyle: {
121
121
  width: 0.5,
122
122
  color: muiTheme.palette.grey[300],
123
- opacity: 0.6
123
+ opacity: 0.4
124
124
  }
125
125
  },
126
126
  splitArea: {
@@ -169,7 +169,30 @@ function generateChartsTheme(muiTheme, echartsTheme, /**
169
169
  borderColor: primaryTextColor
170
170
  }
171
171
  },
172
- tooltip: {},
172
+ tooltip: {
173
+ backgroundColor: (ref5 = muiTheme.palette.designSystem) === null || ref5 === void 0 ? void 0 : ref5.grey[800],
174
+ borderColor: (ref6 = muiTheme.palette.designSystem) === null || ref6 === void 0 ? void 0 : ref6.grey[800],
175
+ textStyle: {
176
+ color: '#fff',
177
+ fontSize: 11
178
+ }
179
+ },
180
+ axisPointer: {
181
+ lineStyle: {
182
+ color: muiTheme.palette.grey[500]
183
+ }
184
+ },
185
+ markLine: {
186
+ symbol: 'none',
187
+ symbolSize: 0,
188
+ itemStyle: {
189
+ color: muiTheme.palette.grey[500]
190
+ },
191
+ lineStyle: {
192
+ type: 'dashed',
193
+ width: 1
194
+ }
195
+ },
173
196
  line: {
174
197
  showSymbol: false,
175
198
  symbol: 'circle',
@@ -188,7 +211,12 @@ function generateChartsTheme(muiTheme, echartsTheme, /**
188
211
  barMaxWidth: 150,
189
212
  itemStyle: {
190
213
  borderWidth: 0,
214
+ borderRadius: 0,
191
215
  borderColor: muiTheme.palette.grey[300]
216
+ },
217
+ label: {
218
+ show: false,
219
+ color: primaryTextColor
192
220
  }
193
221
  },
194
222
  gauge: {
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import { PersesChartsTheme } from '../model';
3
+ import { CursorCoordinates } from '../TimeSeriesTooltip';
4
+ export interface ChartsProviderProps {
5
+ chartsTheme: PersesChartsTheme;
6
+ enablePinning?: boolean;
7
+ children?: React.ReactNode;
8
+ }
9
+ export interface SharedChartsState {
10
+ chartsTheme: PersesChartsTheme;
11
+ enablePinning: boolean;
12
+ lastTooltipPinnedCoords: CursorCoordinates | null;
13
+ setLastTooltipPinnedCoords: (lastTooltipPinnedCoords: CursorCoordinates | null) => void;
14
+ }
15
+ export declare function ChartsProvider(props: ChartsProviderProps): JSX.Element;
16
+ export declare const ChartsThemeContext: React.Context<SharedChartsState | undefined>;
17
+ export declare function useChartsContext(): SharedChartsState;
18
+ export declare function useChartsTheme(): PersesChartsTheme;
19
+ //# sourceMappingURL=ChartsProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartsProvider.d.ts","sourceRoot":"","sources":["../../src/context/ChartsProvider.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAuD,MAAM,OAAO,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,iBAAiB,CAAC;IAC/B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,iBAAiB,CAAC;IAC/B,aAAa,EAAE,OAAO,CAAC;IACvB,uBAAuB,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAClD,0BAA0B,EAAE,CAAC,uBAAuB,EAAE,iBAAiB,GAAG,IAAI,KAAK,IAAI,CAAC;CACzF;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,eAexD;AAED,eAAO,MAAM,kBAAkB,8CAA0D,CAAC;AAE1F,wBAAgB,gBAAgB,IAAI,iBAAiB,CAMpD;AAED,wBAAgB,cAAc,IAAI,iBAAiB,CAGlD"}
@@ -11,21 +11,39 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
- import React, { createContext, useContext } from 'react';
15
- export function ChartsThemeProvider(props) {
16
- const { children , chartsTheme } = props;
14
+ import React, { createContext, useContext, useMemo, useState } from 'react';
15
+ export function ChartsProvider(props) {
16
+ const { children , chartsTheme , enablePinning =false } = props;
17
+ const [lastTooltipPinnedCoords, setLastTooltipPinnedCoords] = useState(null);
18
+ const ctx = useMemo(()=>{
19
+ return {
20
+ chartsTheme,
21
+ enablePinning,
22
+ lastTooltipPinnedCoords,
23
+ setLastTooltipPinnedCoords
24
+ };
25
+ }, [
26
+ chartsTheme,
27
+ enablePinning,
28
+ lastTooltipPinnedCoords,
29
+ setLastTooltipPinnedCoords
30
+ ]);
17
31
  return /*#__PURE__*/ _jsx(ChartsThemeContext.Provider, {
18
- value: chartsTheme,
32
+ value: ctx,
19
33
  children: children
20
34
  });
21
35
  }
22
36
  export const ChartsThemeContext = /*#__PURE__*/ createContext(undefined);
23
- export function useChartsTheme() {
37
+ export function useChartsContext() {
24
38
  const ctx = useContext(ChartsThemeContext);
25
39
  if (ctx === undefined) {
26
40
  throw new Error('No ChartsThemeContext found. Did you forget a Provider?');
27
41
  }
28
42
  return ctx;
29
43
  }
44
+ export function useChartsTheme() {
45
+ const ctx = useChartsContext();
46
+ return ctx.chartsTheme;
47
+ }
30
48
 
31
- //# sourceMappingURL=ChartsThemeProvider.js.map
49
+ //# sourceMappingURL=ChartsProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/context/ChartsProvider.tsx"],"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 React, { createContext, useContext, useMemo, useState } from 'react';\nimport { PersesChartsTheme } from '../model';\nimport { CursorCoordinates } from '../TimeSeriesTooltip';\n\nexport interface ChartsProviderProps {\n chartsTheme: PersesChartsTheme;\n enablePinning?: boolean;\n children?: React.ReactNode;\n}\n\nexport interface SharedChartsState {\n chartsTheme: PersesChartsTheme;\n enablePinning: boolean;\n lastTooltipPinnedCoords: CursorCoordinates | null;\n setLastTooltipPinnedCoords: (lastTooltipPinnedCoords: CursorCoordinates | null) => void;\n}\n\nexport function ChartsProvider(props: ChartsProviderProps) {\n const { children, chartsTheme, enablePinning = false } = props;\n\n const [lastTooltipPinnedCoords, setLastTooltipPinnedCoords] = useState<CursorCoordinates | null>(null);\n\n const ctx = useMemo(() => {\n return {\n chartsTheme,\n enablePinning,\n lastTooltipPinnedCoords,\n setLastTooltipPinnedCoords,\n };\n }, [chartsTheme, enablePinning, lastTooltipPinnedCoords, setLastTooltipPinnedCoords]);\n\n return <ChartsThemeContext.Provider value={ctx}>{children}</ChartsThemeContext.Provider>;\n}\n\nexport const ChartsThemeContext = createContext<SharedChartsState | undefined>(undefined);\n\nexport function useChartsContext(): SharedChartsState {\n const ctx = useContext(ChartsThemeContext);\n if (ctx === undefined) {\n throw new Error('No ChartsThemeContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\nexport function useChartsTheme(): PersesChartsTheme {\n const ctx = useChartsContext();\n return ctx.chartsTheme;\n}\n"],"names":["React","createContext","useContext","useMemo","useState","ChartsProvider","props","children","chartsTheme","enablePinning","lastTooltipPinnedCoords","setLastTooltipPinnedCoords","ctx","ChartsThemeContext","Provider","value","undefined","useChartsContext","Error","useChartsTheme"],"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;AAAA,OAAOA,KAAK,IAAIC,aAAa,EAAEC,UAAU,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO,CAAC;AAiB5E,OAAO,SAASC,cAAc,CAACC,KAA0B,EAAE;IACzD,MAAM,EAAEC,QAAQ,CAAA,EAAEC,WAAW,CAAA,EAAEC,aAAa,EAAG,KAAK,CAAA,EAAE,GAAGH,KAAK,AAAC;IAE/D,MAAM,CAACI,uBAAuB,EAAEC,0BAA0B,CAAC,GAAGP,QAAQ,CAA2B,IAAI,CAAC,AAAC;IAEvG,MAAMQ,GAAG,GAAGT,OAAO,CAAC,IAAM;QACxB,OAAO;YACLK,WAAW;YACXC,aAAa;YACbC,uBAAuB;YACvBC,0BAA0B;SAC3B,CAAC;IACJ,CAAC,EAAE;QAACH,WAAW;QAAEC,aAAa;QAAEC,uBAAuB;QAAEC,0BAA0B;KAAC,CAAC,AAAC;IAEtF,qBAAO,KAACE,kBAAkB,CAACC,QAAQ;QAACC,KAAK,EAAEH,GAAG;kBAAGL,QAAQ;MAA+B,CAAC;AAC3F,CAAC;AAED,OAAO,MAAMM,kBAAkB,iBAAGZ,aAAa,CAAgCe,SAAS,CAAC,CAAC;AAE1F,OAAO,SAASC,gBAAgB,GAAsB;IACpD,MAAML,GAAG,GAAGV,UAAU,CAACW,kBAAkB,CAAC,AAAC;IAC3C,IAAID,GAAG,KAAKI,SAAS,EAAE;QACrB,MAAM,IAAIE,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IACD,OAAON,GAAG,CAAC;AACb,CAAC;AAED,OAAO,SAASO,cAAc,GAAsB;IAClD,MAAMP,GAAG,GAAGK,gBAAgB,EAAE,AAAC;IAC/B,OAAOL,GAAG,CAACJ,WAAW,CAAC;AACzB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './ChartsProvider';
2
+ export * from './SnackbarProvider';
3
+ export * from './TimeZoneProvider';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":"AAaA,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,17 @@
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
+ export * from './ChartsProvider';
14
+ export * from './SnackbarProvider';
15
+ export * from './TimeZoneProvider';
16
+
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/context/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 './ChartsProvider';\nexport * from './SnackbarProvider';\nexport * from './TimeZoneProvider';\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,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './BarChart';
1
2
  export * from './ColorPicker';
2
3
  export * from './ContentWithLegend';
3
4
  export * from './DateTimeRangePicker';
@@ -12,8 +13,10 @@ export * from './InfoTooltip';
12
13
  export * from './JSONEditor';
13
14
  export * from './Legend';
14
15
  export * from './LineChart';
16
+ export * from './ModeSelector';
15
17
  export * from './OptionsEditorLayout';
16
18
  export * from './SettingsAutocomplete';
19
+ export * from './SortSelector';
17
20
  export * from './StatChart';
18
21
  export * from './Table';
19
22
  export * from './ThresholdsEditor';
@@ -21,9 +24,7 @@ export * from './TimeChart';
21
24
  export * from './TimeSeriesTooltip';
22
25
  export * from './UnitSelector';
23
26
  export * from './YAxisLabel';
24
- export * from './context/ChartsThemeProvider';
25
- export * from './context/TimeZoneProvider';
26
- export * from './context/SnackbarProvider';
27
+ export * from './context';
27
28
  export * from './utils';
28
29
  export * from './model';
29
30
  export * from './test-utils';
@@ -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,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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,YAAY,CAAC;AAC3B,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,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,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,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,yBAAyB,CAAC"}
package/dist/index.js CHANGED
@@ -10,6 +10,7 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
+ export * from './BarChart';
13
14
  export * from './ColorPicker';
14
15
  export * from './ContentWithLegend';
15
16
  export * from './DateTimeRangePicker';
@@ -24,8 +25,10 @@ export * from './InfoTooltip';
24
25
  export * from './JSONEditor';
25
26
  export * from './Legend';
26
27
  export * from './LineChart';
28
+ export * from './ModeSelector';
27
29
  export * from './OptionsEditorLayout';
28
30
  export * from './SettingsAutocomplete';
31
+ export * from './SortSelector';
29
32
  export * from './StatChart';
30
33
  export * from './Table';
31
34
  export * from './ThresholdsEditor';
@@ -33,9 +36,7 @@ export * from './TimeChart';
33
36
  export * from './TimeSeriesTooltip';
34
37
  export * from './UnitSelector';
35
38
  export * from './YAxisLabel';
36
- export * from './context/ChartsThemeProvider';
37
- export * from './context/TimeZoneProvider';
38
- export * from './context/SnackbarProvider';
39
+ export * from './context';
39
40
  export * from './utils';
40
41
  export * from './model';
41
42
  export * from './test-utils';
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 './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"}
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 './BarChart';\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 './ModeSelector';\nexport * from './OptionsEditorLayout';\nexport * from './SettingsAutocomplete';\nexport * from './SortSelector';\nexport * from './StatChart';\nexport * from './Table';\nexport * from './ThresholdsEditor';\nexport * from './TimeChart';\nexport * from './TimeSeriesTooltip';\nexport * from './UnitSelector';\nexport * from './YAxisLabel';\nexport * from './context';\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,YAAY,CAAC;AAC3B,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,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,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,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,yBAAyB,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { TimeSeriesValueTuple } from '@perses-dev/core';
2
- import { LineSeriesOption } from 'echarts/charts';
2
+ import { LineSeriesOption, BarSeriesOption } from 'echarts/charts';
3
3
  import { LegendItem } from '../Legend';
4
4
  export declare const OPTIMIZED_MODE_SERIES_LIMIT = 1000;
5
5
  export declare type UnixTimeMs = number;
@@ -12,8 +12,9 @@ export declare type EChartsValues = number | null | '-';
12
12
  export interface LegacyTimeSeries extends Omit<LineSeriesOption, 'data'> {
13
13
  data: EChartsValues[];
14
14
  }
15
- export declare type TimeChartSeriesMapping = LineSeriesOption[];
15
+ export declare type TimeChartSeriesMapping = TimeSeriesOption[];
16
16
  export declare type TimeChartLegendItems = LegendItem[];
17
+ export declare type TimeSeriesOption = LineSeriesOption | BarSeriesOption;
17
18
  export declare type EChartsDataFormat = {
18
19
  timeSeries: LegacyTimeSeries[];
19
20
  xAxis: number[];
@@ -35,4 +36,12 @@ export declare type ChartInstance = {
35
36
  */
36
37
  clearHighlightedSeries: () => void;
37
38
  };
39
+ export declare const PINNED_CROSSHAIR_SERIES_NAME = "Pinned Crosshair";
40
+ export declare const DEFAULT_PINNED_CROSSHAIR: LineSeriesOption;
41
+ export interface DatapointInfo {
42
+ dataIndex: number;
43
+ seriesIndex: number;
44
+ seriesName: string;
45
+ yValue: number;
46
+ }
38
47
  //# 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;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
+ {"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,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACnE,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;AAID,oBAAY,sBAAsB,GAAG,gBAAgB,EAAE,CAAC;AACxD,oBAAY,oBAAoB,GAAG,UAAU,EAAE,CAAC;AAEhD,oBAAY,gBAAgB,GAAG,gBAAgB,GAAG,eAAe,CAAC;AAIlE,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;AAEF,eAAO,MAAM,4BAA4B,qBAAqB,CAAC;AAE/D,eAAO,MAAM,wBAAwB,EAAE,gBAuBtC,CAAC;AAEF,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB"}
@@ -12,5 +12,30 @@
12
12
  // limitations under the License.
13
13
  // adjust display when there are many time series to help with performance
14
14
  export const OPTIMIZED_MODE_SERIES_LIMIT = 1000;
15
+ export const PINNED_CROSSHAIR_SERIES_NAME = 'Pinned Crosshair';
16
+ export const DEFAULT_PINNED_CROSSHAIR = {
17
+ name: PINNED_CROSSHAIR_SERIES_NAME,
18
+ type: 'line',
19
+ // https://echarts.apache.org/en/option.html#series-line.markLine
20
+ markLine: {
21
+ data: [],
22
+ lineStyle: {
23
+ type: 'dashed',
24
+ width: 2
25
+ },
26
+ emphasis: {
27
+ lineStyle: {
28
+ width: 2,
29
+ opacity: 1
30
+ }
31
+ },
32
+ blur: {
33
+ lineStyle: {
34
+ width: 2,
35
+ opacity: 1
36
+ }
37
+ }
38
+ }
39
+ };
15
40
 
16
41
  //# sourceMappingURL=graph.js.map
@@ -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 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"}
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, BarSeriesOption } 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// Used for TimeChart dataset support, each time series returned is mapped to series options using datasetIndex\n// - https://apache.github.io/echarts-handbook/en/concepts/dataset/#how-to-reference-several-datasets\nexport type TimeChartSeriesMapping = TimeSeriesOption[];\nexport type TimeChartLegendItems = LegendItem[];\n\nexport type TimeSeriesOption = LineSeriesOption | BarSeriesOption;\n\n// [DEPRECATED] used for legacy LineChart 'category' axis.\n// May delete in future when embed users migrate to TimeChart.\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\nexport const PINNED_CROSSHAIR_SERIES_NAME = 'Pinned Crosshair';\n\nexport const DEFAULT_PINNED_CROSSHAIR: LineSeriesOption = {\n name: PINNED_CROSSHAIR_SERIES_NAME,\n type: 'line',\n // https://echarts.apache.org/en/option.html#series-line.markLine\n markLine: {\n data: [],\n lineStyle: {\n type: 'dashed',\n width: 2,\n },\n emphasis: {\n lineStyle: {\n width: 2,\n opacity: 1,\n },\n },\n blur: {\n lineStyle: {\n width: 2,\n opacity: 1,\n },\n },\n },\n};\n\nexport interface DatapointInfo {\n dataIndex: number;\n seriesIndex: number;\n seriesName: string;\n yValue: number;\n}\n"],"names":["OPTIMIZED_MODE_SERIES_LIMIT","PINNED_CROSSHAIR_SERIES_NAME","DEFAULT_PINNED_CROSSHAIR","name","type","markLine","data","lineStyle","width","emphasis","opacity","blur"],"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;AAqDhD,OAAO,MAAMC,4BAA4B,GAAG,kBAAkB,CAAC;AAE/D,OAAO,MAAMC,wBAAwB,GAAqB;IACxDC,IAAI,EAAEF,4BAA4B;IAClCG,IAAI,EAAE,MAAM;IACZ,iEAAiE;IACjEC,QAAQ,EAAE;QACRC,IAAI,EAAE,EAAE;QACRC,SAAS,EAAE;YACTH,IAAI,EAAE,QAAQ;YACdI,KAAK,EAAE,CAAC;SACT;QACDC,QAAQ,EAAE;YACRF,SAAS,EAAE;gBACTC,KAAK,EAAE,CAAC;gBACRE,OAAO,EAAE,CAAC;aACX;SACF;QACDC,IAAI,EAAE;YACJJ,SAAS,EAAE;gBACTC,KAAK,EAAE,CAAC;gBACRE,OAAO,EAAE,CAAC;aACX;SACF;KACF;CACF,CAAC"}
@@ -1,3 +1,5 @@
1
1
  import { PersesChartsTheme } from '../model';
2
+ import { SharedChartsState } from '../context';
2
3
  export declare const testChartsTheme: PersesChartsTheme;
4
+ export declare const mockChartsContext: SharedChartsState;
3
5
  //# sourceMappingURL=theme.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/test-utils/theme.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,eAAO,MAAM,eAAe,EAAE,iBAgB7B,CAAC"}
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/test-utils/theme.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,iBAAiB,EAAgB,MAAM,UAAU,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAoB/C,eAAO,MAAM,eAAe,EAAE,iBAAyF,CAAC;AAExH,eAAO,MAAM,iBAAiB,EAAE,iBAK/B,CAAC"}
@@ -10,26 +10,33 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- export const testChartsTheme = {
14
- echartsTheme: {},
15
- noDataOption: {},
16
- sparkline: {
17
- width: 1,
18
- color: '#000000'
13
+ import { createTheme as createMuiTheme } from '@mui/material';
14
+ import { generateChartsTheme } from '../utils';
15
+ // app specific echarts option overrides
16
+ const TEST_ECHARTS_THEME_OVERRIDES = {
17
+ textStyle: {
18
+ fontFamily: 'Lato'
19
19
  },
20
- container: {
21
- padding: {
22
- default: 12
20
+ categoryAxis: {
21
+ splitLine: {
22
+ show: false
23
23
  }
24
24
  },
25
- thresholds: {
26
- defaultColor: '#59CC8D',
27
- palette: [
28
- '#438FEB',
29
- '#FFB249',
30
- '#EE6C6C'
31
- ]
25
+ timeAxis: {
26
+ splitLine: {
27
+ show: false
28
+ }
29
+ },
30
+ bar: {
31
+ barCategoryGap: 2
32
32
  }
33
33
  };
34
+ export const testChartsTheme = generateChartsTheme(createMuiTheme({}), TEST_ECHARTS_THEME_OVERRIDES);
35
+ export const mockChartsContext = {
36
+ chartsTheme: testChartsTheme,
37
+ enablePinning: false,
38
+ lastTooltipPinnedCoords: null,
39
+ setLastTooltipPinnedCoords: ()=>null
40
+ };
34
41
 
35
42
  //# sourceMappingURL=theme.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/test-utils/theme.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 { PersesChartsTheme } from '../model';\n\nexport const testChartsTheme: PersesChartsTheme = {\n echartsTheme: {},\n noDataOption: {},\n sparkline: {\n width: 1,\n color: '#000000',\n },\n container: {\n padding: {\n default: 12,\n },\n },\n thresholds: {\n defaultColor: '#59CC8D',\n palette: ['#438FEB', '#FFB249', '#EE6C6C'],\n },\n};\n"],"names":["testChartsTheme","echartsTheme","noDataOption","sparkline","width","color","container","padding","default","thresholds","defaultColor","palette"],"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;AAIjC,OAAO,MAAMA,eAAe,GAAsB;IAChDC,YAAY,EAAE,EAAE;IAChBC,YAAY,EAAE,EAAE;IAChBC,SAAS,EAAE;QACTC,KAAK,EAAE,CAAC;QACRC,KAAK,EAAE,SAAS;KACjB;IACDC,SAAS,EAAE;QACTC,OAAO,EAAE;YACPC,OAAO,EAAE,EAAE;SACZ;KACF;IACDC,UAAU,EAAE;QACVC,YAAY,EAAE,SAAS;QACvBC,OAAO,EAAE;YAAC,SAAS;YAAE,SAAS;YAAE,SAAS;SAAC;KAC3C;CACF,CAAC"}
1
+ {"version":3,"sources":["../../src/test-utils/theme.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 { createTheme as createMuiTheme } from '@mui/material';\nimport { PersesChartsTheme, EChartsTheme } from '../model';\nimport { generateChartsTheme } from '../utils';\nimport { SharedChartsState } from '../context';\n\n// app specific echarts option overrides\nconst TEST_ECHARTS_THEME_OVERRIDES: EChartsTheme = {\n textStyle: { fontFamily: 'Lato' },\n categoryAxis: {\n splitLine: {\n show: false,\n },\n },\n timeAxis: {\n splitLine: {\n show: false,\n },\n },\n bar: {\n barCategoryGap: 2,\n },\n};\n\nexport const testChartsTheme: PersesChartsTheme = generateChartsTheme(createMuiTheme({}), TEST_ECHARTS_THEME_OVERRIDES);\n\nexport const mockChartsContext: SharedChartsState = {\n chartsTheme: testChartsTheme,\n enablePinning: false,\n lastTooltipPinnedCoords: null,\n setLastTooltipPinnedCoords: () => null,\n};\n"],"names":["createTheme","createMuiTheme","generateChartsTheme","TEST_ECHARTS_THEME_OVERRIDES","textStyle","fontFamily","categoryAxis","splitLine","show","timeAxis","bar","barCategoryGap","testChartsTheme","mockChartsContext","chartsTheme","enablePinning","lastTooltipPinnedCoords","setLastTooltipPinnedCoords"],"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,SAASA,WAAW,IAAIC,cAAc,QAAQ,eAAe,CAAC;AAE9D,SAASC,mBAAmB,QAAQ,UAAU,CAAC;AAG/C,wCAAwC;AACxC,MAAMC,4BAA4B,GAAiB;IACjDC,SAAS,EAAE;QAAEC,UAAU,EAAE,MAAM;KAAE;IACjCC,YAAY,EAAE;QACZC,SAAS,EAAE;YACTC,IAAI,EAAE,KAAK;SACZ;KACF;IACDC,QAAQ,EAAE;QACRF,SAAS,EAAE;YACTC,IAAI,EAAE,KAAK;SACZ;KACF;IACDE,GAAG,EAAE;QACHC,cAAc,EAAE,CAAC;KAClB;CACF,AAAC;AAEF,OAAO,MAAMC,eAAe,GAAsBV,mBAAmB,CAACD,cAAc,CAAC,EAAE,CAAC,EAAEE,4BAA4B,CAAC,CAAC;AAExH,OAAO,MAAMU,iBAAiB,GAAsB;IAClDC,WAAW,EAAEF,eAAe;IAC5BG,aAAa,EAAE,KAAK;IACpBC,uBAAuB,EAAE,IAAI;IAC7BC,0BAA0B,EAAE,IAAM,IAAI;CACvC,CAAC"}
@@ -1,12 +1,12 @@
1
- import type { YAXisComponentOption } from 'echarts';
1
+ import type { XAXisComponentOption, YAXisComponentOption } from 'echarts';
2
2
  import { UnitOptions } from '@perses-dev/core';
3
- export declare function getYAxes(yAxis?: YAXisComponentOption, unit?: UnitOptions): ({
3
+ export declare function getFormattedAxis(axis?: YAXisComponentOption | XAXisComponentOption, unit?: UnitOptions): ({
4
4
  type: string;
5
5
  boundaryGap: (string | number)[];
6
6
  axisLabel: {
7
7
  formatter: (value: number) => string;
8
8
  };
9
- } & (YAXisComponentOption | undefined))[];
9
+ } & (YAXisComponentOption | XAXisComponentOption | undefined))[];
10
10
  /**
11
11
  * Calculate date range, used as a fallback when xAxis time range not passed as prop
12
12
  */
@@ -1 +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"}
1
+ {"version":3,"file":"axis.d.ts","sourceRoot":"","sources":["../../src/utils/axis.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAe,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAK5D,wBAAgB,gBAAgB,CAAC,IAAI,CAAC,EAAE,oBAAoB,GAAG,oBAAoB,EAAE,IAAI,CAAC,EAAE,WAAW;;;;2BAM9E,MAAM;;iEAM9B;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,UAM1C"}
@@ -13,10 +13,10 @@
13
13
  import merge from 'lodash/merge';
14
14
  import { formatValue } from '@perses-dev/core';
15
15
  /*
16
- * Populate yAxis properties, returns an Array since multiple y axes will be supported in the future
17
- */ export function getYAxes(yAxis, unit) {
16
+ * Populate yAxis or xAxis properties, returns an Array since multiple axes will be supported in the future
17
+ */ export function getFormattedAxis(axis, unit) {
18
18
  // TODO: support alternate yAxis that shows on right side
19
- const Y_AXIS_DEFAULT = {
19
+ const AXIS_DEFAULT = {
20
20
  type: 'value',
21
21
  boundaryGap: [
22
22
  0,
@@ -29,7 +29,7 @@ import { formatValue } from '@perses-dev/core';
29
29
  }
30
30
  };
31
31
  return [
32
- merge(Y_AXIS_DEFAULT, yAxis)
32
+ merge(AXIS_DEFAULT, axis)
33
33
  ];
34
34
  }
35
35
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/axis.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 merge from 'lodash/merge';\nimport type { YAXisComponentOption } from 'echarts';\nimport { formatValue, UnitOptions } from '@perses-dev/core';\n\n/*\n * Populate yAxis properties, returns an Array since multiple y axes will be supported in the future\n */\nexport function getYAxes(yAxis?: YAXisComponentOption, unit?: UnitOptions) {\n // TODO: support alternate yAxis that shows on right side\n const Y_AXIS_DEFAULT = {\n type: 'value',\n boundaryGap: [0, '10%'],\n axisLabel: {\n formatter: (value: number) => {\n return formatValue(value, unit);\n },\n },\n };\n return [merge(Y_AXIS_DEFAULT, yAxis)];\n}\n\n/**\n * Calculate date range, used as a fallback when xAxis time range not passed as prop\n */\nexport function getDateRange(data: number[]) {\n const defaultRange = 3600000; // hour in ms\n if (data.length === 0) return defaultRange;\n const lastDatum = data[data.length - 1];\n if (data[0] === undefined || lastDatum === undefined) return defaultRange;\n return lastDatum - data[0];\n}\n"],"names":["merge","formatValue","getYAxes","yAxis","unit","Y_AXIS_DEFAULT","type","boundaryGap","axisLabel","formatter","value","getDateRange","data","defaultRange","length","lastDatum","undefined"],"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,OAAOA,KAAK,MAAM,cAAc,CAAC;AAEjC,SAASC,WAAW,QAAqB,kBAAkB,CAAC;AAE5D;;CAEC,GACD,OAAO,SAASC,QAAQ,CAACC,KAA4B,EAAEC,IAAkB,EAAE;IACzE,yDAAyD;IACzD,MAAMC,cAAc,GAAG;QACrBC,IAAI,EAAE,OAAO;QACbC,WAAW,EAAE;AAAC,aAAC;YAAE,KAAK;SAAC;QACvBC,SAAS,EAAE;YACTC,SAAS,EAAE,CAACC,KAAa,GAAK;gBAC5B,OAAOT,WAAW,CAACS,KAAK,EAAEN,IAAI,CAAC,CAAC;YAClC,CAAC;SACF;KACF,AAAC;IACF,OAAO;QAACJ,KAAK,CAACK,cAAc,EAAEF,KAAK,CAAC;KAAC,CAAC;AACxC,CAAC;AAED;;CAEC,GACD,OAAO,SAASQ,YAAY,CAACC,IAAc,EAAE;IAC3C,MAAMC,YAAY,GAAG,OAAO,AAAC,EAAC,aAAa;IAC3C,IAAID,IAAI,CAACE,MAAM,KAAK,CAAC,EAAE,OAAOD,YAAY,CAAC;IAC3C,MAAME,SAAS,GAAGH,IAAI,CAACA,IAAI,CAACE,MAAM,GAAG,CAAC,CAAC,AAAC;IACxC,IAAIF,IAAI,CAAC,CAAC,CAAC,KAAKI,SAAS,IAAID,SAAS,KAAKC,SAAS,EAAE,OAAOH,YAAY,CAAC;IAC1E,OAAOE,SAAS,GAAGH,IAAI,CAAC,CAAC,CAAC,CAAC;AAC7B,CAAC"}
1
+ {"version":3,"sources":["../../src/utils/axis.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 merge from 'lodash/merge';\nimport type { XAXisComponentOption, YAXisComponentOption } from 'echarts';\nimport { formatValue, UnitOptions } from '@perses-dev/core';\n\n/*\n * Populate yAxis or xAxis properties, returns an Array since multiple axes will be supported in the future\n */\nexport function getFormattedAxis(axis?: YAXisComponentOption | XAXisComponentOption, unit?: UnitOptions) {\n // TODO: support alternate yAxis that shows on right side\n const AXIS_DEFAULT = {\n type: 'value',\n boundaryGap: [0, '10%'],\n axisLabel: {\n formatter: (value: number) => {\n return formatValue(value, unit);\n },\n },\n };\n return [merge(AXIS_DEFAULT, axis)];\n}\n\n/**\n * Calculate date range, used as a fallback when xAxis time range not passed as prop\n */\nexport function getDateRange(data: number[]) {\n const defaultRange = 3600000; // hour in ms\n if (data.length === 0) return defaultRange;\n const lastDatum = data[data.length - 1];\n if (data[0] === undefined || lastDatum === undefined) return defaultRange;\n return lastDatum - data[0];\n}\n"],"names":["merge","formatValue","getFormattedAxis","axis","unit","AXIS_DEFAULT","type","boundaryGap","axisLabel","formatter","value","getDateRange","data","defaultRange","length","lastDatum","undefined"],"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,OAAOA,KAAK,MAAM,cAAc,CAAC;AAEjC,SAASC,WAAW,QAAqB,kBAAkB,CAAC;AAE5D;;CAEC,GACD,OAAO,SAASC,gBAAgB,CAACC,IAAkD,EAAEC,IAAkB,EAAE;IACvG,yDAAyD;IACzD,MAAMC,YAAY,GAAG;QACnBC,IAAI,EAAE,OAAO;QACbC,WAAW,EAAE;AAAC,aAAC;YAAE,KAAK;SAAC;QACvBC,SAAS,EAAE;YACTC,SAAS,EAAE,CAACC,KAAa,GAAK;gBAC5B,OAAOT,WAAW,CAACS,KAAK,EAAEN,IAAI,CAAC,CAAC;YAClC,CAAC;SACF;KACF,AAAC;IACF,OAAO;QAACJ,KAAK,CAACK,YAAY,EAAEF,IAAI,CAAC;KAAC,CAAC;AACrC,CAAC;AAED;;CAEC,GACD,OAAO,SAASQ,YAAY,CAACC,IAAc,EAAE;IAC3C,MAAMC,YAAY,GAAG,OAAO,AAAC,EAAC,aAAa;IAC3C,IAAID,IAAI,CAACE,MAAM,KAAK,CAAC,EAAE,OAAOD,YAAY,CAAC;IAC3C,MAAME,SAAS,GAAGH,IAAI,CAACA,IAAI,CAACE,MAAM,GAAG,CAAC,CAAC,AAAC;IACxC,IAAIF,IAAI,CAAC,CAAC,CAAC,KAAKI,SAAS,IAAID,SAAS,KAAKC,SAAS,EAAE,OAAOH,YAAY,CAAC;IAC1E,OAAOE,SAAS,GAAGH,IAAI,CAAC,CAAC,CAAC,CAAC;AAC7B,CAAC"}