@perses-dev/components 0.38.0 → 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 (87) hide show
  1. package/dist/BarChart/BarChart.d.ts.map +1 -1
  2. package/dist/BarChart/BarChart.js +9 -3
  3. package/dist/BarChart/BarChart.js.map +1 -1
  4. package/dist/GaugeChart/GaugeChart.js +1 -1
  5. package/dist/GaugeChart/GaugeChart.js.map +1 -1
  6. package/dist/LineChart/LineChart.d.ts.map +1 -1
  7. package/dist/LineChart/LineChart.js +7 -8
  8. package/dist/LineChart/LineChart.js.map +1 -1
  9. package/dist/StatChart/StatChart.js +1 -1
  10. package/dist/StatChart/StatChart.js.map +1 -1
  11. package/dist/StatChart/calculateFontSize.js +3 -3
  12. package/dist/StatChart/calculateFontSize.js.map +1 -1
  13. package/dist/ThresholdsEditor/ThresholdColorPicker.js +1 -1
  14. package/dist/ThresholdsEditor/ThresholdColorPicker.js.map +1 -1
  15. package/dist/ThresholdsEditor/ThresholdsEditor.d.ts.map +1 -1
  16. package/dist/ThresholdsEditor/ThresholdsEditor.js +3 -2
  17. package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
  18. package/dist/TimeChart/TimeChart.d.ts +1 -1
  19. package/dist/TimeChart/TimeChart.d.ts.map +1 -1
  20. package/dist/TimeChart/TimeChart.js +100 -53
  21. package/dist/TimeChart/TimeChart.js.map +1 -1
  22. package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts +1 -0
  23. package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts.map +1 -1
  24. package/dist/TimeSeriesTooltip/LineChartTooltip.js +3 -2
  25. package/dist/TimeSeriesTooltip/LineChartTooltip.js.map +1 -1
  26. package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts +1 -0
  27. package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts.map +1 -1
  28. package/dist/TimeSeriesTooltip/TimeChartTooltip.js +3 -2
  29. package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
  30. package/dist/TimeSeriesTooltip/TooltipHeader.d.ts +1 -0
  31. package/dist/TimeSeriesTooltip/TooltipHeader.d.ts.map +1 -1
  32. package/dist/TimeSeriesTooltip/TooltipHeader.js +5 -5
  33. package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -1
  34. package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -1
  35. package/dist/TimeSeriesTooltip/nearby-series.js +13 -17
  36. package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
  37. package/dist/TimeSeriesTooltip/tooltip-model.d.ts +4 -0
  38. package/dist/TimeSeriesTooltip/tooltip-model.d.ts.map +1 -1
  39. package/dist/TimeSeriesTooltip/tooltip-model.js +6 -0
  40. package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
  41. package/dist/cjs/BarChart/BarChart.js +10 -4
  42. package/dist/cjs/GaugeChart/GaugeChart.js +2 -2
  43. package/dist/cjs/LineChart/LineChart.js +6 -7
  44. package/dist/cjs/StatChart/StatChart.js +2 -2
  45. package/dist/cjs/StatChart/calculateFontSize.js +3 -3
  46. package/dist/cjs/ThresholdsEditor/ThresholdColorPicker.js +2 -2
  47. package/dist/cjs/ThresholdsEditor/ThresholdsEditor.js +3 -2
  48. package/dist/cjs/TimeChart/TimeChart.js +97 -50
  49. package/dist/cjs/TimeSeriesTooltip/LineChartTooltip.js +3 -2
  50. package/dist/cjs/TimeSeriesTooltip/TimeChartTooltip.js +3 -2
  51. package/dist/cjs/TimeSeriesTooltip/TooltipHeader.js +4 -4
  52. package/dist/cjs/TimeSeriesTooltip/nearby-series.js +12 -16
  53. package/dist/cjs/TimeSeriesTooltip/tooltip-model.js +10 -1
  54. package/dist/cjs/context/{ChartsThemeProvider.js → ChartsProvider.js} +24 -5
  55. package/dist/cjs/context/index.js +30 -0
  56. package/dist/cjs/index.js +1 -3
  57. package/dist/cjs/test-utils/theme.js +32 -19
  58. package/dist/cjs/utils/axis.js +4 -4
  59. package/dist/cjs/utils/chart-actions.js +39 -1
  60. package/dist/context/ChartsProvider.d.ts +19 -0
  61. package/dist/context/ChartsProvider.d.ts.map +1 -0
  62. package/dist/context/{ChartsThemeProvider.js → ChartsProvider.js} +24 -6
  63. package/dist/context/ChartsProvider.js.map +1 -0
  64. package/dist/context/index.d.ts +4 -0
  65. package/dist/context/index.d.ts.map +1 -0
  66. package/dist/context/index.js +17 -0
  67. package/dist/context/index.js.map +1 -0
  68. package/dist/index.d.ts +1 -3
  69. package/dist/index.d.ts.map +1 -1
  70. package/dist/index.js +1 -3
  71. package/dist/index.js.map +1 -1
  72. package/dist/test-utils/theme.d.ts +2 -0
  73. package/dist/test-utils/theme.d.ts.map +1 -1
  74. package/dist/test-utils/theme.js +23 -16
  75. package/dist/test-utils/theme.js.map +1 -1
  76. package/dist/utils/axis.d.ts +3 -3
  77. package/dist/utils/axis.d.ts.map +1 -1
  78. package/dist/utils/axis.js +4 -4
  79. package/dist/utils/axis.js.map +1 -1
  80. package/dist/utils/chart-actions.d.ts +5 -1
  81. package/dist/utils/chart-actions.d.ts.map +1 -1
  82. package/dist/utils/chart-actions.js +42 -0
  83. package/dist/utils/chart-actions.js.map +1 -1
  84. package/package.json +3 -3
  85. package/dist/context/ChartsThemeProvider.d.ts +0 -10
  86. package/dist/context/ChartsThemeProvider.d.ts.map +0 -1
  87. package/dist/context/ChartsThemeProvider.js.map +0 -1
