@perses-dev/components 0.0.0-snapshot-datasource-browser-test-28cbb71 → 0.0.0-snapshot-test-internal-dep-dd238ac

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 (164) hide show
  1. package/dist/ColorPicker/ColorPicker.d.ts +12 -0
  2. package/dist/ColorPicker/ColorPicker.d.ts.map +1 -0
  3. package/dist/ColorPicker/ColorPicker.js +78 -0
  4. package/dist/ColorPicker/ColorPicker.js.map +1 -0
  5. package/dist/ColorPicker/index.d.ts +2 -0
  6. package/dist/ColorPicker/index.d.ts.map +1 -0
  7. package/dist/ColorPicker/index.js +15 -0
  8. package/dist/ColorPicker/index.js.map +1 -0
  9. package/dist/{EChart.d.ts → EChart/EChart.d.ts} +3 -3
  10. package/dist/EChart/EChart.d.ts.map +1 -0
  11. package/dist/EChart/EChart.js.map +1 -0
  12. package/dist/EChart/index.d.ts +2 -0
  13. package/dist/EChart/index.d.ts.map +1 -0
  14. package/dist/EChart/index.js +15 -0
  15. package/dist/EChart/index.js.map +1 -0
  16. package/dist/GaugeChart/GaugeChart.d.ts +1 -2
  17. package/dist/GaugeChart/GaugeChart.d.ts.map +1 -1
  18. package/dist/GaugeChart/GaugeChart.js.map +1 -1
  19. package/dist/Legend/Legend.js +6 -9
  20. package/dist/Legend/Legend.js.map +1 -1
  21. package/dist/LineChart/LineChart.d.ts +4 -2
  22. package/dist/LineChart/LineChart.d.ts.map +1 -1
  23. package/dist/LineChart/LineChart.js +1 -1
  24. package/dist/LineChart/LineChart.js.map +1 -1
  25. package/dist/OptionsEditorLayout/OptionsEditorControl.js +1 -1
  26. package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
  27. package/dist/OptionsEditorLayout/OptionsEditorGroup.d.ts +3 -2
  28. package/dist/OptionsEditorLayout/OptionsEditorGroup.d.ts.map +1 -1
  29. package/dist/OptionsEditorLayout/OptionsEditorGroup.js +17 -5
  30. package/dist/OptionsEditorLayout/OptionsEditorGroup.js.map +1 -1
  31. package/dist/StatChart/StatChart.d.ts +1 -3
  32. package/dist/StatChart/StatChart.d.ts.map +1 -1
  33. package/dist/StatChart/StatChart.js +1 -3
  34. package/dist/StatChart/StatChart.js.map +1 -1
  35. package/dist/ThresholdsEditor/ThresholdColorPicker.d.ts +4 -0
  36. package/dist/ThresholdsEditor/ThresholdColorPicker.d.ts.map +1 -0
  37. package/dist/ThresholdsEditor/ThresholdColorPicker.js +76 -0
  38. package/dist/ThresholdsEditor/ThresholdColorPicker.js.map +1 -0
  39. package/dist/ThresholdsEditor/ThresholdInput.d.ts +13 -0
  40. package/dist/ThresholdsEditor/ThresholdInput.d.ts.map +1 -0
  41. package/dist/ThresholdsEditor/ThresholdInput.js +61 -0
  42. package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -0
  43. package/dist/ThresholdsEditor/ThresholdsEditor.d.ts +10 -0
  44. package/dist/ThresholdsEditor/ThresholdsEditor.d.ts.map +1 -0
  45. package/dist/ThresholdsEditor/ThresholdsEditor.js +215 -0
  46. package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -0
  47. package/dist/ThresholdsEditor/index.d.ts +2 -0
  48. package/dist/ThresholdsEditor/index.d.ts.map +1 -0
  49. package/dist/ThresholdsEditor/index.js +15 -0
  50. package/dist/ThresholdsEditor/index.js.map +1 -0
  51. package/dist/TimeSeriesTooltip/focused-series.d.ts.map +1 -1
  52. package/dist/TimeSeriesTooltip/focused-series.js +3 -3
  53. package/dist/TimeSeriesTooltip/focused-series.js.map +1 -1
  54. package/dist/cjs/ColorPicker/ColorPicker.js +128 -0
  55. package/dist/cjs/{model/legend.test.js → ColorPicker/index.js} +11 -12
  56. package/dist/{model/legend.test.js → cjs/EChart/index.js} +15 -14
  57. package/dist/cjs/Legend/Legend.js +5 -8
  58. package/dist/cjs/LineChart/LineChart.js +40 -1
  59. package/dist/cjs/OptionsEditorLayout/OptionsEditorControl.js +1 -1
  60. package/dist/cjs/OptionsEditorLayout/OptionsEditorGroup.js +22 -5
  61. package/dist/cjs/StatChart/StatChart.js +1 -41
  62. package/dist/cjs/ThresholdsEditor/ThresholdColorPicker.js +87 -0
  63. package/dist/cjs/ThresholdsEditor/ThresholdInput.js +72 -0
  64. package/dist/cjs/ThresholdsEditor/ThresholdsEditor.js +265 -0
  65. package/dist/cjs/ThresholdsEditor/index.js +28 -0
  66. package/dist/cjs/TimeSeriesTooltip/focused-series.js +3 -3
  67. package/dist/cjs/index.js +2 -0
  68. package/dist/cjs/test-utils/theme.js +8 -0
  69. package/dist/cjs/theme/theme.js +5 -0
  70. package/dist/cjs/utils/theme-gen.js +8 -0
  71. package/dist/index.d.ts +2 -0
  72. package/dist/index.d.ts.map +1 -1
  73. package/dist/index.js +2 -0
  74. package/dist/index.js.map +1 -1
  75. package/dist/model/graph.d.ts +2 -2
  76. package/dist/model/graph.d.ts.map +1 -1
  77. package/dist/model/graph.js.map +1 -1
  78. package/dist/model/legend.d.ts +1 -1
  79. package/dist/model/legend.d.ts.map +1 -1
  80. package/dist/model/legend.js.map +1 -1
  81. package/dist/model/theme.d.ts +5 -0
  82. package/dist/model/theme.d.ts.map +1 -1
  83. package/dist/model/theme.js.map +1 -1
  84. package/dist/model/units/bytes.d.ts +1 -1
  85. package/dist/model/units/bytes.d.ts.map +1 -1
  86. package/dist/model/units/bytes.js.map +1 -1
  87. package/dist/model/units/decimal.d.ts +1 -1
  88. package/dist/model/units/decimal.d.ts.map +1 -1
  89. package/dist/model/units/decimal.js.map +1 -1
  90. package/dist/model/units/percent.d.ts +1 -1
  91. package/dist/model/units/percent.d.ts.map +1 -1
  92. package/dist/model/units/percent.js.map +1 -1
  93. package/dist/model/units/time.d.ts +1 -1
  94. package/dist/model/units/time.d.ts.map +1 -1
  95. package/dist/model/units/time.js.map +1 -1
  96. package/dist/model/units/types.d.ts +1 -1
  97. package/dist/model/units/types.d.ts.map +1 -1
  98. package/dist/model/units/types.js.map +1 -1
  99. package/dist/test-utils/theme.d.ts.map +1 -1
  100. package/dist/test-utils/theme.js +8 -0
  101. package/dist/test-utils/theme.js.map +1 -1
  102. package/dist/theme/theme.js +5 -0
  103. package/dist/theme/theme.js.map +1 -1
  104. package/dist/utils/theme-gen.d.ts.map +1 -1
  105. package/dist/utils/theme-gen.js +8 -0
  106. package/dist/utils/theme-gen.js.map +1 -1
  107. package/package.json +8 -3
  108. package/dist/EChart.d.ts.map +0 -1
  109. package/dist/EChart.js.map +0 -1
  110. package/dist/InfoTooltip/InfoTooltip.test.d.ts +0 -2
  111. package/dist/InfoTooltip/InfoTooltip.test.d.ts.map +0 -1
  112. package/dist/InfoTooltip/InfoTooltip.test.js +0 -36
  113. package/dist/InfoTooltip/InfoTooltip.test.js.map +0 -1
  114. package/dist/LegendOptionsEditor/LegendOptionsEditor.test.d.ts +0 -2
  115. package/dist/LegendOptionsEditor/LegendOptionsEditor.test.d.ts.map +0 -1
  116. package/dist/LegendOptionsEditor/LegendOptionsEditor.test.js +0 -62
  117. package/dist/LegendOptionsEditor/LegendOptionsEditor.test.js.map +0 -1
  118. package/dist/StatChart/StatChart.test.d.ts +0 -2
  119. package/dist/StatChart/StatChart.test.d.ts.map +0 -1
  120. package/dist/StatChart/StatChart.test.js +0 -94
  121. package/dist/StatChart/StatChart.test.js.map +0 -1
  122. package/dist/TimeSeriesTooltip/SeriesInfo.test.d.ts +0 -2
  123. package/dist/TimeSeriesTooltip/SeriesInfo.test.d.ts.map +0 -1
  124. package/dist/TimeSeriesTooltip/SeriesInfo.test.js +0 -52
  125. package/dist/TimeSeriesTooltip/SeriesInfo.test.js.map +0 -1
  126. package/dist/TimeSeriesTooltip/TooltipContent.test.d.ts +0 -2
  127. package/dist/TimeSeriesTooltip/TooltipContent.test.d.ts.map +0 -1
  128. package/dist/TimeSeriesTooltip/TooltipContent.test.js +0 -78
  129. package/dist/TimeSeriesTooltip/TooltipContent.test.js.map +0 -1
  130. package/dist/TimeSeriesTooltip/focused-series.test.d.ts +0 -2
  131. package/dist/TimeSeriesTooltip/focused-series.test.d.ts.map +0 -1
  132. package/dist/TimeSeriesTooltip/focused-series.test.js +0 -93
  133. package/dist/TimeSeriesTooltip/focused-series.test.js.map +0 -1
  134. package/dist/UnitSelector/UnitSelector.test.d.ts +0 -2
  135. package/dist/UnitSelector/UnitSelector.test.d.ts.map +0 -1
  136. package/dist/UnitSelector/UnitSelector.test.js +0 -204
  137. package/dist/UnitSelector/UnitSelector.test.js.map +0 -1
  138. package/dist/cjs/InfoTooltip/InfoTooltip.test.js +0 -43
  139. package/dist/cjs/LegendOptionsEditor/LegendOptionsEditor.test.js +0 -69
  140. package/dist/cjs/StatChart/StatChart.test.js +0 -96
  141. package/dist/cjs/TimeSeriesTooltip/SeriesInfo.test.js +0 -54
  142. package/dist/cjs/TimeSeriesTooltip/TooltipContent.test.js +0 -80
  143. package/dist/cjs/TimeSeriesTooltip/focused-series.test.js +0 -95
  144. package/dist/cjs/UnitSelector/UnitSelector.test.js +0 -211
  145. package/dist/cjs/model/units/units.test.js +0 -206
  146. package/dist/cjs/utils/format.test.js +0 -47
  147. package/dist/cjs/utils/theme-gen.test.js +0 -202
  148. package/dist/model/legend.test.d.ts +0 -2
  149. package/dist/model/legend.test.d.ts.map +0 -1
  150. package/dist/model/legend.test.js.map +0 -1
  151. package/dist/model/units/units.test.d.ts +0 -2
  152. package/dist/model/units/units.test.d.ts.map +0 -1
  153. package/dist/model/units/units.test.js +0 -204
  154. package/dist/model/units/units.test.js.map +0 -1
  155. package/dist/utils/format.test.d.ts +0 -2
  156. package/dist/utils/format.test.d.ts.map +0 -1
  157. package/dist/utils/format.test.js +0 -45
  158. package/dist/utils/format.test.js.map +0 -1
  159. package/dist/utils/theme-gen.test.d.ts +0 -2
  160. package/dist/utils/theme-gen.test.d.ts.map +0 -1
  161. package/dist/utils/theme-gen.test.js +0 -200
  162. package/dist/utils/theme-gen.test.js.map +0 -1
  163. /package/dist/{EChart.js → EChart/EChart.js} +0 -0
  164. /package/dist/cjs/{EChart.js → EChart/EChart.js} +0 -0