@@ -21,7 +21,7 @@ function _export(target, all) {
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- getYAxes: ()=>getYAxes,
24
+ getFormattedAxis: ()=>getFormattedAxis,
25
25
  getDateRange: ()=>getDateRange
26
26
  });
27
27
  const _merge = /*#__PURE__*/ _interopRequireDefault(require("lodash/merge"));
@@ -31,9 +31,9 @@ function _interopRequireDefault(obj) {
31
31
  default: obj
32
32
  };
33
33
  }
34
- function getYAxes(yAxis, unit) {
34
+ function getFormattedAxis(axis, unit) {
35
35
  // TODO: support alternate yAxis that shows on right side
36
- const Y_AXIS_DEFAULT = {
36
+ const AXIS_DEFAULT = {
37
37
  type: 'value',
38
38
  boundaryGap: [
39
39
  0,
@@ -46,7 +46,7 @@ function getYAxes(yAxis, unit) {
46
46
  }
47
47
  };
48
48
  return [
49
- (0, _merge.default)(Y_AXIS_DEFAULT, yAxis)
49
+ (0, _merge.default)(AXIS_DEFAULT, axis)
50
50
  ];
51
51
  }
52
52
  function getDateRange(data) {
@@ -25,8 +25,12 @@ _export(exports, {
25
25
  restoreChart: ()=>restoreChart,
26
26
  clearHighlightedSeries: ()=>clearHighlightedSeries,
27
27
  getPointInGrid: ()=>getPointInGrid,
28
- batchDispatchNearbySeriesActions: ()=>batchDispatchNearbySeriesActions
28
+ batchDispatchNearbySeriesActions: ()=>batchDispatchNearbySeriesActions,
29
+ checkCrosshairPinnedStatus: ()=>checkCrosshairPinnedStatus,
30
+ getClosestTimestamp: ()=>getClosestTimestamp,
31
+ getClosestTimestampInFullDataset: ()=>getClosestTimestampInFullDataset
29
32
  });
33
+ const _model = require("../model");
30
34
  function enableDataZoom(chart) {
31
35
  const chartModel = chart['_model'];
32
36
  if (chartModel === undefined) return;
@@ -115,3 +119,37 @@ function batchDispatchNearbySeriesActions(chart, nearbySeriesIndexes, emphasized
115
119
  });
116
120
  }
117
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
+ }
@@ -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
@@ -24,9 +24,7 @@ export * from './TimeChart';
24
24
  export * from './TimeSeriesTooltip';
25
25
  export * from './UnitSelector';
26
26
  export * from './YAxisLabel';
27
- export * from './context/ChartsThemeProvider';
28
- export * from './context/TimeZoneProvider';
29
- export * from './context/SnackbarProvider';
27
+ export * from './context';
30
28
  export * from './utils';
31
29
  export * from './model';
32
30
  export * from './test-utils';
@@ -1 +1 @@
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,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AAc,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
@@ -36,9 +36,7 @@ export * from './TimeChart';
36
36
  export * from './TimeSeriesTooltip';
37
37
  export * from './UnitSelector';
38
38
  export * from './YAxisLabel';
39
- export * from './context/ChartsThemeProvider';
40
- export * from './context/TimeZoneProvider';
41
- export * from './context/SnackbarProvider';
39
+ export * from './context';
42
40
  export * from './utils';
43
41
  export * from './model';
44
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 './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/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,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,+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,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"}
@@ -1,5 +1,6 @@
1
1
  import { ECharts as EChartsInstance } from 'echarts/core';
2
- import { DatapointInfo } from '../model';
2
+ import { TimeSeries, TimeSeriesValueTuple } from '@perses-dev/core';
3
+ import { DatapointInfo, TimeChartSeriesMapping } from '../model';
3
4
  export interface ZoomEventData {
4
5
  start: number;
5
6
  end: number;
@@ -18,4 +19,7 @@ export declare function restoreChart(chart: EChartsInstance): void;
18
19
  export declare function clearHighlightedSeries(chart: EChartsInstance, totalSeries: number): void;
19
20
  export declare function getPointInGrid(cursorCoordX: number, cursorCoordY: number, chart?: EChartsInstance): number[] | null;
20
21
  export declare function batchDispatchNearbySeriesActions(chart: EChartsInstance, nearbySeriesIndexes: number[], emphasizedSeriesIndexes: number[], nonEmphasizedSeriesIndexes: number[], emphasizedDatapoints: DatapointInfo[], duplicateDatapoints: DatapointInfo[]): void;
22
+ export declare function checkCrosshairPinnedStatus(seriesMapping: TimeChartSeriesMapping): boolean;
23
+ export declare function getClosestTimestamp(timeSeriesValues?: TimeSeriesValueTuple[], cursorX?: number): number | null;
24
+ export declare function getClosestTimestampInFullDataset(data: TimeSeries[], cursorX?: number): number | null;
21
25
  //# sourceMappingURL=chart-actions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chart-actions.d.ts","sourceRoot":"","sources":["../../src/utils/chart-actions.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IAEZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,eAAe,QAapD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,eAAe,QAKlD;AAMD,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,QASjF;AAOD,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,eAAe,m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AE,sBAAsB,WAG/E;AAMD,wBAAgB,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,oBAAoB,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAgB9G;AAKD,wBAAgB,gCAAgC,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAapG"}
@@ -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
+ import { PINNED_CROSSHAIR_SERIES_NAME } from '../model';
13
14
  /**
14
15
  * Enable dataZoom without requring user to click toolbox icon.
15
16
  * https://stackoverflow.com/questions/57183297/is-there-a-way-to-use-zoom-of-type-select-without-showing-the-toolbar
@@ -114,5 +115,46 @@
114
115
  });
115
116
  }
116
117
  }
118
+ /*
119
+ * Determine whether a markLine was pushed into the final series, which means crosshair was already pinned onClick
120
+ */ export function checkCrosshairPinnedStatus(seriesMapping) {
121
+ var ref;
122
+ const isCrosshairPinned = ((ref = seriesMapping[seriesMapping.length - 1]) === null || ref === void 0 ? void 0 : ref.name) === PINNED_CROSSHAIR_SERIES_NAME;
123
+ return isCrosshairPinned;
124
+ }
125
+ /*
126
+ * Find closest timestamp to logical x coordinate returned from echartsInstance.convertFromPixel
127
+ * Used to find nearby series in time series tooltip.
128
+ */ export function getClosestTimestamp(timeSeriesValues, cursorX) {
129
+ if (timeSeriesValues === undefined || cursorX === undefined) {
130
+ return null;
131
+ }
132
+ let currentClosestTimestamp = null;
133
+ let currentClosestDistance = Infinity;
134
+ for (const [timestamp] of timeSeriesValues){
135
+ const distance = Math.abs(timestamp - cursorX);
136
+ if (distance < currentClosestDistance) {
137
+ currentClosestTimestamp = timestamp;
138
+ currentClosestDistance = distance;
139
+ }
140
+ }
141
+ return currentClosestTimestamp;
142
+ }
143
+ /*
144
+ * Find closest timestamp in full dataset, used to snap crosshair into place onClick when tooltip is pinned.
145
+ */ export function getClosestTimestampInFullDataset(data, cursorX) {
146
+ if (cursorX === undefined) {
147
+ return null;
148
+ }
149
+ const totalSeries = data.length;
150
+ let closestTimestamp = null;
151
+ for(let seriesIdx = 0; seriesIdx < totalSeries; seriesIdx++){
152
+ const currentDataset = totalSeries > 0 ? data[seriesIdx] : null;
153
+ if (currentDataset == null) break;
154
+ const currentValues = currentDataset.values;
155
+ closestTimestamp = getClosestTimestamp(currentValues, cursorX);
156
+ }
157
+ return closestTimestamp;
158
+ }
117
159
 
118
160
  //# sourceMappingURL=chart-actions.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/chart-actions.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ECharts as EChartsInstance } from 'echarts/core';\nimport { DatapointInfo } from '../model';\n\nexport interface ZoomEventData {\n start: number;\n end: number;\n // TODO: remove startIndex and endIndex once LineChart is deprecated\n startIndex?: number;\n endIndex?: number;\n}\n\n/**\n * Enable dataZoom without requring user to click toolbox icon.\n * https://stackoverflow.com/questions/57183297/is-there-a-way-to-use-zoom-of-type-select-without-showing-the-toolbar\n */\nexport function enableDataZoom(chart: EChartsInstance) {\n const chartModel = chart['_model'];\n if (chartModel === undefined) return;\n if (chartModel.option.toolbox !== undefined && chartModel.option.toolbox.length > 0) {\n // check if hidden data zoom icon is unselected (if selected it would be 'emphasis' instead of 'normal')\n if (chartModel.option.toolbox[0].feature.dataZoom.iconStatus.zoom === 'normal') {\n chart.dispatchAction({\n type: 'takeGlobalCursor',\n key: 'dataZoomSelect',\n dataZoomSelectActive: true,\n });\n }\n }\n}\n\n/**\n * Restore chart to original state before zoom or other actions were dispatched\n */\nexport function restoreChart(chart: EChartsInstance) {\n // TODO: support incremental unzoom instead of restore to original state\n chart.dispatchAction({\n type: 'restore', // https://echarts.apache.org/en/api.html#events.restore\n });\n}\n\n/*\n * Clear all highlighted series when cursor exits canvas\n * https://echarts.apache.org/en/api.html#action.downplay\n */\nexport function clearHighlightedSeries(chart: EChartsInstance, totalSeries: number) {\n if (chart.dispatchAction !== undefined) {\n for (let i = 0; i < totalSeries; i++) {\n chart.dispatchAction({\n type: 'downplay',\n seriesIndex: i,\n });\n }\n }\n}\n\n/*\n * Convert a point from pixel coordinate to logical coordinate.\n * Used to determine if cursor is over chart canvas and closest datapoint.\n * https://echarts.apache.org/en/api.html#echartsInstance.convertFromPixel\n */\nexport function getPointInGrid(cursorCoordX: number, cursorCoordY: number, chart?: EChartsInstance) {\n if (chart === undefined) {\n return null;\n }\n\n const pointInPixel = [cursorCoordX, cursorCoordY];\n if (!chart.containPixel('grid', pointInPixel)) {\n return null;\n }\n\n const pointInGrid: number[] = chart.convertFromPixel('grid', pointInPixel);\n return pointInGrid;\n}\n\n/*\n * TimeSeriesChart tooltip is built custom to support finding nearby series instead of single or all series.\n * This means ECharts actions need to be dispatched manually for series highlighting, datapoint select state, etc.\n * More info: https://echarts.apache.org/en/api.html#action\n */\nexport function batchDispatchNearbySeriesActions(\n chart: EChartsInstance,\n nearbySeriesIndexes: number[],\n emphasizedSeriesIndexes: number[],\n nonEmphasizedSeriesIndexes: number[],\n emphasizedDatapoints: DatapointInfo[],\n duplicateDatapoints: DatapointInfo[]\n) {\n // Accounts for multiple series that are rendered direct on top of eachother.\n // Only applies select state to the datapoint that is visible to avoid color mismatch.\n const lastEmphasizedDatapoint =\n duplicateDatapoints.length > 0\n ? duplicateDatapoints[duplicateDatapoints.length - 1]\n : emphasizedDatapoints[emphasizedDatapoints.length - 1];\n if (lastEmphasizedDatapoint !== undefined) {\n // Corresponds to select options inside getTimeSeries util.\n // https://echarts.apache.org/en/option.html#series-line.select.itemStyle\n chart.dispatchAction({\n type: 'select',\n seriesIndex: lastEmphasizedDatapoint.seriesIndex,\n dataIndex: lastEmphasizedDatapoint.dataIndex,\n // Shared crosshair should not emphasize datapoints on adjacent charts.\n escapeConnect: true, // TODO: try to remove escapeConnect and match by seriesName for cross panel correlation\n });\n }\n\n // Clears emphasis state of all lines that are not emphasized.\n // Emphasized is a subset of just the nearby series that are closest to cursor.\n chart.dispatchAction({\n type: 'downplay',\n seriesIndex: nonEmphasizedSeriesIndexes,\n });\n\n // https://echarts.apache.org/en/api.html#action.highlight\n if (emphasizedSeriesIndexes.length > 0) {\n // Fadeout opacity of all series not closest to cursor.\n chart.dispatchAction({\n type: 'highlight',\n seriesIndex: emphasizedSeriesIndexes,\n notBlur: false, // ensure blur IS triggered, this is default but setting so it is explicit\n escapeConnect: true, // shared crosshair should not emphasize series on adjacent charts\n });\n } else {\n // When no emphasized series with bold text, notBlur allows opacity fadeout to not trigger.\n chart.dispatchAction({\n type: 'highlight',\n seriesIndex: nearbySeriesIndexes,\n notBlur: true, // do not trigger blur state when cursor is not immediately close to any series\n escapeConnect: true, // shared crosshair should not emphasize series on adjacent charts\n });\n\n // Clears selected datapoints since no bold series in tooltip, restore does not impact highlighting\n chart.dispatchAction({\n type: 'toggleSelect', // https://echarts.apache.org/en/api.html#action.toggleSelect\n });\n }\n}\n"],"names":["enableDataZoom","chart","chartModel","undefined","option","toolbox","length","feature","dataZoom","iconStatus","zoom","dispatchAction","type","key","dataZoomSelectActive","restoreChart","clearHighlightedSeries","totalSeries","i","seriesIndex","getPointInGrid","cursorCoordX","cursorCoordY","pointInPixel","containPixel","pointInGrid","convertFromPixel","batchDispatchNearbySeriesActions","nearbySeriesIndexes","emphasizedSeriesIndexes","nonEmphasizedSeriesIndexes","emphasizedDatapoints","duplicateDatapoints","lastEmphasizedDatapoint","dataIndex","escapeConnect","notBlur"],"mappings":"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QAChBO,WAAW,EAAEW,0BAA0B;KACxC,CAAC,CAAC;IAEH,0DAA0D;IAC1D,IAAID,uBAAuB,CAACvB,MAAM,GAAG,CAAC,EAAE;QACtC,uDAAuD;QACvDL,KAAK,CAACU,cAAc,CAAC;YACnBC,IAAI,EAAE,WAAW;YACjBO,WAAW,EAAEU,uBAAuB;YACpCO,OAAO,EAAE,KAAK;YACdD,aAAa,EAAE,IAAI;SACpB,CAAC,CAAC;IACL,OAAO;QACL,2FAA2F;QAC3FlC,KAAK,CAACU,cAAc,CAAC;YACnBC,IAAI,EAAE,WAAW;YACjBO,WAAW,EAAES,mBAAmB;YAChCQ,OAAO,EAAE,IAAI;YACbD,aAAa,EAAE,IAAI;SACpB,CAAC,CAAC;QAEH,mGAAmG;QACnGlC,KAAK,CAACU,cAAc,CAAC;YACnBC,IAAI,EAAE,cAAc;SACrB,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
1
+ {"version":3,"sources":["../../src/utils/chart-actions.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ECharts as EChartsInstance } from 'echarts/core';\nimport { TimeSeries, TimeSeriesValueTuple } from '@perses-dev/core';\nimport { DatapointInfo, PINNED_CROSSHAIR_SERIES_NAME, TimeChartSeriesMapping } from '../model';\n\nexport interface ZoomEventData {\n start: number;\n end: number;\n // TODO: remove startIndex and endIndex once LineChart is deprecated\n startIndex?: number;\n endIndex?: number;\n}\n\n/**\n * Enable dataZoom without requring user to click toolbox icon.\n * https://stackoverflow.com/questions/57183297/is-there-a-way-to-use-zoom-of-type-select-without-showing-the-toolbar\n */\nexport function enableDataZoom(chart: EChartsInstance) {\n const chartModel = chart['_model'];\n if (chartModel === undefined) return;\n if (chartModel.option.toolbox !== undefined && chartModel.option.toolbox.length > 0) {\n // check if hidden data zoom icon is unselected (if selected it would be 'emphasis' instead of 'normal')\n if (chartModel.option.toolbox[0].feature.dataZoom.iconStatus.zoom === 'normal') {\n chart.dispatchAction({\n type: 'takeGlobalCursor',\n key: 'dataZoomSelect',\n dataZoomSelectActive: true,\n });\n }\n }\n}\n\n/**\n * Restore chart to original state before zoom or other actions were dispatched\n */\nexport function restoreChart(chart: EChartsInstance) {\n // TODO: support incremental unzoom instead of restore to original state\n chart.dispatchAction({\n type: 'restore', // https://echarts.apache.org/en/api.html#events.restore\n });\n}\n\n/*\n * Clear all highlighted series when cursor exits canvas\n * https://echarts.apache.org/en/api.html#action.downplay\n */\nexport function clearHighlightedSeries(chart: EChartsInstance, totalSeries: number) {\n if (chart.dispatchAction !== undefined) {\n for (let i = 0; i < totalSeries; i++) {\n chart.dispatchAction({\n type: 'downplay',\n seriesIndex: i,\n });\n }\n }\n}\n\n/*\n * Convert a point from pixel coordinate to logical coordinate.\n * Used to determine if cursor is over chart canvas and closest datapoint.\n * https://echarts.apache.org/en/api.html#echartsInstance.convertFromPixel\n */\nexport function getPointInGrid(cursorCoordX: number, cursorCoordY: number, chart?: EChartsInstance) {\n if (chart === undefined) {\n return null;\n }\n\n const pointInPixel = [cursorCoordX, cursorCoordY];\n if (!chart.containPixel('grid', pointInPixel)) {\n return null;\n }\n\n const pointInGrid: number[] = chart.convertFromPixel('grid', pointInPixel);\n return pointInGrid;\n}\n\n/*\n * TimeSeriesChart tooltip is built custom to support finding nearby series instead of single or all series.\n * This means ECharts actions need to be dispatched manually for series highlighting, datapoint select state, etc.\n * More info: https://echarts.apache.org/en/api.html#action\n */\nexport function batchDispatchNearbySeriesActions(\n chart: EChartsInstance,\n nearbySeriesIndexes: number[],\n emphasizedSeriesIndexes: number[],\n nonEmphasizedSeriesIndexes: number[],\n emphasizedDatapoints: DatapointInfo[],\n duplicateDatapoints: DatapointInfo[]\n) {\n // Accounts for multiple series that are rendered direct on top of eachother.\n // Only applies select state to the datapoint that is visible to avoid color mismatch.\n const lastEmphasizedDatapoint =\n duplicateDatapoints.length > 0\n ? duplicateDatapoints[duplicateDatapoints.length - 1]\n : emphasizedDatapoints[emphasizedDatapoints.length - 1];\n if (lastEmphasizedDatapoint !== undefined) {\n // Corresponds to select options inside getTimeSeries util.\n // https://echarts.apache.org/en/option.html#series-line.select.itemStyle\n chart.dispatchAction({\n type: 'select',\n seriesIndex: lastEmphasizedDatapoint.seriesIndex,\n dataIndex: lastEmphasizedDatapoint.dataIndex,\n // Shared crosshair should not emphasize datapoints on adjacent charts.\n escapeConnect: true, // TODO: try to remove escapeConnect and match by seriesName for cross panel correlation\n });\n }\n\n // Clears emphasis state of all lines that are not emphasized.\n // Emphasized is a subset of just the nearby series that are closest to cursor.\n chart.dispatchAction({\n type: 'downplay',\n seriesIndex: nonEmphasizedSeriesIndexes,\n });\n\n // https://echarts.apache.org/en/api.html#action.highlight\n if (emphasizedSeriesIndexes.length > 0) {\n // Fadeout opacity of all series not closest to cursor.\n chart.dispatchAction({\n type: 'highlight',\n seriesIndex: emphasizedSeriesIndexes,\n notBlur: false, // ensure blur IS triggered, this is default but setting so it is explicit\n escapeConnect: true, // shared crosshair should not emphasize series on adjacent charts\n });\n } else {\n // When no emphasized series with bold text, notBlur allows opacity fadeout to not trigger.\n chart.dispatchAction({\n type: 'highlight',\n seriesIndex: nearbySeriesIndexes,\n notBlur: true, // do not trigger blur state when cursor is not immediately close to any series\n escapeConnect: true, // shared crosshair should not emphasize series on adjacent charts\n });\n\n // Clears selected datapoints since no bold series in tooltip, restore does not impact highlighting\n chart.dispatchAction({\n type: 'toggleSelect', // https://echarts.apache.org/en/api.html#action.toggleSelect\n });\n }\n}\n\n/*\n * Determine whether a markLine was pushed into the final series, which means crosshair was already pinned onClick\n */\nexport function checkCrosshairPinnedStatus(seriesMapping: TimeChartSeriesMapping) {\n const isCrosshairPinned = seriesMapping[seriesMapping.length - 1]?.name === PINNED_CROSSHAIR_SERIES_NAME;\n return isCrosshairPinned;\n}\n\n/*\n * Find closest timestamp to logical x coordinate returned from echartsInstance.convertFromPixel\n * Used to find nearby series in time series tooltip.\n */\nexport function getClosestTimestamp(timeSeriesValues?: TimeSeriesValueTuple[], cursorX?: number): number | null {\n if (timeSeriesValues === undefined || cursorX === undefined) {\n return null;\n }\n\n let currentClosestTimestamp: number | null = null;\n let currentClosestDistance = Infinity;\n\n for (const [timestamp] of timeSeriesValues) {\n const distance = Math.abs(timestamp - cursorX);\n if (distance < currentClosestDistance) {\n currentClosestTimestamp = timestamp;\n currentClosestDistance = distance;\n }\n }\n return currentClosestTimestamp;\n}\n\n/*\n * Find closest timestamp in full dataset, used to snap crosshair into place onClick when tooltip is pinned.\n */\nexport function getClosestTimestampInFullDataset(data: TimeSeries[], cursorX?: number): number | null {\n if (cursorX === undefined) {\n return null;\n }\n const totalSeries = data.length;\n let closestTimestamp = null;\n for (let seriesIdx = 0; seriesIdx < totalSeries; seriesIdx++) {\n const currentDataset = totalSeries > 0 ? data[seriesIdx] : null;\n if (currentDataset == null) break;\n const currentValues: TimeSeriesValueTuple[] = currentDataset.values;\n closestTimestamp = getClosestTimestamp(currentValues, cursorX);\n }\n return closestTimestamp;\n}\n"],"names":["PINNED_CROSSHAIR_SERIES_NAME","enableDataZoom","chart","chartModel","undefined","option","toolbox","length","feature","dataZoom","iconStatus","zoom","dispatchAction","type","key","dataZoomSelectActive","restoreChart","clearHighlightedSeries","totalSeries","i","seriesIndex","getPointInGrid","cursorCoordX","cursorCoordY","pointInPixel","containPixel","pointInGrid","convertFromPixel","batchDispatchNearbySeriesActions","nearbySeriesIndexes","emphasizedSeriesIndexes","nonEmphasizedSeriesIndexes","emphasizedDatapoints","duplicateDatapoints","lastEmphasizedDatapoint","dataIndex","escapeConnect","notBlur","checkCrosshairPinnedStatus","seriesMapping","isCrosshairPinned","name","getClosestTimestamp","timeSeriesValues","cursorX","currentClosestTimestamp","currentClosestDistance","Infinity","timestamp","distance","Math","abs","getClosestTimestampInFullDataset","data","closestTimestamp","seriesIdx","currentDataset","currentValues","values"],"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,SAAwBA,4BAA4B,QAAgC,UAAU,CAAC;AAU/F;;;CAGC,GACD,OAAO,SAASC,cAAc,CAACC,KAAsB,EAAE;IACrD,MAAMC,UAAU,GAAGD,KAAK,CAAC,QAAQ,CAAC,AAAC;IACnC,IAAIC,UAAU,KAAKC,SAAS,EAAE,OAAO;IACrC,IAAID,UAAU,CAACE,MAAM,CAACC,OAAO,KAAKF,SAAS,IAAID,UAAU,CAACE,MAAM,CAACC,OAAO,CAACC,MAAM,GAAG,CAAC,EAAE;QACnF,wGAAwG;QACxG,IAAIJ,UAAU,CAACE,MAAM,CAACC,OAAO,CAAC,CAAC,CAAC,CAACE,OAAO,CAACC,QAAQ,CAACC,UAAU,CAACC,IAAI,KAAK,QAAQ,EAAE;YAC9ET,KAAK,CAACU,cAAc,CAAC;gBACnBC,IAAI,EAAE,kBAAkB;gBACxBC,GAAG,EAAE,gBAAgB;gBACrBC,oBAAoB,EAAE,IAAI;aAC3B,CAAC,CAAC;QACL,CAAC;IACH,CAAC;AACH,CAAC;AAED;;CAEC,GACD,OAAO,SAASC,YAAY,CAACd,KAAsB,EAAE;IACnD,wEAAwE;IACxEA,KAAK,CAACU,cAAc,CAAC;QACnBC,IAAI,EAAE,SAAS;KAChB,CAAC,CAAC;AACL,CAAC;AAED;;;CAGC,GACD,OAAO,SAASI,sBAAsB,CAACf,KAAsB,EAAEgB,WAAmB,EAAE;IAClF,IAAIhB,KAAK,CAACU,cAAc,KAAKR,SAA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S,EAAE;QAC3D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAIyC,uBAAuB,GAAkB,IAAI,AAAC;IAClD,IAAIC,sBAAsB,GAAGC,QAAQ,AAAC;IAEtC,KAAK,MAAM,CAACC,SAAS,CAAC,IAAIL,gBAAgB,CAAE;QAC1C,MAAMM,QAAQ,GAAGC,IAAI,CAACC,GAAG,CAACH,SAAS,GAAGJ,OAAO,CAAC,AAAC;QAC/C,IAAIK,QAAQ,GAAGH,sBAAsB,EAAE;YACrCD,uBAAuB,GAAGG,SAAS,CAAC;YACpCF,sBAAsB,GAAGG,QAAQ,CAAC;QACpC,CAAC;IACH,CAAC;IACD,OAAOJ,uBAAuB,CAAC;AACjC,CAAC;AAED;;CAEC,GACD,OAAO,SAASO,gCAAgC,CAACC,IAAkB,EAAET,OAAgB,EAAiB;IACpG,IAAIA,OAAO,KAAKxC,SAAS,EAAE;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAMc,WAAW,GAAGmC,IAAI,CAAC9C,MAAM,AAAC;IAChC,IAAI+C,gBAAgB,GAAG,IAAI,AAAC;IAC5B,IAAK,IAAIC,SAAS,GAAG,CAAC,EAAEA,SAAS,GAAGrC,WAAW,EAAEqC,SAAS,EAAE,CAAE;QAC5D,MAAMC,cAAc,GAAGtC,WAAW,GAAG,CAAC,GAAGmC,IAAI,CAACE,SAAS,CAAC,GAAG,IAAI,AAAC;QAChE,IAAIC,cAAc,IAAI,IAAI,EAAE,MAAM;QAClC,MAAMC,aAAa,GAA2BD,cAAc,CAACE,MAAM,AAAC;QACpEJ,gBAAgB,GAAGZ,mBAAmB,CAACe,aAAa,EAAEb,OAAO,CAAC,CAAC;IACjE,CAAC;IACD,OAAOU,gBAAgB,CAAC;AAC1B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/components",
3
- "version": "0.38.0",
3
+ "version": "0.39.0",
4
4
  "description": "Common UI components used across Perses features",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/perses/perses/blob/main/README.md",
@@ -36,7 +36,7 @@
36
36
  "@codemirror/lang-json": "^6.0.1",
37
37
  "@fontsource/lato": "^4.5.10",
38
38
  "@mui/x-date-pickers": "^5.0.0-beta.1",
39
- "@perses-dev/core": "0.38.0",
39
+ "@perses-dev/core": "0.39.0",
40
40
  "@tanstack/react-table": "^8.9.1",
41
41
  "@uiw/react-codemirror": "^4.19.1",
42
42
  "date-fns": "^2.28.0",
@@ -50,7 +50,7 @@
50
50
  "react-virtuoso": "^4.3.6"
51
51
  },
52
52
  "devDependencies": {
53
- "@perses-dev/storybook": "0.38.0"
53
+ "@perses-dev/storybook": "0.39.0"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "@mui/material": "^5.10.0",
@@ -1,10 +0,0 @@
1
- import React from 'react';
2
- import { PersesChartsTheme } from '../model';
3
- export interface ChartsThemeProviderProps {
4
- chartsTheme?: PersesChartsTheme;
5
- children?: React.ReactNode;
6
- }
7
- export declare function ChartsThemeProvider(props: ChartsThemeProviderProps): JSX.Element;
8
- export declare const ChartsThemeContext: React.Context<PersesChartsTheme | undefined>;
9
- export declare function useChartsTheme(): PersesChartsTheme;
10
- //# sourceMappingURL=ChartsThemeProvider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ChartsThemeProvider.d.ts","sourceRoot":"","sources":["../../src/context/ChartsThemeProvider.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAoC,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,MAAM,WAAW,wBAAwB;IACvC,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,eAGlE;AAED,eAAO,MAAM,kBAAkB,8CAA0D,CAAC;AAE1F,wBAAgB,cAAc,IAAI,iBAAiB,CAMlD"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/context/ChartsThemeProvider.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 } from 'react';\nimport { PersesChartsTheme } from '../model';\n\nexport interface ChartsThemeProviderProps {\n chartsTheme?: PersesChartsTheme;\n children?: React.ReactNode;\n}\n\nexport function ChartsThemeProvider(props: ChartsThemeProviderProps) {\n const { children, chartsTheme } = props;\n return <ChartsThemeContext.Provider value={chartsTheme}>{children}</ChartsThemeContext.Provider>;\n}\n\nexport const ChartsThemeContext = createContext<PersesChartsTheme | undefined>(undefined);\n\nexport function useChartsTheme(): PersesChartsTheme {\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"],"names":["React","createContext","useContext","ChartsThemeProvider","props","children","chartsTheme","ChartsThemeContext","Provider","value","undefined","useChartsTheme","ctx","Error"],"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,QAAQ,OAAO,CAAC;AAQzD,OAAO,SAASC,mBAAmB,CAACC,KAA+B,EAAE;IACnE,MAAM,EAAEC,QAAQ,CAAA,EAAEC,WAAW,CAAA,EAAE,GAAGF,KAAK,AAAC;IACxC,qBAAO,KAACG,kBAAkB,CAACC,QAAQ;QAACC,KAAK,EAAEH,WAAW;kBAAGD,QAAQ;MAA+B,CAAC;AACnG,CAAC;AAED,OAAO,MAAME,kBAAkB,iBAAGN,aAAa,CAAgCS,SAAS,CAAC,CAAC;AAE1F,OAAO,SAASC,cAAc,GAAsB;IAClD,MAAMC,GAAG,GAAGV,UAAU,CAACK,kBAAkB,CAAC,AAAC;IAC3C,IAAIK,GAAG,KAAKF,SAAS,EAAE;QACrB,MAAM,IAAIG,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IACD,OAAOD,GAAG,CAAC;AACb,CAAC"}