@@ -5,9 +5,8 @@ import { GraphSeries } from '../model/graph';
5
5
  export interface StatChartData {
6
6
  calculatedValue?: number;
7
7
  seriesData?: GraphSeries;
8
- name?: string;
9
8
  }
10
- interface StatChartProps {
9
+ export interface StatChartProps {
11
10
  width: number;
12
11
  height: number;
13
12
  data: StatChartData;
@@ -15,5 +14,4 @@ interface StatChartProps {
15
14
  sparkline?: LineSeriesOption;
16
15
  }
17
16
  export declare function StatChart(props: StatChartProps): JSX.Element;
18
- export {};
19
17
  //# sourceMappingURL=StatChart.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"StatChart.d.ts","sourceRoot":"","sources":["../../src/StatChart/StatChart.tsx"],"names":[],"mappings":";AAkBA,OAAO,EAAiC,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIjF,OAAO,EAAe,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAe7C,MAAM,WAAW,aAAa;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,WAAW,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,UAAU,cAAc;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,CAAC,EAAE,gBAAgB,CAAC;CAC9B;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,eA0F9C"}
1
+ {"version":3,"file":"StatChart.d.ts","sourceRoot":"","sources":["../../src/StatChart/StatChart.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAAiC,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIjF,OAAO,EAAe,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAO7C,MAAM,WAAW,aAAa;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,WAAW,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,CAAC,EAAE,gBAAgB,CAAC;CAC9B;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,eAyF9C"}
@@ -11,11 +11,10 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
- import React, { useMemo } from 'react';
14
+ import { useMemo } from 'react';
15
15
  import { Box, Typography } from '@mui/material';
16
16
  import { merge } from 'lodash-es';
17
17
  import { use } from 'echarts/core';
18
- import { GaugeChart as EChartsGaugeChart } from 'echarts/charts';
19
18
  import { LineChart as EChartsLineChart } from 'echarts/charts';
20
19
  import { GridComponent, DatasetComponent, TitleComponent, TooltipComponent } from 'echarts/components';
21
20
  import { CanvasRenderer } from 'echarts/renderers';
@@ -23,7 +22,6 @@ import { useChartsTheme } from '../context/ChartsThemeProvider';
23
22
  import { formatValue } from '../model/units';
24
23
  import { EChart } from '../EChart';
25
24
  use([
26
- EChartsGaugeChart,
27
25
  EChartsLineChart,
28
26
  GridComponent,
29
27
  DatasetComponent,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/StatChart/StatChart.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, { useMemo } from 'react';\nimport { Box, Typography } from '@mui/material';\nimport { merge } from 'lodash-es';\nimport { use, EChartsCoreOption } from 'echarts/core';\nimport { GaugeChart as EChartsGaugeChart, GaugeSeriesOption } from 'echarts/charts';\nimport { LineChart as EChartsLineChart, LineSeriesOption } from 'echarts/charts';\nimport { GridComponent, DatasetComponent, TitleComponent, TooltipComponent } from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { useChartsTheme } from '../context/ChartsThemeProvider';\nimport { formatValue, UnitOptions } from '../model/units';\nimport { EChart } from '../EChart';\nimport { GraphSeries } from '../model/graph';\n\nuse([\n EChartsGaugeChart,\n EChartsLineChart,\n GridComponent,\n DatasetComponent,\n TitleComponent,\n TooltipComponent,\n CanvasRenderer,\n]);\n\nconst MIN_VALUE_SIZE = 12;\nconst MAX_VALUE_SIZE = 36;\n\nexport interface StatChartData {\n calculatedValue?: number;\n seriesData?: GraphSeries;\n name?: string;\n}\n\ninterface StatChartProps {\n width: number;\n height: number;\n data: StatChartData;\n unit: UnitOptions;\n sparkline?: LineSeriesOption;\n}\n\nexport function StatChart(props: StatChartProps) {\n const { width, height, data, unit, sparkline } = props;\n const chartsTheme = useChartsTheme();\n\n const formattedValue = data.calculatedValue === undefined ? '' : formatValue(data.calculatedValue, unit);\n\n const option: EChartsCoreOption = useMemo(() => {\n if (data.seriesData === undefined) return chartsTheme.noDataOption;\n\n const series = data.seriesData;\n\n const statSeries: Array<GaugeSeriesOption | LineSeriesOption> = [];\n\n if (sparkline !== undefined) {\n const lineSeries: LineSeriesOption = {\n type: 'line',\n data: [...series.values],\n zlevel: 1,\n symbol: 'none',\n animation: false,\n silent: true,\n };\n const mergedSeries = merge(lineSeries, sparkline);\n statSeries.push(mergedSeries);\n }\n\n const option = {\n title: {\n show: false,\n },\n grid: {\n show: false,\n top: '35%', // adds space above sparkline\n right: 0,\n bottom: 0,\n left: 0,\n containLabel: false,\n },\n xAxis: {\n type: 'time',\n show: false,\n boundaryGap: false,\n },\n yAxis: {\n type: 'value',\n show: false,\n },\n tooltip: {\n show: false,\n },\n series: statSeries,\n };\n\n return option;\n }, [data, chartsTheme, sparkline]);\n\n const isLargePanel = width > 250 && height > 180;\n // adjusts fontSize depending on number of characters, clamp also used in fontSize attribute\n const charactersAdjust = formattedValue.length;\n const valueSize = isLargePanel === true ? MAX_VALUE_SIZE : Math.min(width, height) / charactersAdjust;\n\n const containerPadding = `${chartsTheme.container.padding.default}px`;\n\n return (\n <Box sx={{ height: '100%', width: '100%', display: 'flex', flexDirection: 'column' }}>\n <Typography\n variant=\"h3\"\n sx={(theme) => ({\n color: theme.palette.text.primary,\n fontSize: `clamp(${MIN_VALUE_SIZE}px, ${valueSize}px, ${MAX_VALUE_SIZE}px)`,\n padding: `${containerPadding} ${containerPadding} 0 ${containerPadding}`,\n })}\n >\n {formattedValue}\n </Typography>\n {sparkline !== undefined && (\n <Box sx={{ flex: 1 }}>\n <EChart\n sx={{\n width: '100%',\n height: '100%',\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n renderer=\"svg\"\n />\n </Box>\n )}\n </Box>\n );\n}\n"],"names":["React","useMemo","Box","Typography","merge","use","GaugeChart","EChartsGaugeChart","LineChart","EChartsLineChart","GridComponent","DatasetComponent","TitleComponent","TooltipComponent","CanvasRenderer","useChartsTheme","formatValue","EChart","MIN_VALUE_SIZE","MAX_VALUE_SIZE","StatChart","props","width","height","data","unit","sparkline","chartsTheme","formattedValue","calculatedValue","undefined","option","seriesData","noDataOption","series","statSeries","lineSeries","type","values","zlevel","symbol","animation","silent","mergedSeries","push","title","show","grid","top","right","bottom","left","containLabel","xAxis","boundaryGap","yAxis","tooltip","isLargePanel","charactersAdjust","length","valueSize","Math","min","containerPadding","container","padding","default","sx","display","flexDirection","variant","theme","color","palette","text","primary","fontSize","flex","echartsTheme","renderer"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF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D,YAAY;oBAC/BC,QAAQ,EAAC,KAAK;kBACd;cACE,AACP;;MACG,CACN;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../src/StatChart/StatChart.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 { useMemo } from 'react';\nimport { Box, Typography } from '@mui/material';\nimport { merge } from 'lodash-es';\nimport { use, EChartsCoreOption } from 'echarts/core';\nimport { LineChart as EChartsLineChart, LineSeriesOption } from 'echarts/charts';\nimport { GridComponent, DatasetComponent, TitleComponent, TooltipComponent } from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { useChartsTheme } from '../context/ChartsThemeProvider';\nimport { formatValue, UnitOptions } from '../model/units';\nimport { EChart } from '../EChart';\nimport { GraphSeries } from '../model/graph';\n\nuse([EChartsLineChart, GridComponent, DatasetComponent, TitleComponent, TooltipComponent, CanvasRenderer]);\n\nconst MIN_VALUE_SIZE = 12;\nconst MAX_VALUE_SIZE = 36;\n\nexport interface StatChartData {\n calculatedValue?: number;\n seriesData?: GraphSeries;\n}\n\nexport interface StatChartProps {\n width: number;\n height: number;\n data: StatChartData;\n unit: UnitOptions;\n sparkline?: LineSeriesOption;\n}\n\nexport function StatChart(props: StatChartProps) {\n const { width, height, data, unit, sparkline } = props;\n const chartsTheme = useChartsTheme();\n\n const formattedValue = data.calculatedValue === undefined ? '' : formatValue(data.calculatedValue, unit);\n\n const option: EChartsCoreOption = useMemo(() => {\n if (data.seriesData === undefined) return chartsTheme.noDataOption;\n\n const series = data.seriesData;\n const statSeries: LineSeriesOption[] = [];\n\n if (sparkline !== undefined) {\n const lineSeries = {\n type: 'line',\n data: [...series.values],\n zlevel: 1,\n symbol: 'none',\n animation: false,\n silent: true,\n };\n const mergedSeries = merge(lineSeries, sparkline);\n statSeries.push(mergedSeries);\n }\n\n const option = {\n title: {\n show: false,\n },\n grid: {\n show: false,\n top: '35%', // adds space above sparkline\n right: 0,\n bottom: 0,\n left: 0,\n containLabel: false,\n },\n xAxis: {\n type: 'time',\n show: false,\n boundaryGap: false,\n },\n yAxis: {\n type: 'value',\n show: false,\n },\n tooltip: {\n show: false,\n },\n series: statSeries,\n };\n\n return option;\n }, [data, chartsTheme, sparkline]);\n\n const isLargePanel = width > 250 && height > 180;\n // adjusts fontSize depending on number of characters, clamp also used in fontSize attribute\n const charactersAdjust = formattedValue.length;\n const valueSize = isLargePanel === true ? MAX_VALUE_SIZE : Math.min(width, height) / charactersAdjust;\n\n const containerPadding = `${chartsTheme.container.padding.default}px`;\n\n return (\n <Box sx={{ height: '100%', width: '100%', display: 'flex', flexDirection: 'column' }}>\n <Typography\n variant=\"h3\"\n sx={(theme) => ({\n color: theme.palette.text.primary,\n fontSize: `clamp(${MIN_VALUE_SIZE}px, ${valueSize}px, ${MAX_VALUE_SIZE}px)`,\n padding: `${containerPadding} ${containerPadding} 0 ${containerPadding}`,\n })}\n >\n {formattedValue}\n </Typography>\n {sparkline !== undefined && (\n <Box sx={{ flex: 1 }}>\n <EChart\n sx={{\n width: '100%',\n height: '100%',\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n renderer=\"svg\"\n />\n </Box>\n )}\n </Box>\n );\n}\n"],"names":["useMemo","Box","Typography","merge","use","LineChart","EChartsLineChart","GridComponent","DatasetComponent","TitleComponent","TooltipComponent","CanvasRenderer","useChartsTheme","formatValue","EChart","MIN_VALUE_SIZE","MAX_VALUE_SIZE","StatChart","props","width","height","data","unit","sparkline","chartsTheme","formattedValue","calculatedValue","undefined","option","seriesData","noDataOption","series","statSeries","lineSeries","type","values","zlevel","symbol","animation","silent","mergedSeries","push","title","show","grid","top","right","bottom","left","containLabel","xAxis","boundaryGap","yAxis","tooltip","isLargePanel","charactersAdjust","length","valueSize","Math","min","containerPadding","container","padding","default","sx","display","flexDirection","variant","theme","color","palette","text","primary","fontSize","flex","echartsTheme","renderer"],"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,SAASA,OAAO,QAAQ,OAAO,CAAC;AAChC,SAASC,GAAG,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAChD,SAASC,KAAK,QAAQ,WAAW,CAAC;AAClC,SAASC,GAAG,QAA2B,cAAc,CAAC;AACtD,SAASC,SAAS,IAAIC,gBAAgB,QAA0B,gBAAgB,CAAC;AACjF,SAASC,aAAa,EAAEC,gBAAgB,EAAEC,cAAc,EAAEC,gBAAgB,QAAQ,oBAAoB,CAAC;AACvG,SAASC,cAAc,QAAQ,mBAAmB,CAAC;AACnD,SAASC,cAAc,QAAQ,gCAAgC,CAAC;AAChE,SAASC,WAAW,QAAqB,gBAAgB,CAAC;AAC1D,SAASC,MAAM,QAAQ,WAAW,CAAC;AAGnCV,GAAG,CAAC;IAACE,gBAAgB;IAAEC,aAAa;IAAEC,gBAAgB;IAAEC,cAAc;IAAEC,gBAAgB;IAAEC,cAAc;CAAC,CAAC,CAAC;AAE3G,MAAMI,cAAc,GAAG,EAAE,AAAC;AAC1B,MAAMC,cAAc,GAAG,EAAE,AAAC;AAe1B,OAAO,SAASC,SAAS,CAACC,KAAqB,EAAE;IAC/C,MAAM,EAAEC,KAAK,CAAA,EAAEC,MAAM,CAAA,EAAEC,IAAI,CAAA,EAAEC,IAAI,CAAA,EAAEC,SAAS,CAAA,EAAE,GAAGL,KAAK,AAAC;IACvD,MAAMM,WAAW,GAAGZ,cAAc,EAAE,AAAC;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AClB,cAAA,KAAC5D,MAAM;oBACLkD,EAAE,EAAE;wBACF7C,KAAK,EAAE,MAAM;wBACbC,MAAM,EAAE,MAAM;qBACf;oBACDQ,MAAM,EAAEA,MAAM;oBACdwC,KAAK,EAAE5C,WAAW,CAACmD,YAAY;oBAC/BC,QAAQ,EAAC,KAAK;kBACd;cACE,AACP;;MACG,CACN;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { ThresholdInputProps } from './ThresholdInput';
3
+ export declare function ThresholdColorPicker({ color, onColorChange, label, }: Pick<ThresholdInputProps, 'color' | 'onColorChange' | 'label'>): JSX.Element;
4
+ //# sourceMappingURL=ThresholdColorPicker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThresholdColorPicker.d.ts","sourceRoot":"","sources":["../../src/ThresholdsEditor/ThresholdColorPicker.tsx"],"names":[],"mappings":";AAkBA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,wBAAgB,oBAAoB,CAAC,EACnC,KAAK,EACL,aAAa,EACb,KAAK,GACN,EAAE,IAAI,CAAC,mBAAmB,EAAE,OAAO,GAAG,eAAe,GAAG,OAAO,CAAC,eA8ChE"}
@@ -0,0 +1,76 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
14
+ import React from 'react';
15
+ import { styled, IconButton, Popover } from '@mui/material';
16
+ import CircleIcon from 'mdi-material-ui/Circle';
17
+ import { useChartsTheme } from '../context/ChartsThemeProvider';
18
+ import { ColorPicker } from '../ColorPicker';
19
+ export function ThresholdColorPicker({ color , onColorChange , label }) {
20
+ const [anchorEl, setAnchorEl] = React.useState(null);
21
+ const isOpen = Boolean(anchorEl);
22
+ const openColorPicker = (event)=>{
23
+ setAnchorEl(event.currentTarget);
24
+ };
25
+ const closeColorPicker = ()=>{
26
+ setAnchorEl(null);
27
+ };
28
+ const { thresholds: { defaultColor , palette } , } = useChartsTheme();
29
+ return /*#__PURE__*/ _jsxs(_Fragment, {
30
+ children: [
31
+ /*#__PURE__*/ _jsx(ColorIconButton, {
32
+ size: "small",
33
+ "aria-label": `change threshold ${label} color`,
34
+ isSelected: isOpen,
35
+ iconColor: color,
36
+ onClick: openColorPicker,
37
+ children: /*#__PURE__*/ _jsx(CircleIcon, {})
38
+ }),
39
+ /*#__PURE__*/ _jsx(Popover, {
40
+ "data-testid": "threshold color picker",
41
+ open: isOpen,
42
+ anchorEl: anchorEl,
43
+ onClose: closeColorPicker,
44
+ PaperProps: {
45
+ sx: {
46
+ padding: (theme)=>theme.spacing(2)
47
+ }
48
+ },
49
+ anchorOrigin: {
50
+ vertical: 'top',
51
+ horizontal: 'left'
52
+ },
53
+ transformOrigin: {
54
+ vertical: 'top',
55
+ horizontal: 'right'
56
+ },
57
+ children: /*#__PURE__*/ _jsx(ColorPicker, {
58
+ color: color,
59
+ onChange: onColorChange,
60
+ palette: [
61
+ defaultColor,
62
+ ...palette
63
+ ]
64
+ })
65
+ })
66
+ ]
67
+ });
68
+ }
69
+ const ColorIconButton = styled(IconButton, {
70
+ shouldForwardProp: (props)=>props !== 'isSelected' && props !== 'iconColor'
71
+ })(({ iconColor , isSelected })=>({
72
+ backgroundColor: isSelected && iconColor ? `${iconColor}3F` : 'undefined',
73
+ color: iconColor
74
+ }));
75
+
76
+ //# sourceMappingURL=ThresholdColorPicker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ThresholdsEditor/ThresholdColorPicker.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 from 'react';\nimport { styled, IconButton, Popover } from '@mui/material';\nimport CircleIcon from 'mdi-material-ui/Circle';\nimport { useChartsTheme } from '../context/ChartsThemeProvider';\nimport { ColorPicker } from '../ColorPicker';\nimport { ThresholdInputProps } from './ThresholdInput';\n\nexport function ThresholdColorPicker({\n color,\n onColorChange,\n label,\n}: Pick<ThresholdInputProps, 'color' | 'onColorChange' | 'label'>) {\n const [anchorEl, setAnchorEl] = React.useState<HTMLButtonElement | null>(null);\n const isOpen = Boolean(anchorEl);\n\n const openColorPicker = (event: React.MouseEvent<HTMLButtonElement>) => {\n setAnchorEl(event.currentTarget);\n };\n\n const closeColorPicker = () => {\n setAnchorEl(null);\n };\n\n const {\n thresholds: { defaultColor, palette },\n } = useChartsTheme();\n\n return (\n <>\n <ColorIconButton\n size=\"small\"\n aria-label={`change threshold ${label} color`}\n isSelected={isOpen}\n iconColor={color}\n onClick={openColorPicker}\n >\n <CircleIcon />\n </ColorIconButton>\n <Popover\n data-testid=\"threshold color picker\"\n open={isOpen}\n anchorEl={anchorEl}\n onClose={closeColorPicker}\n PaperProps={{ sx: { padding: (theme) => theme.spacing(2) } }}\n anchorOrigin={{\n vertical: 'top',\n horizontal: 'left',\n }}\n transformOrigin={{\n vertical: 'top',\n horizontal: 'right',\n }}\n >\n <ColorPicker color={color} onChange={onColorChange} palette={[defaultColor, ...palette]} />\n </Popover>\n </>\n );\n}\n\nconst ColorIconButton = styled(IconButton, {\n shouldForwardProp: (props) => props !== 'isSelected' && props !== 'iconColor',\n})<{\n iconColor?: string;\n isSelected?: boolean;\n}>(({ iconColor, isSelected }) => ({\n backgroundColor: isSelected && iconColor ? `${iconColor}3F` : 'undefined', // 3F represents 25% opacity\n color: iconColor,\n}));\n"],"names":["React","styled","IconButton","Popover","CircleIcon","useChartsTheme","ColorPicker","ThresholdColorPicker","color","onColorChange","label","anchorEl","setAnchorEl","useState","isOpen","Boolean","openColorPicker","event","currentTarget","closeColorPicker","thresholds","defaultColor","palette","ColorIconButton","size","aria-label","isSelected","iconColor","onClick","data-testid","open","onClose","PaperProps","sx","padding","theme","spacing","anchorOrigin","vertical","horizontal","transformOrigin","onChange","shouldForwardProp","props","backgroundColor"],"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,MAAM,OAAO,CAAC;AAC1B,SAASC,MAAM,EAAEC,UAAU,EAAEC,OAAO,QAAQ,eAAe,CAAC;AAC5D,OAAOC,UAAU,MAAM,wBAAwB,CAAC;AAChD,SAASC,cAAc,QAAQ,gCAAgC,CAAC;AAChE,SAASC,WAAW,QAAQ,gBAAgB,CAAC;AAG7C,OAAO,SAASC,oBAAoB,CAAC,EACnCC,KAAK,CAAA,EACLC,aAAa,CAAA,EACbC,KAAK,CAAA,EAC0D,EAAE;IACjE,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGZ,KAAK,CAACa,QAAQ,CAA2B,IAAI,CAAC,AAAC;IAC/E,MAAMC,MAAM,GAAGC,OAAO,CAACJ,QAAQ,CAAC,AAAC;IAEjC,MAAMK,eAAe,GAAG,CAACC,KAA0C,GAAK;QACtEL,WAAW,CAACK,KAAK,CAACC,aAAa,CAAC,CAAC;IACnC,CAAC,AAAC;IAEF,MAAMC,gBAAgB,GAAG,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AE,GAAM,CAAA;QACjCkB,eAAe,EAAElB,UAAU,IAAIC,SAAS,GAAG,CAAC,EAAEA,SAAS,CAAC,EAAE,CAAC,GAAG,WAAW;QACzEnB,KAAK,EAAEmB,SAAS;KACjB,CAAA,AAAC,CAAC,AAAC"}
@@ -0,0 +1,13 @@
1
+ import { RefObject } from 'react';
2
+ export interface ThresholdInputProps {
3
+ label: string;
4
+ color: string;
5
+ value: number;
6
+ onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
7
+ onColorChange: (color: string) => void;
8
+ onBlur: () => void;
9
+ onDelete: () => void;
10
+ inputRef?: RefObject<HTMLInputElement | null>;
11
+ }
12
+ export declare function ThresholdInput({ inputRef, label, color, value, onChange, onColorChange, onBlur, onDelete, }: ThresholdInputProps): JSX.Element;
13
+ //# sourceMappingURL=ThresholdInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThresholdInput.d.ts","sourceRoot":"","sources":["../../src/ThresholdsEditor/ThresholdInput.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAK5C,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IAC3D,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;CAC/C;AAED,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,KAAK,EACL,KAAK,EACL,KAAK,EACL,QAAQ,EACR,aAAa,EACb,MAAM,EACN,QAAQ,GACT,EAAE,mBAAmB,eA2BrB"}
@@ -0,0 +1,61 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
+ import { useState } from 'react';
15
+ import { Stack, FormLabel, TextField, IconButton } from '@mui/material';
16
+ import DeleteIcon from 'mdi-material-ui/DeleteOutline';
17
+ import { ThresholdColorPicker } from './ThresholdColorPicker';
18
+ export function ThresholdInput({ inputRef , label , color , value , onChange , onColorChange , onBlur , onDelete }) {
19
+ const [key, setKey] = useState(0); // use key to cause input to lose focus when pressing enter
20
+ return /*#__PURE__*/ _jsxs(Stack, {
21
+ flex: 1,
22
+ direction: "row",
23
+ alignItems: "center",
24
+ justifyContent: "space-between",
25
+ spacing: 1,
26
+ children: [
27
+ /*#__PURE__*/ _jsx(ThresholdColorPicker, {
28
+ label: label,
29
+ color: color,
30
+ onColorChange: onColorChange
31
+ }),
32
+ /*#__PURE__*/ _jsx(FormLabel, {
33
+ htmlFor: label,
34
+ children: label
35
+ }),
36
+ /*#__PURE__*/ _jsx(TextField, {
37
+ id: label,
38
+ inputRef: inputRef,
39
+ type: "number",
40
+ value: value === 0 ? undefined : value,
41
+ placeholder: "0",
42
+ onChange: onChange,
43
+ onBlur: onBlur,
44
+ onKeyDown: (e)=>{
45
+ if (e.key === 'Enter') {
46
+ onBlur();
47
+ setKey(key + 1);
48
+ }
49
+ }
50
+ }, key),
51
+ /*#__PURE__*/ _jsx(IconButton, {
52
+ "aria-label": `delete threshold ${label}`,
53
+ size: "small",
54
+ onClick: onDelete,
55
+ children: /*#__PURE__*/ _jsx(DeleteIcon, {})
56
+ })
57
+ ]
58
+ });
59
+ }
60
+
61
+ //# sourceMappingURL=ThresholdInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ThresholdsEditor/ThresholdInput.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 { RefObject, useState } from 'react';\nimport { Stack, FormLabel, TextField, IconButton } from '@mui/material';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport { ThresholdColorPicker } from './ThresholdColorPicker';\n\nexport interface ThresholdInputProps {\n label: string;\n color: string;\n value: number;\n onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;\n onColorChange: (color: string) => void;\n onBlur: () => void;\n onDelete: () => void;\n inputRef?: RefObject<HTMLInputElement | null>;\n}\n\nexport function ThresholdInput({\n inputRef,\n label,\n color,\n value,\n onChange,\n onColorChange,\n onBlur,\n onDelete,\n}: ThresholdInputProps) {\n const [key, setKey] = useState(0); // use key to cause input to lose focus when pressing enter\n return (\n <Stack flex={1} direction=\"row\" alignItems=\"center\" justifyContent=\"space-between\" spacing={1}>\n <ThresholdColorPicker label={label} color={color} onColorChange={onColorChange} />\n <FormLabel htmlFor={label}>{label}</FormLabel>\n <TextField\n id={label}\n key={key}\n inputRef={inputRef}\n type=\"number\"\n value={value === 0 ? undefined : value}\n placeholder=\"0\"\n onChange={onChange}\n onBlur={onBlur}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n onBlur();\n setKey(key + 1);\n }\n }}\n />\n <IconButton aria-label={`delete threshold ${label}`} size=\"small\" onClick={onDelete}>\n <DeleteIcon />\n </IconButton>\n </Stack>\n );\n}\n"],"names":["useState","Stack","FormLabel","TextField","IconButton","DeleteIcon","ThresholdColorPicker","ThresholdInput","inputRef","label","color","value","onChange","onColorChange","onBlur","onDelete","key","setKey","flex","direction","alignItems","justifyContent","spacing","htmlFor","id","type","undefined","placeholder","onKeyDown","e","aria-label","size","onClick"],"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,SAAoBA,QAAQ,QAAQ,OAAO,CAAC;AAC5C,SAASC,KAAK,EAAEC,SAAS,EAAEC,SAAS,EAAEC,UAAU,QAAQ,eAAe,CAAC;AACxE,OAAOC,UAAU,MAAM,+BAA+B,CAAC;AACvD,SAASC,oBAAoB,QAAQ,wBAAwB,CAAC;AAa9D,OAAO,SAASC,cAAc,CAAC,EAC7BC,QAAQ,CAAA,EACRC,KAAK,CAAA,EACLC,KAAK,CAAA,EACLC,KAAK,CAAA,EACLC,QAAQ,CAAA,EACRC,aAAa,CAAA,EACbC,MAAM,CAAA,EACNC,QAAQ,CAAA,EACY,EAAE;IACtB,MAAM,CAACC,GAAG,EAAEC,MAAM,CAAC,GAAGjB,QAAQ,CAAC,CAAC,CAAC,AAAC,EAAC,2DAA2D;IAC9F,qBACE,MAACC,KAAK;QAACiB,IAAI,EAAE,CAAC;QAAEC,SAAS,EAAC,KAAK;QAACC,UAAU,EAAC,QAAQ;QAACC,cAAc,EAAC,eAAe;QAACC,OAAO,EAAE,CAAC;;0BAC3F,KAAChB,oBAAoB;gBAACG,KAAK,EAAEA,KAAK;gBAAEC,KAAK,EAAEA,KAAK;gBAAEG,aAAa,EAAEA,aAAa;cAAI;0BAClF,KAACX,SAAS;gBAACqB,OAAO,EAAEd,KAAK;0BAAGA,KAAK;cAAa;0BAC9C,KAACN,SAAS;gBACRqB,EAAE,EAAEf,KAAK;gBAETD,QAAQ,EAAEA,QAAQ;gBAClBiB,IAAI,EAAC,QAAQ;gBACbd,KAAK,EAAEA,KAAK,KAAK,CAAC,GAAGe,SAAS,GAAGf,KAAK;gBACtCgB,WAAW,EAAC,GAAG;gBACff,QAAQ,EAAEA,QAAQ;gBAClBE,MAAM,EAAEA,MAAM;gBACdc,SAAS,EAAE,CAACC,CAAC,GAAK;oBAChB,IAAIA,CAAC,CAACb,GAAG,KAAK,OAAO,EAAE;wBACrBF,MAAM,EAAE,CAAC;wBACTG,MAAM,CAACD,GAAG,GAAG,CAAC,CAAC,CAAC;oBAClB,CAAC;gBACH,CAAC;eAZIA,GAAG,CAaR;0BACF,KAACZ,UAAU;gBAAC0B,YAAU,EAAE,CAAC,iBAAiB,EAAErB,KAAK,CAAC,CAAC;gBAAEsB,IAAI,EAAC,OAAO;gBAACC,OAAO,EAAEjB,QAAQ;0BACjF,cAAA,KAACV,UAAU,KAAG;cACH;;MACP,CACR;AACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { ThresholdOptions } from '@perses-dev/core';
3
+ export interface ThresholdsEditorProps {
4
+ onChange: (thresholds: ThresholdOptions) => void;
5
+ thresholds?: ThresholdOptions;
6
+ hideDefault?: boolean;
7
+ disablePercentMode?: boolean;
8
+ }
9
+ export declare function ThresholdsEditor({ thresholds, onChange, hideDefault, disablePercentMode }: ThresholdsEditorProps): JSX.Element;
10
+ //# sourceMappingURL=ThresholdsEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThresholdsEditor.d.ts","sourceRoot":"","sources":["../../src/ThresholdsEditor/ThresholdsEditor.tsx"],"names":[],"mappings":";AAkBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAOpD,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,CAAC,UAAU,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACjD,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAID,wBAAgB,gBAAgB,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,kBAAkB,EAAE,EAAE,qBAAqB,eA4KhH"}
@@ -0,0 +1,215 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
+ import React, { useEffect, useRef, useState } from 'react';
15
+ import produce from 'immer';
16
+ import { IconButton, ToggleButton, ToggleButtonGroup, Typography } from '@mui/material';
17
+ import PlusIcon from 'mdi-material-ui/Plus';
18
+ import { Stack } from '@mui/system';
19
+ import { InfoTooltip } from '../InfoTooltip';
20
+ import { useChartsTheme } from '../context/ChartsThemeProvider';
21
+ import { OptionsEditorGroup } from '../OptionsEditorLayout';
22
+ import { ThresholdColorPicker } from './ThresholdColorPicker';
23
+ import { ThresholdInput } from './ThresholdInput';
24
+ const DEFAULT_STEP = 10;
25
+ export function ThresholdsEditor({ thresholds , onChange , hideDefault , disablePercentMode }) {
26
+ const { thresholds: { defaultColor , palette } , } = useChartsTheme();
27
+ var ref;
28
+ const defaultThresholdColor = (ref = thresholds === null || thresholds === void 0 ? void 0 : thresholds.default_color) !== null && ref !== void 0 ? ref : defaultColor;
29
+ const [steps, setSteps] = useState(thresholds === null || thresholds === void 0 ? void 0 : thresholds.steps);
30
+ useEffect(()=>{
31
+ setSteps(thresholds === null || thresholds === void 0 ? void 0 : thresholds.steps);
32
+ }, [
33
+ thresholds === null || thresholds === void 0 ? void 0 : thresholds.steps
34
+ ]);
35
+ // every time a new threshold is added, we want to focus the recently added input
36
+ const recentlyAddedInputRef = useRef(null);
37
+ const focusRef = useRef(false);
38
+ useEffect(()=>{
39
+ var ref;
40
+ if (!recentlyAddedInputRef.current || !focusRef.current) return;
41
+ (ref = recentlyAddedInputRef.current) === null || ref === void 0 ? void 0 : ref.focus();
42
+ focusRef.current = false;
43
+ }, [
44
+ steps === null || steps === void 0 ? void 0 : steps.length
45
+ ]);
46
+ const handleThresholdValueChange = (e, i)=>{
47
+ setSteps(produce(steps, (draft)=>{
48
+ const step = draft === null || draft === void 0 ? void 0 : draft[i];
49
+ if (step) {
50
+ step.value = Number(e.target.value);
51
+ }
52
+ }));
53
+ };
54
+ const handleThresholdColorChange = (color, i)=>{
55
+ if (thresholds !== undefined) {
56
+ onChange(produce(thresholds, (draft)=>{
57
+ if (draft.steps !== undefined) {
58
+ const step = draft.steps[i];
59
+ if (step) {
60
+ step.color = color;
61
+ }
62
+ }
63
+ }));
64
+ }
65
+ };
66
+ const handleDefaultColorChange = (color)=>{
67
+ if (thresholds !== undefined) {
68
+ onChange(produce(thresholds, (draft)=>{
69
+ draft.default_color = color;
70
+ }));
71
+ }
72
+ };
73
+ // sort thresholds in ascending order every time an input blurs
74
+ const handleThresholdBlur = ()=>{
75
+ if (steps !== undefined) {
76
+ const sortedSteps = [
77
+ ...steps
78
+ ];
79
+ sortedSteps.sort((a, b)=>a.value - b.value);
80
+ if (thresholds !== undefined) {
81
+ onChange(produce(thresholds, (draft)=>{
82
+ draft.steps = sortedSteps;
83
+ }));
84
+ }
85
+ }
86
+ };
87
+ const deleteThreshold = (i)=>{
88
+ if (thresholds !== undefined) {
89
+ const updatedThresholds = produce(thresholds, (draft)=>{
90
+ if (draft.steps) {
91
+ draft.steps.splice(i, 1);
92
+ }
93
+ });
94
+ onChange(updatedThresholds);
95
+ }
96
+ };
97
+ const addThresholdInput = ()=>{
98
+ focusRef.current = true;
99
+ if (thresholds === undefined) {
100
+ onChange({
101
+ steps: [
102
+ {
103
+ value: DEFAULT_STEP
104
+ }
105
+ ]
106
+ });
107
+ } else {
108
+ onChange(produce(thresholds, (draft)=>{
109
+ const steps = draft.steps;
110
+ if (steps === null || steps === void 0 ? void 0 : steps.length) {
111
+ const lastStep = steps[steps.length - 1];
112
+ var _length;
113
+ const color = (_length = palette[steps.length]) !== null && _length !== void 0 ? _length : getRandomColor(); // we will assign color from the palette first, then generate random color
114
+ var ref;
115
+ steps.push({
116
+ color,
117
+ value: ((ref = lastStep === null || lastStep === void 0 ? void 0 : lastStep.value) !== null && ref !== void 0 ? ref : 0) + DEFAULT_STEP
118
+ }); // set new threshold value to last step value + 10
119
+ } else if (steps) {
120
+ steps.push({
121
+ value: DEFAULT_STEP
122
+ });
123
+ }
124
+ }));
125
+ }
126
+ };
127
+ const handleModeChange = (event, value)=>{
128
+ const mode = value === 'Percent' ? 'Percent' : undefined;
129
+ if (thresholds !== undefined) {
130
+ onChange(produce(thresholds, (draft)=>{
131
+ draft.mode = mode;
132
+ }));
133
+ } else {
134
+ onChange({
135
+ mode
136
+ });
137
+ }
138
+ };
139
+ var ref1, _color, ref2;
140
+ return /*#__PURE__*/ _jsxs(OptionsEditorGroup, {
141
+ title: "Thresholds",
142
+ icon: /*#__PURE__*/ _jsx(IconButton, {
143
+ size: "small",
144
+ "aria-label": "add threshold",
145
+ onClick: addThresholdInput,
146
+ children: /*#__PURE__*/ _jsx(PlusIcon, {})
147
+ }),
148
+ children: [
149
+ /*#__PURE__*/ _jsxs(ToggleButtonGroup, {
150
+ exclusive: true,
151
+ disabled: disablePercentMode,
152
+ value: (ref1 = thresholds === null || thresholds === void 0 ? void 0 : thresholds.mode) !== null && ref1 !== void 0 ? ref1 : 'Absolute',
153
+ onChange: handleModeChange,
154
+ sx: {
155
+ height: '36px',
156
+ marginLeft: 'auto'
157
+ },
158
+ children: [
159
+ /*#__PURE__*/ _jsx(ToggleButton, {
160
+ "aria-label": "absolute",
161
+ value: "Absolute",
162
+ children: /*#__PURE__*/ _jsx(InfoTooltip, {
163
+ description: "Absolute",
164
+ children: "#"
165
+ })
166
+ }),
167
+ /*#__PURE__*/ _jsx(ToggleButton, {
168
+ "aria-label": "percent",
169
+ value: "Percent",
170
+ children: /*#__PURE__*/ _jsx(InfoTooltip, {
171
+ description: "Percentage means thresholds relative to min & max",
172
+ children: "%"
173
+ })
174
+ })
175
+ ]
176
+ }),
177
+ steps && steps.map((step, i)=>/*#__PURE__*/ _jsx(ThresholdInput, {
178
+ inputRef: i === steps.length - 1 ? recentlyAddedInputRef : undefined,
179
+ label: `T${i + 1}`,
180
+ color: (ref2 = (_color = step.color) !== null && _color !== void 0 ? _color : palette[i]) !== null && ref2 !== void 0 ? ref2 : defaultThresholdColor,
181
+ value: step.value,
182
+ onColorChange: (color)=>handleThresholdColorChange(color, i),
183
+ onChange: (e)=>{
184
+ handleThresholdValueChange(e, i);
185
+ },
186
+ onDelete: ()=>{
187
+ deleteThreshold(i);
188
+ },
189
+ onBlur: handleThresholdBlur
190
+ }, i)).reverse(),
191
+ !hideDefault && /*#__PURE__*/ _jsxs(Stack, {
192
+ flex: 1,
193
+ direction: "row",
194
+ alignItems: "center",
195
+ spacing: 1,
196
+ children: [
197
+ /*#__PURE__*/ _jsx(ThresholdColorPicker, {
198
+ label: "default",
199
+ color: defaultThresholdColor,
200
+ onColorChange: handleDefaultColorChange
201
+ }),
202
+ /*#__PURE__*/ _jsx(Typography, {
203
+ children: "Default"
204
+ })
205
+ ]
206
+ })
207
+ ]
208
+ });
209
+ }
210
+ // https://www.paulirish.com/2009/random-hex-color-code-snippets/
211
+ const getRandomColor = ()=>{
212
+ return '#' + Math.floor(Math.random() * 16777216).toString(16).padStart(6, '0');
213
+ };
214
+
215
+ //# sourceMappingURL=ThresholdsEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ThresholdsEditor/ThresholdsEditor.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, { useEffect, useRef, useState } from 'react';\nimport produce from 'immer';\nimport { IconButton, ToggleButton, ToggleButtonGroup, Typography } from '@mui/material';\nimport PlusIcon from 'mdi-material-ui/Plus';\nimport { Stack } from '@mui/system';\nimport { ThresholdOptions } from '@perses-dev/core';\nimport { InfoTooltip } from '../InfoTooltip';\nimport { useChartsTheme } from '../context/ChartsThemeProvider';\nimport { OptionsEditorGroup } from '../OptionsEditorLayout';\nimport { ThresholdColorPicker } from './ThresholdColorPicker';\nimport { ThresholdInput } from './ThresholdInput';\n\nexport interface ThresholdsEditorProps {\n onChange: (thresholds: ThresholdOptions) => void;\n thresholds?: ThresholdOptions;\n hideDefault?: boolean;\n disablePercentMode?: boolean;\n}\n\nconst DEFAULT_STEP = 10;\n\nexport function ThresholdsEditor({ thresholds, onChange, hideDefault, disablePercentMode }: ThresholdsEditorProps) {\n const {\n thresholds: { defaultColor, palette },\n } = useChartsTheme();\n const defaultThresholdColor = thresholds?.default_color ?? defaultColor;\n\n const [steps, setSteps] = useState(thresholds?.steps);\n useEffect(() => {\n setSteps(thresholds?.steps);\n }, [thresholds?.steps]);\n\n // every time a new threshold is added, we want to focus the recently added input\n const recentlyAddedInputRef = useRef<HTMLInputElement | null>(null);\n const focusRef = useRef(false);\n useEffect(() => {\n if (!recentlyAddedInputRef.current || !focusRef.current) return;\n recentlyAddedInputRef.current?.focus();\n focusRef.current = false;\n }, [steps?.length]);\n\n const handleThresholdValueChange = (e: React.ChangeEvent<HTMLInputElement>, i: number) => {\n setSteps(\n produce(steps, (draft) => {\n const step = draft?.[i];\n if (step) {\n step.value = Number(e.target.value);\n }\n })\n );\n };\n\n const handleThresholdColorChange = (color: string, i: number) => {\n if (thresholds !== undefined) {\n onChange(\n produce(thresholds, (draft) => {\n if (draft.steps !== undefined) {\n const step = draft.steps[i];\n if (step) {\n step.color = color;\n }\n }\n })\n );\n }\n };\n\n const handleDefaultColorChange = (color: string) => {\n if (thresholds !== undefined) {\n onChange(\n produce(thresholds, (draft) => {\n draft.default_color = color;\n })\n );\n }\n };\n\n // sort thresholds in ascending order every time an input blurs\n const handleThresholdBlur = () => {\n if (steps !== undefined) {\n const sortedSteps = [...steps];\n sortedSteps.sort((a, b) => a.value - b.value);\n if (thresholds !== undefined) {\n onChange(\n produce(thresholds, (draft) => {\n draft.steps = sortedSteps;\n })\n );\n }\n }\n };\n\n const deleteThreshold = (i: number): void => {\n if (thresholds !== undefined) {\n const updatedThresholds = produce(thresholds, (draft) => {\n if (draft.steps) {\n draft.steps.splice(i, 1);\n }\n });\n onChange(updatedThresholds);\n }\n };\n\n const addThresholdInput = (): void => {\n focusRef.current = true;\n if (thresholds === undefined) {\n onChange({\n steps: [{ value: DEFAULT_STEP }],\n });\n } else {\n onChange(\n produce(thresholds, (draft) => {\n const steps = draft.steps;\n if (steps?.length) {\n const lastStep = steps[steps.length - 1];\n const color = palette[steps.length] ?? getRandomColor(); // we will assign color from the palette first, then generate random color\n steps.push({ color, value: (lastStep?.value ?? 0) + DEFAULT_STEP }); // set new threshold value to last step value + 10\n } else if (steps) {\n steps.push({ value: DEFAULT_STEP });\n }\n })\n );\n }\n };\n\n const handleModeChange = (event: React.MouseEvent, value: string): void => {\n const mode = value === 'Percent' ? 'Percent' : undefined;\n if (thresholds !== undefined) {\n onChange(\n produce(thresholds, (draft) => {\n draft.mode = mode;\n })\n );\n } else {\n onChange({ mode });\n }\n };\n\n return (\n <OptionsEditorGroup\n title=\"Thresholds\"\n icon={\n <IconButton size=\"small\" aria-label=\"add threshold\" onClick={addThresholdInput}>\n <PlusIcon />\n </IconButton>\n }\n >\n <ToggleButtonGroup\n exclusive\n disabled={disablePercentMode}\n value={thresholds?.mode ?? 'Absolute'}\n onChange={handleModeChange}\n sx={{ height: '36px', marginLeft: 'auto' }}\n >\n <ToggleButton aria-label=\"absolute\" value=\"Absolute\">\n <InfoTooltip description=\"Absolute\">#</InfoTooltip>\n </ToggleButton>\n <ToggleButton aria-label=\"percent\" value=\"Percent\">\n <InfoTooltip description=\"Percentage means thresholds relative to min & max\">%</InfoTooltip>\n </ToggleButton>\n </ToggleButtonGroup>\n {steps &&\n steps\n .map((step, i) => (\n <ThresholdInput\n inputRef={i === steps.length - 1 ? recentlyAddedInputRef : undefined}\n key={i}\n label={`T${i + 1}`}\n color={step.color ?? palette[i] ?? defaultThresholdColor}\n value={step.value}\n onColorChange={(color) => handleThresholdColorChange(color, i)}\n onChange={(e) => {\n handleThresholdValueChange(e, i);\n }}\n onDelete={() => {\n deleteThreshold(i);\n }}\n onBlur={handleThresholdBlur}\n />\n ))\n .reverse()}\n {!hideDefault && (\n <Stack flex={1} direction=\"row\" alignItems=\"center\" spacing={1}>\n <ThresholdColorPicker\n label=\"default\"\n color={defaultThresholdColor}\n onColorChange={handleDefaultColorChange}\n />\n <Typography>Default</Typography>\n </Stack>\n )}\n </OptionsEditorGroup>\n );\n}\n\n// https://www.paulirish.com/2009/random-hex-color-code-snippets/\nconst getRandomColor = () => {\n return (\n '#' +\n Math.floor(Math.random() * 16777216)\n .toString(16)\n .padStart(6, '0')\n );\n};\n"],"names":["React","useEffect","useRef","useState","produce","IconButton","ToggleButton","ToggleButtonGroup","Typography","PlusIcon","Stack","InfoTooltip","useChartsTheme","OptionsEditorGroup","ThresholdColorPicker","ThresholdInput","DEFAULT_STEP","ThresholdsEditor","thresholds","onChange","hideDefault","disablePercentMode","defaultColor","palette","defaultThresholdColor","default_color","steps","setSteps","recentlyAddedInputRef","focusRef","current","focus","length","handleThresholdValueChange","e","i","draft","step","value","Number","target","handleThresholdColorChange","color","undefined","handleDefaultColorChange","handleThresholdBlur","sortedSteps","sort","a","b","deleteThreshold","updatedThresholds","splice","addThresholdInput","lastStep","getRandomColor","push","handleModeChange","event","mode","title","icon","size","aria-label","onClick","exclusive","disabled","sx","height","marginLeft","description","map","inputRef","label","onColorChange","onDelete","onBlur","reverse","flex","direction","alignItems","spacing","Math","floor","random","toString","padStart"],"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,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO,CAAC;AAC3D,OAAOC,OAAO,MAAM,OAAO,CAAC;AAC5B,SAASC,UAAU,EAAEC,YAAY,EAAEC,iBAAiB,EAAEC,UAAU,QAAQ,eAAe,CAAC;AACxF,OAAOC,QAAQ,MAAM,sBAAsB,CAAC;AAC5C,SAASC,KAAK,QAAQ,aAAa,CAAC;AAEpC,SAASC,WAAW,QAAQ,gBAAgB,CAAC;AAC7C,SAASC,cAAc,QAAQ,gCAAgC,CAAC;AAChE,SAASC,kBAAkB,QAAQ,wBAAwB,CAAC;AAC5D,SAASC,oBAAoB,QAAQ,wBAAwB,CAAC;AAC9D,SAASC,cAAc,QAAQ,kBAAkB,CAAC;AASlD,MAAMC,YAAY,GAAG,EAAE,AAAC;AAExB,OAAO,SAASC,gBAAgB,CAAC,EAAEC,UAAU,CAAA,EAAEC,QAAQ,CAAA,EAAEC,WAAW,CAAA,EAAEC,kBAAkB,CAAA,EAAyB,EAAE;IACjH,MAAM,EACJH,UAAU,EAAE,EAAEI,YAAY,CAAA,EAAEC,OAAO,CAAA,EAAE,CAAA,IACtC,GAA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BACxDc,KAAK,EAAED,IAAI,CAACC,KAAK;oBACjBoC,aAAa,EAAE,CAAChC,KAAK,GAAKD,0BAA0B,CAACC,KAAK,EAAEP,CAAC,CAAC;oBAC9DhB,QAAQ,EAAE,CAACe,CAAC,GAAK;wBACfD,0BAA0B,CAACC,CAAC,EAAEC,CAAC,CAAC,CAAC;oBACnC,CAAC;oBACDwC,QAAQ,EAAE,IAAM;wBACdzB,eAAe,CAACf,CAAC,CAAC,CAAC;oBACrB,CAAC;oBACDyC,MAAM,EAAE/B,mBAAmB;mBAXtBV,CAAC,CAYN,AACH,CAAC,CACD0C,OAAO,EAAE;YACb,CAACzD,WAAW,kBACX,MAACV,KAAK;gBAACoE,IAAI,EAAE,CAAC;gBAAEC,SAAS,EAAC,KAAK;gBAACC,UAAU,EAAC,QAAQ;gBAACC,OAAO,EAAE,CAAC;;kCAC5D,KAACnE,oBAAoB;wBACnB2D,KAAK,EAAC,SAAS;wBACf/B,KAAK,EAAElB,qBAAqB;wBAC5BkD,aAAa,EAAE9B,wBAAwB;sBACvC;kCACF,KAACpC,UAAU;kCAAC,SAAO;sBAAa;;cAC1B,AACT;;MACkB,CACrB;AACJ,CAAC;AAED,iEAAiE;AACjE,MAAM+C,cAAc,GAAG,IAAM;IAC3B,OACE,GAAG,GACH2B,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,MAAM,EAAE,GAAG,QAAQ,CAAC,CACjCC,QAAQ,CAAC,EAAE,CAAC,CACZC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CACnB;AACJ,CAAC,AAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './ThresholdsEditor';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ThresholdsEditor/index.ts"],"names":[],"mappings":"AAaA,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,15 @@
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 './ThresholdsEditor';
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ThresholdsEditor/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 './ThresholdsEditor';\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,oBAAoB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"focused-series.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesTooltip/focused-series.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAe,WAAW,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AACvE,OAAO,EAAE,UAAU,EAA0C,MAAM,iBAAiB,CAAC;AAErF,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,GAA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CACpB;AAED,oBAAY,kBAAkB,GAAG,iBAAiB,EAAE,CAAC;AAErD;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,iBAAiB,EACvB,WAAW,EAAE,MAAM,EAAE,EACrB,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,WAAW,GACjB,kBAAkB,CA6CpB;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,UAAU,CAAC,QAAQ,CAAC,EAC9B,SAAS,EAAE,iBAAiB,EAC5B,SAAS,EAAE,UAAU,CAAC,QAAQ,CAAC,EAC/B,KAAK,CAAC,EAAE,eAAe,EACvB,IAAI,CAAC,EAAE,WAAW,sBA2CnB"}
@@ -36,9 +36,9 @@ import { TOOLTIP_DATE_FORMAT, TOOLTIP_MAX_ITEMS } from './tooltip-model';
36
36
  for(let datumIdx = 0; datumIdx < currentSeries.data.length; datumIdx++){
37
37
  var _datumIdx;
38
38
  const xValue = (_datumIdx = data.xAxis[datumIdx]) !== null && _datumIdx !== void 0 ? _datumIdx : 0;
39
- var _datumIdx1;
40
- const yValue = (_datumIdx1 = currentSeries.data[datumIdx]) !== null && _datumIdx1 !== void 0 ? _datumIdx1 : 0;
41
- if (focusedX === datumIdx) {
39
+ const yValue = currentSeries.data[datumIdx];
40
+ // ensure null values not displayed in tooltip
41
+ if (yValue !== undefined && yValue !== null && focusedX === datumIdx) {
42
42
  if (yValue !== '-' && focusedY <= yValue + yBuffer && focusedY >= yValue - yBuffer) {
43
43
  // determine whether to convert timestamp to ms, see: https://stackoverflow.com/a/23982005/17575201
44
44
  const xValueMilliSeconds = xValue > 99999999999 ? xValue : xValue * 1000;