@perses-dev/components 0.15.0 → 0.17.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 (138) hide show
  1. package/dist/LineChart/LineChart.d.ts +3 -2
  2. package/dist/LineChart/LineChart.d.ts.map +1 -1
  3. package/dist/LineChart/LineChart.js +6 -16
  4. package/dist/LineChart/LineChart.js.map +1 -1
  5. package/dist/LineChart/utils.d.ts +18 -0
  6. package/dist/LineChart/utils.d.ts.map +1 -1
  7. package/dist/LineChart/utils.js +35 -9
  8. package/dist/LineChart/utils.js.map +1 -1
  9. package/dist/OptionsEditorLayout/OptionsEditorColumn.d.ts +13 -0
  10. package/dist/OptionsEditorLayout/OptionsEditorColumn.d.ts.map +1 -0
  11. package/dist/OptionsEditorLayout/OptionsEditorColumn.js +28 -0
  12. package/dist/OptionsEditorLayout/OptionsEditorColumn.js.map +1 -0
  13. package/dist/OptionsEditorLayout/OptionsEditorControl.d.ts +5 -0
  14. package/dist/OptionsEditorLayout/OptionsEditorControl.d.ts.map +1 -0
  15. package/dist/OptionsEditorLayout/OptionsEditorControl.js +50 -0
  16. package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -0
  17. package/dist/OptionsEditorLayout/OptionsEditorGrid.d.ts +13 -0
  18. package/dist/OptionsEditorLayout/OptionsEditorGrid.d.ts.map +1 -0
  19. package/dist/OptionsEditorLayout/OptionsEditorGrid.js +26 -0
  20. package/dist/OptionsEditorLayout/OptionsEditorGrid.js.map +1 -0
  21. package/dist/OptionsEditorLayout/OptionsEditorGroup.d.ts +13 -0
  22. package/dist/OptionsEditorLayout/OptionsEditorGroup.d.ts.map +1 -0
  23. package/dist/OptionsEditorLayout/OptionsEditorGroup.js +36 -0
  24. package/dist/OptionsEditorLayout/OptionsEditorGroup.js.map +1 -0
  25. package/dist/OptionsEditorLayout/index.d.ts +5 -0
  26. package/dist/OptionsEditorLayout/index.d.ts.map +1 -0
  27. package/dist/OptionsEditorLayout/index.js +18 -0
  28. package/dist/OptionsEditorLayout/index.js.map +1 -0
  29. package/dist/Tooltip/SeriesInfo.d.ts +1 -0
  30. package/dist/Tooltip/SeriesInfo.d.ts.map +1 -1
  31. package/dist/Tooltip/SeriesInfo.js +3 -3
  32. package/dist/Tooltip/SeriesInfo.js.map +1 -1
  33. package/dist/Tooltip/Tooltip.d.ts +2 -1
  34. package/dist/Tooltip/Tooltip.d.ts.map +1 -1
  35. package/dist/Tooltip/Tooltip.js +2 -2
  36. package/dist/Tooltip/Tooltip.js.map +1 -1
  37. package/dist/Tooltip/TooltipContent.d.ts.map +1 -1
  38. package/dist/Tooltip/TooltipContent.js +2 -1
  39. package/dist/Tooltip/TooltipContent.js.map +1 -1
  40. package/dist/Tooltip/focused-series.d.ts +4 -3
  41. package/dist/Tooltip/focused-series.d.ts.map +1 -1
  42. package/dist/Tooltip/focused-series.js +6 -3
  43. package/dist/Tooltip/focused-series.js.map +1 -1
  44. package/dist/Tooltip/focused-series.test.js +20 -2
  45. package/dist/Tooltip/focused-series.test.js.map +1 -1
  46. package/dist/UnitSelector/UnitSelector.d.ts +8 -0
  47. package/dist/UnitSelector/UnitSelector.d.ts.map +1 -0
  48. package/dist/UnitSelector/UnitSelector.js +112 -0
  49. package/dist/UnitSelector/UnitSelector.js.map +1 -0
  50. package/dist/UnitSelector/UnitSelector.test.d.ts +2 -0
  51. package/dist/UnitSelector/UnitSelector.test.d.ts.map +1 -0
  52. package/dist/UnitSelector/UnitSelector.test.js +211 -0
  53. package/dist/UnitSelector/UnitSelector.test.js.map +1 -0
  54. package/dist/UnitSelector/index.d.ts +2 -0
  55. package/dist/UnitSelector/index.d.ts.map +1 -0
  56. package/dist/UnitSelector/index.js +15 -0
  57. package/dist/UnitSelector/index.js.map +1 -0
  58. package/dist/YAxisLabel.d.ts +8 -0
  59. package/dist/YAxisLabel.d.ts.map +1 -0
  60. package/dist/YAxisLabel.js +39 -0
  61. package/dist/YAxisLabel.js.map +1 -0
  62. package/dist/cjs/LineChart/LineChart.js +5 -15
  63. package/dist/cjs/LineChart/utils.js +23 -1
  64. package/dist/cjs/OptionsEditorLayout/OptionsEditorColumn.js +32 -0
  65. package/dist/cjs/OptionsEditorLayout/OptionsEditorControl.js +61 -0
  66. package/dist/cjs/OptionsEditorLayout/OptionsEditorGrid.js +29 -0
  67. package/dist/cjs/OptionsEditorLayout/OptionsEditorGroup.js +40 -0
  68. package/dist/cjs/OptionsEditorLayout/index.js +31 -0
  69. package/dist/cjs/Tooltip/SeriesInfo.js +3 -3
  70. package/dist/cjs/Tooltip/Tooltip.js +2 -2
  71. package/dist/cjs/Tooltip/TooltipContent.js +2 -1
  72. package/dist/cjs/Tooltip/focused-series.js +6 -3
  73. package/dist/cjs/Tooltip/focused-series.test.js +20 -2
  74. package/dist/cjs/UnitSelector/UnitSelector.js +118 -0
  75. package/dist/cjs/UnitSelector/UnitSelector.test.js +218 -0
  76. package/dist/cjs/UnitSelector/index.js +28 -0
  77. package/dist/cjs/YAxisLabel.js +45 -0
  78. package/dist/cjs/index.js +5 -2
  79. package/dist/cjs/model/units/bytes.js +60 -0
  80. package/dist/cjs/model/units/constants.js +23 -0
  81. package/dist/cjs/model/units/decimal.js +67 -0
  82. package/dist/cjs/model/units/index.js +30 -0
  83. package/dist/cjs/model/units/percent.js +64 -0
  84. package/dist/cjs/model/units/time.js +138 -0
  85. package/dist/cjs/model/units/types.js +28 -0
  86. package/dist/cjs/model/units/units.js +104 -0
  87. package/dist/cjs/utils/component-ids.js +31 -0
  88. package/dist/cjs/utils/index.js +1 -0
  89. package/dist/index.d.ts +5 -2
  90. package/dist/index.d.ts.map +1 -1
  91. package/dist/index.js +5 -2
  92. package/dist/index.js.map +1 -1
  93. package/dist/model/units/bytes.d.ts +12 -0
  94. package/dist/model/units/bytes.d.ts.map +1 -0
  95. package/dist/model/units/bytes.js +48 -0
  96. package/dist/model/units/bytes.js.map +1 -0
  97. package/dist/model/units/constants.d.ts +2 -0
  98. package/dist/model/units/constants.d.ts.map +1 -0
  99. package/dist/model/units/constants.js +17 -0
  100. package/dist/model/units/constants.js.map +1 -0
  101. package/dist/model/units/decimal.d.ts +24 -0
  102. package/dist/model/units/decimal.d.ts.map +1 -0
  103. package/dist/model/units/decimal.js +59 -0
  104. package/dist/model/units/decimal.js.map +1 -0
  105. package/dist/model/units/index.d.ts +4 -0
  106. package/dist/model/units/index.d.ts.map +1 -0
  107. package/dist/model/units/index.js +17 -0
  108. package/dist/model/units/index.js.map +1 -0
  109. package/dist/model/units/percent.d.ts +12 -0
  110. package/dist/model/units/percent.d.ts.map +1 -0
  111. package/dist/model/units/percent.js +51 -0
  112. package/dist/model/units/percent.js.map +1 -0
  113. package/dist/model/units/time.d.ts +11 -0
  114. package/dist/model/units/time.d.ts.map +1 -0
  115. package/dist/model/units/time.js +125 -0
  116. package/dist/model/units/time.js.map +1 -0
  117. package/dist/model/units/types.d.ts +38 -0
  118. package/dist/model/units/types.d.ts.map +1 -0
  119. package/dist/model/units/types.js +22 -0
  120. package/dist/model/units/types.js.map +1 -0
  121. package/dist/model/units/units.d.ts +40 -0
  122. package/dist/model/units/units.d.ts.map +1 -0
  123. package/dist/model/units/units.js +83 -0
  124. package/dist/model/units/units.js.map +1 -0
  125. package/dist/utils/component-ids.d.ts +8 -0
  126. package/dist/utils/component-ids.d.ts.map +1 -0
  127. package/dist/utils/component-ids.js +27 -0
  128. package/dist/utils/component-ids.js.map +1 -0
  129. package/dist/utils/index.d.ts +1 -0
  130. package/dist/utils/index.d.ts.map +1 -1
  131. package/dist/utils/index.js +1 -0
  132. package/dist/utils/index.js.map +1 -1
  133. package/package.json +2 -2
  134. package/dist/cjs/model/units.js +0 -203
  135. package/dist/model/units.d.ts +0 -36
  136. package/dist/model/units.d.ts.map +0 -1
  137. package/dist/model/units.js +0 -196
  138. package/dist/model/units.js.map +0 -1
@@ -1,11 +1,12 @@
1
1
  import { MouseEvent } from 'react';
2
- import type { GridComponentOption, LegendComponentOption, VisualMapComponentOption } from 'echarts';
2
+ import type { GridComponentOption, LegendComponentOption, VisualMapComponentOption, YAXisComponentOption } from 'echarts';
3
3
  import { EChartsDataFormat } from '../model/graph';
4
4
  import { UnitOptions } from '../model/units';
5
5
  import { ZoomEventData } from './utils';
6
6
  interface LineChartProps {
7
7
  height: number;
8
8
  data: EChartsDataFormat;
9
+ yAxis?: YAXisComponentOption;
9
10
  unit?: UnitOptions;
10
11
  grid?: GridComponentOption;
11
12
  legend?: LegendComponentOption;
@@ -13,6 +14,6 @@ interface LineChartProps {
13
14
  onDataZoom?: (e: ZoomEventData) => void;
14
15
  onDoubleClick?: (e: MouseEvent) => void;
15
16
  }
16
- export declare function LineChart({ height, data, unit, grid, legend, visualMap, onDataZoom, onDoubleClick }: LineChartProps): JSX.Element;
17
+ export declare function LineChart({ height, data, yAxis, unit, grid, legend, visualMap, onDataZoom, onDoubleClick, }: LineChartProps): JSX.Element;
17
18
  export {};
18
19
  //# sourceMappingURL=LineChart.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../src/LineChart/LineChart.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAA6B,MAAM,OAAO,CAAC;AAG9D,OAAO,KAAK,EAEV,mBAAmB,EAEnB,qBAAqB,EACrB,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAiBjB,OAAO,EAAiC,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAClF,OAAO,EAAe,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG1D,OAAO,EAAgE,aAAa,EAAE,MAAM,SAAS,CAAC;AAiBtG,UAAU,cAAc;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,iBAAiB,CAAC;IACxB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B,SAAS,CAAC,EAAE,wBAAwB,EAAE,CAAC;IAC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E,cAAc,eAmJhB"}
@@ -20,10 +20,9 @@ import { GridComponent, DataZoomComponent, MarkAreaComponent, MarkLineComponent,
20
20
  import { CanvasRenderer } from 'echarts/renderers';
21
21
  import { EChart } from '../EChart';
22
22
  import { PROGRESSIVE_MODE_SERIES_LIMIT } from '../model/graph';
23
- import { formatValue } from '../model/units';
24
23
  import { useChartsTheme } from '../context/ChartsThemeProvider';
25
24
  import { Tooltip } from '../Tooltip/Tooltip';
26
- import { enableDataZoom, restoreChart, getDateRange, getFormattedDate } from './utils';
25
+ import { enableDataZoom, getDateRange, getFormattedDate, getYAxes, restoreChart } from './utils';
27
26
  use([
28
27
  EChartsLineChart,
29
28
  GridComponent,
@@ -38,7 +37,7 @@ use([
38
37
  VisualMapComponent,
39
38
  CanvasRenderer
40
39
  ]);
41
- export function LineChart({ height , data , unit , grid , legend , visualMap , onDataZoom , onDoubleClick }) {
40
+ export function LineChart({ height , data , yAxis , unit , grid , legend , visualMap , onDataZoom , onDoubleClick }) {
42
41
  const chartsTheme = useChartsTheme();
43
42
  const chartRef = useRef();
44
43
  const [showTooltip, setShowTooltip] = useState(true);
@@ -124,18 +123,7 @@ export function LineChart({ height , data , unit , grid , legend , visualMap , o
124
123
  }
125
124
  }
126
125
  },
127
- yAxis: {
128
- type: 'value',
129
- boundaryGap: [
130
- 0,
131
- '10%'
132
- ],
133
- axisLabel: {
134
- formatter: (value)=>{
135
- return formatValue(value, unit);
136
- }
137
- }
138
- },
126
+ yAxis: getYAxes(yAxis, unit),
139
127
  animation: false,
140
128
  tooltip: {
141
129
  show: showPointsOnHover,
@@ -160,6 +148,7 @@ export function LineChart({ height , data , unit , grid , legend , visualMap , o
160
148
  return option;
161
149
  }, [
162
150
  data,
151
+ yAxis,
163
152
  grid,
164
153
  legend,
165
154
  visualMap
@@ -179,7 +168,8 @@ export function LineChart({ height , data , unit , grid , legend , visualMap , o
179
168
  chartRef: chartRef,
180
169
  chartData: data,
181
170
  wrapLabels: true,
182
- pinTooltip: pinTooltip
171
+ pinTooltip: pinTooltip,
172
+ unit: unit
183
173
  }),
184
174
  /*#__PURE__*/ _jsx(EChart, {
185
175
  sx: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/LineChart/LineChart.tsx"],"sourcesContent":["// Copyright 2022 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 { MouseEvent, useMemo, useRef, useState } from 'react';\nimport { useDeepMemo } from '@perses-dev/core';\nimport { Box } from '@mui/material';\nimport type {\n EChartsCoreOption,\n GridComponentOption,\n LineSeriesOption,\n LegendComponentOption,\n VisualMapComponentOption,\n} from 'echarts';\nimport { ECharts as EChartsInstance, use } from 'echarts/core';\nimport { LineChart as EChartsLineChart } from 'echarts/charts';\nimport {\n GridComponent,\n DataZoomComponent,\n MarkAreaComponent,\n MarkLineComponent,\n MarkPointComponent,\n TitleComponent,\n ToolboxComponent,\n TooltipComponent,\n LegendComponent,\n VisualMapComponent,\n} from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { EChart, OnEventsType } from '../EChart';\nimport { PROGRESSIVE_MODE_SERIES_LIMIT, EChartsDataFormat } from '../model/graph';\nimport { formatValue, UnitOptions } from '../model/units';\nimport { useChartsTheme } from '../context/ChartsThemeProvider';\nimport { Tooltip } from '../Tooltip/Tooltip';\nimport { enableDataZoom, restoreChart, getDateRange, getFormattedDate, ZoomEventData } from './utils';\n\nuse([\n EChartsLineChart,\n GridComponent,\n DataZoomComponent,\n MarkAreaComponent,\n MarkLineComponent,\n MarkPointComponent,\n TitleComponent,\n ToolboxComponent,\n TooltipComponent,\n LegendComponent,\n VisualMapComponent,\n CanvasRenderer,\n]);\n\ninterface LineChartProps {\n height: number;\n data: EChartsDataFormat;\n unit?: UnitOptions;\n grid?: GridComponentOption;\n legend?: LegendComponentOption;\n visualMap?: VisualMapComponentOption[];\n onDataZoom?: (e: ZoomEventData) => void;\n onDoubleClick?: (e: MouseEvent) => void;\n}\n\nexport function LineChart({ height, data, unit, grid, legend, visualMap, onDataZoom, onDoubleClick }: LineChartProps) {\n const chartsTheme = useChartsTheme();\n const chartRef = useRef<EChartsInstance>();\n const [showTooltip, setShowTooltip] = useState<boolean>(true);\n const [pinTooltip, setPinTooltip] = useState<boolean>(false);\n\n const handleEvents: OnEventsType<LineSeriesOption['data'] | unknown> = useMemo(() => {\n return {\n datazoom: (params) => {\n if (onDataZoom === undefined) {\n setTimeout(() => {\n // workaround so unpin happens after click event\n setPinTooltip(false);\n }, 10);\n }\n if (onDataZoom === undefined || params.batch[0] === undefined) return;\n const startIndex = params.batch[0].startValue ?? 0;\n const endIndex = params.batch[0].endValue ?? data.xAxis.length - 1;\n const xAxisStartValue = data.xAxis[startIndex];\n const xAxisEndValue = data.xAxis[endIndex];\n\n if (xAxisStartValue !== undefined && xAxisEndValue !== undefined) {\n const zoomEvent: ZoomEventData = {\n start: xAxisStartValue,\n end: xAxisEndValue,\n startIndex,\n endIndex,\n };\n onDataZoom(zoomEvent);\n }\n },\n // TODO: use legendselectchanged event to fix tooltip when legend selected\n };\n }, [data, onDataZoom, setPinTooltip]);\n\n if (chartRef.current !== undefined) {\n enableDataZoom(chartRef.current);\n }\n\n const handleOnClick = () => setPinTooltip((current) => !current);\n\n const handleOnDoubleClick = (e: MouseEvent) => {\n setPinTooltip(false);\n // either dispatch ECharts restore action to return to orig state or allow consumer to define behavior\n if (onDoubleClick === undefined) {\n if (chartRef.current !== undefined) {\n restoreChart(chartRef.current);\n }\n } else {\n onDoubleClick(e);\n }\n };\n\n const handleOnMouseDown = (e: MouseEvent) => {\n // hide tooltip when user drags to zoom, but allow clicking inside tooltip to copy labels\n if (e.target instanceof HTMLCanvasElement) {\n setShowTooltip(false);\n }\n };\n\n const handleOnMouseUp = () => {\n setShowTooltip(true);\n };\n\n const handleOnMouseEnter = () => {\n setShowTooltip(true);\n };\n\n const handleOnMouseLeave = () => {\n setShowTooltip(false);\n setPinTooltip(false);\n };\n\n const option: EChartsCoreOption = useDeepMemo(() => {\n if (data.timeSeries === undefined) return {};\n if (data.timeSeries === null || data.timeSeries.length === 0) return chartsTheme.noDataOption;\n\n const showPointsOnHover = data.timeSeries.length < PROGRESSIVE_MODE_SERIES_LIMIT;\n\n const rangeMs = data.rangeMs ?? getDateRange(data.xAxis);\n\n const option: EChartsCoreOption = {\n series: data.timeSeries,\n xAxis: {\n type: 'category',\n data: data.xAxis,\n max: data.xAxisMax,\n axisLabel: {\n formatter: (value: number) => {\n return getFormattedDate(value, rangeMs);\n },\n },\n },\n yAxis: {\n type: 'value',\n boundaryGap: [0, '10%'],\n axisLabel: {\n formatter: (value: number) => {\n return formatValue(value, unit);\n },\n },\n },\n animation: false,\n tooltip: {\n show: showPointsOnHover,\n trigger: 'axis',\n showContent: false,\n axisPointer: {\n type: 'none',\n },\n },\n toolbox: {\n feature: {\n dataZoom: {\n icon: null, // https://stackoverflow.com/a/67684076/17575201\n yAxisIndex: 'none',\n },\n },\n },\n grid,\n legend,\n visualMap,\n };\n\n return option;\n }, [data, grid, legend, visualMap]);\n\n return (\n <Box\n sx={{\n height,\n }}\n onClick={handleOnClick}\n onDoubleClick={handleOnDoubleClick}\n onMouseDown={handleOnMouseDown}\n onMouseUp={handleOnMouseUp}\n onMouseLeave={handleOnMouseLeave}\n onMouseEnter={handleOnMouseEnter}\n >\n {showTooltip === true && (\n <Tooltip chartRef={chartRef} chartData={data} wrapLabels={true} pinTooltip={pinTooltip}></Tooltip>\n )}\n\n <EChart\n sx={{\n width: '100%',\n height: '100%',\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n onEvents={handleEvents}\n _instance={chartRef}\n />\n </Box>\n );\n}\n"],"names":["useMemo","useRef","useState","useDeepMemo","Box","use","LineChart","EChartsLineChart","GridComponent","DataZoomComponent","MarkAreaComponent","MarkLineComponent","MarkPointComponent","TitleComponent","ToolboxComponent","TooltipComponent","LegendComponent","VisualMapComponent","CanvasRenderer","EChart","PROGRESSIVE_MODE_SERIES_LIMIT","formatValue","useChartsTheme","Tooltip","enableDataZoom","restoreChart","getDateRange","getFormattedDate","height","data","unit","grid","legend","visualMap","onDataZoom","onDoubleClick","chartsTheme","chartRef","showTooltip","setShowTooltip","pinTooltip","setPinTooltip","handleEvents","datazoom","params","undefined","setTimeout","batch","startIndex","startValue","endIndex","endValue","xAxis","length","xAxisStartValue","xAxisEndValue","zoomEvent","start","end","current","handleOnClick","handleOnDoubleClick","e","handleOnMouseDown","target","HTMLCanvasElement","handleOnMouseUp","handleOnMouseEnter","handleOnMouseLeave","option","timeSeries","noDataOption","showPointsOnHover","rangeMs","series","type","max","xAxisMax","axisLabel","formatter","value","yAxis","boundaryGap","animation","tooltip","show","trigger","showContent","axisPointer","toolbox","feature","dataZoom","icon","yAxisIndex","sx","onClick","onMouseDown","onMouseUp","onMouseLeave","onMouseEnter","chartData","wrapLabels","width","theme","echartsTheme","onEvents","_instance"],"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,SAAqBA,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO,CAAC;AAC9D,SAASC,WAAW,QAAQ,kBAAkB,CAAC;AAC/C,SAASC,GAAG,QAAQ,eAAe,CAAC;AAQpC,SAAqCC,GAAG,QAAQ,cAAc,CAAC;AAC/D,SAASC,SAAS,IAAIC,gBAAgB,QAAQ,gBAAgB,CAAC;AAC/D,SACEC,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EACj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AM;QAAEC,SAAS;KAAC,CAAC,AAAC;IAEpC,qBACE,MAAC7B,GAAG;QACF0F,EAAE,EAAE;YACFlE,MAAM;SACP;QACDmE,OAAO,EAAEnC,aAAa;QACtBzB,aAAa,EAAE0B,mBAAmB;QAClCmC,WAAW,EAAEjC,iBAAiB;QAC9BkC,SAAS,EAAE/B,eAAe;QAC1BgC,YAAY,EAAE9B,kBAAkB;QAChC+B,YAAY,EAAEhC,kBAAkB;;YAE/B7B,WAAW,KAAK,IAAI,kBACnB,KAACf,OAAO;gBAACc,QAAQ,EAAEA,QAAQ;gBAAE+D,SAAS,EAAEvE,IAAI;gBAAEwE,UAAU,EAAE,IAAI;gBAAE7D,UAAU,EAAEA,UAAU;cAAY,AACnG;0BAED,KAACrB,MAAM;gBACL2E,EAAE,EAAE;oBACFQ,KAAK,EAAE,MAAM;oBACb1E,MAAM,EAAE,MAAM;iBACf;gBACDyC,MAAM,EAAEA,MAAM;gBACdkC,KAAK,EAAEnE,WAAW,CAACoE,YAAY;gBAC/BC,QAAQ,EAAE/D,YAAY;gBACtBgE,SAAS,EAAErE,QAAQ;cACnB;;MACE,CACN;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../src/LineChart/LineChart.tsx"],"sourcesContent":["// Copyright 2022 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 { MouseEvent, useMemo, useRef, useState } from 'react';\nimport { useDeepMemo } from '@perses-dev/core';\nimport { Box } from '@mui/material';\nimport type {\n EChartsCoreOption,\n GridComponentOption,\n LineSeriesOption,\n LegendComponentOption,\n VisualMapComponentOption,\n YAXisComponentOption,\n} from 'echarts';\nimport { ECharts as EChartsInstance, use } from 'echarts/core';\nimport { LineChart as EChartsLineChart } from 'echarts/charts';\nimport {\n GridComponent,\n DataZoomComponent,\n MarkAreaComponent,\n MarkLineComponent,\n MarkPointComponent,\n TitleComponent,\n ToolboxComponent,\n TooltipComponent,\n LegendComponent,\n VisualMapComponent,\n} from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { EChart, OnEventsType } from '../EChart';\nimport { PROGRESSIVE_MODE_SERIES_LIMIT, EChartsDataFormat } from '../model/graph';\nimport { UnitOptions } from '../model/units';\nimport { useChartsTheme } from '../context/ChartsThemeProvider';\nimport { Tooltip } from '../Tooltip/Tooltip';\nimport { enableDataZoom, getDateRange, getFormattedDate, getYAxes, restoreChart, ZoomEventData } from './utils';\n\nuse([\n EChartsLineChart,\n GridComponent,\n DataZoomComponent,\n MarkAreaComponent,\n MarkLineComponent,\n MarkPointComponent,\n TitleComponent,\n ToolboxComponent,\n TooltipComponent,\n LegendComponent,\n VisualMapComponent,\n CanvasRenderer,\n]);\n\ninterface LineChartProps {\n height: number;\n data: EChartsDataFormat;\n yAxis?: YAXisComponentOption;\n unit?: UnitOptions;\n grid?: GridComponentOption;\n legend?: LegendComponentOption;\n visualMap?: VisualMapComponentOption[];\n onDataZoom?: (e: ZoomEventData) => void;\n onDoubleClick?: (e: MouseEvent) => void;\n}\n\nexport function LineChart({\n height,\n data,\n yAxis,\n unit,\n grid,\n legend,\n visualMap,\n onDataZoom,\n onDoubleClick,\n}: LineChartProps) {\n const chartsTheme = useChartsTheme();\n const chartRef = useRef<EChartsInstance>();\n const [showTooltip, setShowTooltip] = useState<boolean>(true);\n const [pinTooltip, setPinTooltip] = useState<boolean>(false);\n\n const handleEvents: OnEventsType<LineSeriesOption['data'] | unknown> = useMemo(() => {\n return {\n datazoom: (params) => {\n if (onDataZoom === undefined) {\n setTimeout(() => {\n // workaround so unpin happens after click event\n setPinTooltip(false);\n }, 10);\n }\n if (onDataZoom === undefined || params.batch[0] === undefined) return;\n const startIndex = params.batch[0].startValue ?? 0;\n const endIndex = params.batch[0].endValue ?? data.xAxis.length - 1;\n const xAxisStartValue = data.xAxis[startIndex];\n const xAxisEndValue = data.xAxis[endIndex];\n\n if (xAxisStartValue !== undefined && xAxisEndValue !== undefined) {\n const zoomEvent: ZoomEventData = {\n start: xAxisStartValue,\n end: xAxisEndValue,\n startIndex,\n endIndex,\n };\n onDataZoom(zoomEvent);\n }\n },\n // TODO: use legendselectchanged event to fix tooltip when legend selected\n };\n }, [data, onDataZoom, setPinTooltip]);\n\n if (chartRef.current !== undefined) {\n enableDataZoom(chartRef.current);\n }\n\n const handleOnClick = () => setPinTooltip((current) => !current);\n\n const handleOnDoubleClick = (e: MouseEvent) => {\n setPinTooltip(false);\n // either dispatch ECharts restore action to return to orig state or allow consumer to define behavior\n if (onDoubleClick === undefined) {\n if (chartRef.current !== undefined) {\n restoreChart(chartRef.current);\n }\n } else {\n onDoubleClick(e);\n }\n };\n\n const handleOnMouseDown = (e: MouseEvent) => {\n // hide tooltip when user drags to zoom, but allow clicking inside tooltip to copy labels\n if (e.target instanceof HTMLCanvasElement) {\n setShowTooltip(false);\n }\n };\n\n const handleOnMouseUp = () => {\n setShowTooltip(true);\n };\n\n const handleOnMouseEnter = () => {\n setShowTooltip(true);\n };\n\n const handleOnMouseLeave = () => {\n setShowTooltip(false);\n setPinTooltip(false);\n };\n\n const option: EChartsCoreOption = useDeepMemo(() => {\n if (data.timeSeries === undefined) return {};\n if (data.timeSeries === null || data.timeSeries.length === 0) return chartsTheme.noDataOption;\n\n const showPointsOnHover = data.timeSeries.length < PROGRESSIVE_MODE_SERIES_LIMIT;\n\n const rangeMs = data.rangeMs ?? getDateRange(data.xAxis);\n\n const option: EChartsCoreOption = {\n series: data.timeSeries,\n xAxis: {\n type: 'category',\n data: data.xAxis,\n max: data.xAxisMax,\n axisLabel: {\n formatter: (value: number) => {\n return getFormattedDate(value, rangeMs);\n },\n },\n },\n yAxis: getYAxes(yAxis, unit),\n animation: false,\n tooltip: {\n show: showPointsOnHover,\n trigger: 'axis',\n showContent: false,\n axisPointer: {\n type: 'none',\n },\n },\n toolbox: {\n feature: {\n dataZoom: {\n icon: null, // https://stackoverflow.com/a/67684076/17575201\n yAxisIndex: 'none',\n },\n },\n },\n grid,\n legend,\n visualMap,\n };\n\n return option;\n }, [data, yAxis, grid, legend, visualMap]);\n\n return (\n <Box\n sx={{\n height,\n }}\n onClick={handleOnClick}\n onDoubleClick={handleOnDoubleClick}\n onMouseDown={handleOnMouseDown}\n onMouseUp={handleOnMouseUp}\n onMouseLeave={handleOnMouseLeave}\n onMouseEnter={handleOnMouseEnter}\n >\n {showTooltip === true && (\n <Tooltip chartRef={chartRef} chartData={data} wrapLabels={true} pinTooltip={pinTooltip} unit={unit}></Tooltip>\n )}\n\n <EChart\n sx={{\n width: '100%',\n height: '100%',\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n onEvents={handleEvents}\n _instance={chartRef}\n />\n </Box>\n );\n}\n"],"names":["useMemo","useRef","useState","useDeepMemo","Box","use","LineChart","EChartsLineChart","GridComponent","DataZoomComponent","MarkAreaComponent","MarkLineComponent","MarkPointComponent","TitleComponent","ToolboxComponent","TooltipComponent","LegendComponent","VisualMapComponent","CanvasRenderer","EChart","PROGRESSIVE_MODE_SERIES_LIMIT","useChartsTheme","Tooltip","enableDataZoom","getDateRange","getFormattedDate","getYAxes","restoreChart","height","data","yAxis","unit","grid","legend","visualMap","onDataZoom","onDoubleClick","chartsTheme","chartRef","showTooltip","setShowTooltip","pinTooltip","setPinTooltip","handleEvents","datazoom","params","undefined","setTimeout","batch","startIndex","startValue","endIndex","endValue","xAxis","length","xAxisStartValue","xAxisEndValue","zoomEvent","start","end","current","handleOnClick","handleOnDoubleClick","e","handleOnMouseDown","target","HTMLCanvasElement","handleOnMouseUp","handleOnMouseEnter","handleOnMouseLeave","option","timeSeries","noDataOption","showPointsOnHover","rangeMs","series","type","max","xAxisMax","axisLabel","formatter","value","animation","tooltip","show","trigger","showContent","axisPointer","toolbox","feature","dataZoom","icon","yAxisIndex","sx","onClick","onMouseDown","onMouseUp","onMouseLeave","onMouseEnter","chartData","wrapLabels","width","theme","echartsTheme","onEvents","_instance"],"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,SAAqBA,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO,CAAC;AAC9D,SAASC,WAAW,QAAQ,kBAAkB,CAAC;AAC/C,SAASC,GAAG,QAAQ,eAAe,CAAC;AASpC,SAAqCC,GAAG,QAAQ,cAAc,CAAC;AAC/D,SAASC,SAAS,IAAIC,gBAAgB,QAAQ,gBAAgB,CAAC;AAC/D,SACEC,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EACjBC,iBAAiB,EACjBC,kBAAkB,EAClBC,cAAc,EACdC,gBAAgB,EAChBC,gBAAgB,EAChBC,eAAe,EACfC,kBAAkB,QACb,oBAAoB,CAAC;AAC5B,SAASC,cAAc,QAAQ,mBAAmB,CAAC;AACnD,SAASC,MAAM,QAAsB,WAAW,CAAC;AACjD,SAASC,6BAA6B,QAA2B,gBAAgB,CAAC;AAElF,SAASC,cAAc,QAAQ,gCAAgC,CAAC;AAChE,SAASC,OAAO,QAAQ,oBAAoB,CAAC;AAC7C,SAASC,cAAc,EAAEC,YAAY,EAAEC,gBAAgB,EAAEC,QAAQ,EAAEC,YAAY,QAAuB,SAAS,CAAC;AAEhHtB,GAAG,CAAC;IACFE,gBAAgB;IAChBC,aAAa;IACbC,iBAAiB;IACjBC,iBAAiB;IACjBC,iBAAiB;IACjBC,kBAAkB;IAClBC,cAAc;IACdC,gBAAgB;IAChBC,gBAAgB;IAChBC,eAAe;IACfC,kBAAkB;IAClBC,cAAc;CACf,C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ption } from 'echarts';
1
2
  import { ECharts as EChartsInstance } from 'echarts/core';
3
+ import { UnitOptions } from '../model';
2
4
  export interface ZoomEventData {
3
5
  start: number;
4
6
  end: number;
5
7
  startIndex: number;
6
8
  endIndex: number;
7
9
  }
10
+ /**
11
+ * Enable dataZoom without requring user to click toolbox icon
12
+ */
8
13
  export declare function enableDataZoom(chart: EChartsInstance): void;
14
+ /**
15
+ * Restore chart to original state before zoom or other actions were dispatched
16
+ */
9
17
  export declare function restoreChart(chart: EChartsInstance): void;
18
+ /**
19
+ * Calculate date range, used as a fallback when xAxis time range not passed as prop
20
+ */
10
21
  export declare function getDateRange(data: number[]): number;
11
22
  export declare function getFormattedDate(value: number, rangeMs: number): string;
23
+ export declare function getYAxes(yAxis?: YAXisComponentOption, unit?: UnitOptions): ({
24
+ type: string;
25
+ boundaryGap: (string | number)[];
26
+ axisLabel: {
27
+ formatter: (value: number) => string;
28
+ };
29
+ } & (YAXisComponentOption | undefined))[];
12
30
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/LineChart/utils.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC;AAE1D,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAGD,wBAAgB,cAAc,CAAC,KAAK,EAAE,eAAe,QAapD;AAID,wBAAgB,YAAY,CAAC,KAAK,EAAE,eAAe,QAIlD;AAGD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,UAM1C;AAGD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,UAiB9D"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/LineChart/utils.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAe,WAAW,EAAE,MAAM,UAAU,CAAC;AAEpD,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,eAAe,QAapD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,eAAe,QAKlD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,UAM1C;AAKD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,UAiB9D;AAKD,wBAAgB,QAAQ,CAAC,KAAK,CAAC,EAAE,oBAAoB,EAAE,IAAI,CAAC,EAAE,WAAW;;;;2BAMhD,MAAM;;0CAM9B"}
@@ -10,8 +10,11 @@
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
- // enable dataZoom without requring user to click toolbox icon
14
- export function enableDataZoom(chart) {
13
+ import { merge } from 'lodash-es';
14
+ import { formatValue } from '../model';
15
+ /**
16
+ * Enable dataZoom without requring user to click toolbox icon
17
+ */ export function enableDataZoom(chart) {
15
18
  const chartModel = chart['_model'];
16
19
  if (chartModel === undefined) return;
17
20
  if (chartModel.option.toolbox !== undefined && chartModel.option.toolbox.length > 0) {
@@ -25,23 +28,26 @@ export function enableDataZoom(chart) {
25
28
  }
26
29
  }
27
30
  }
28
- // restore chart to original state before zoom or other actions were dispatched
29
- // TODO: support incremental unzoom instead of restore to original state
30
- export function restoreChart(chart) {
31
+ /**
32
+ * Restore chart to original state before zoom or other actions were dispatched
33
+ */ export function restoreChart(chart) {
34
+ // TODO: support incremental unzoom instead of restore to original state
31
35
  chart.dispatchAction({
32
36
  type: 'restore'
33
37
  });
34
38
  }
35
- // fallback when xAxis time range not passed as prop
36
- export function getDateRange(data) {
39
+ /**
40
+ * Calculate date range, used as a fallback when xAxis time range not passed as prop
41
+ */ export function getDateRange(data) {
37
42
  const defaultRange = 3600000; // hour in ms
38
43
  if (data.length === 0) return defaultRange;
39
44
  const lastDatum = data[data.length - 1];
40
45
  if (data[0] === undefined || lastDatum === undefined) return defaultRange;
41
46
  return lastDatum - data[0];
42
47
  }
43
- // determines time granularity for axis labels, defaults to hh:mm
44
- export function getFormattedDate(value, rangeMs) {
48
+ /*
49
+ * Determines time granularity for axis labels, defaults to hh:mm
50
+ */ export function getFormattedDate(value, rangeMs) {
45
51
  const dateFormatOptions = {
46
52
  hour: 'numeric',
47
53
  minute: 'numeric',
@@ -59,5 +65,25 @@ export function getFormattedDate(value, rangeMs) {
59
65
  // remove comma when month / day present
60
66
  return DATE_FORMAT.format(value).replace(/, /g, ' ');
61
67
  }
68
+ /*
69
+ * Populate yAxis properties, returns an Array since multiple y axes will be supported in the future
70
+ */ export function getYAxes(yAxis, unit) {
71
+ // TODO: support alternate yAxis that shows on right side
72
+ const Y_AXIS_DEFAULT = {
73
+ type: 'value',
74
+ boundaryGap: [
75
+ 0,
76
+ '10%'
77
+ ],
78
+ axisLabel: {
79
+ formatter: (value)=>{
80
+ return formatValue(value, unit);
81
+ }
82
+ }
83
+ };
84
+ return [
85
+ merge(Y_AXIS_DEFAULT, yAxis)
86
+ ];
87
+ }
62
88
 
63
89
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/LineChart/utils.ts"],"sourcesContent":["// Copyright 2022 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';\n\nexport interface ZoomEventData {\n start: number;\n end: number;\n startIndex: number;\n endIndex: number;\n}\n\n// enable dataZoom without requring user to click toolbox icon\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// restore chart to original state before zoom or other actions were dispatched\n// TODO: support incremental unzoom instead of restore to original state\nexport function restoreChart(chart: EChartsInstance) {\n chart.dispatchAction({\n type: 'restore', // https://echarts.apache.org/en/api.html#events.restore\n });\n}\n\n// fallback when xAxis time range not passed as prop\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\n// determines time granularity for axis labels, defaults to hh:mm\nexport function getFormattedDate(value: number, rangeMs: number) {\n const dateFormatOptions: Intl.DateTimeFormatOptions = {\n hour: 'numeric',\n minute: 'numeric',\n hourCycle: 'h23',\n };\n const thirtyMinMs = 1800000;\n const dayMs = 86400000;\n if (rangeMs <= thirtyMinMs) {\n dateFormatOptions.second = 'numeric';\n } else if (rangeMs >= dayMs) {\n dateFormatOptions.month = 'numeric';\n dateFormatOptions.day = 'numeric';\n }\n const DATE_FORMAT = new Intl.DateTimeFormat(undefined, dateFormatOptions);\n // remove comma when month / day present\n return DATE_FORMAT.format(value).replace(/, /g, ' ');\n}\n"],"names":["enableDataZoom","chart","chartModel","undefined","option","toolbox","length","feature","dataZoom","iconStatus","zoom","dispatchAction","type","key","dataZoomSelectActive","restoreChart","getDateRange","data","defaultRange","lastDatum","getFormattedDate","value","rangeMs","dateFormatOptions","hour","minute","hourCycle","thirtyMinMs","dayMs","second","month","day","DATE_FORMAT","Intl","DateTimeFormat","format","replace"],"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;AAWjC,8DAA8D;AAC9D,OAAO,SAASA,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,+EAA+E;AAC/E,wEAAwE;AACxE,OAAO,SAASC,YAAY,CAACd,KAAsB,EAAE;IACnDA,KAAK,CAACU,cAAc,CAAC;QACnBC,IAAI,EAAE,SAAS;KAChB,CAAC,CAAC;AACL,CAAC;AAED,oDAAoD;AACpD,OAAO,SAASI,YAAY,CAACC,IAAc,EAAE;IAC3C,MAAMC,YAAY,GAAG,OAAO,AAAC,EAAC,aAAa;IAC3C,IAAID,IAAI,CAACX,MAAM,KAAK,CAAC,EAAE,OAAOY,YAAY,CAAC;IAC3C,MAAMC,SAAS,GAAGF,IAAI,CAACA,IAAI,CAACX,MAAM,GAAG,CAAC,CAAC,AAAC;IACxC,IAAIW,IAAI,CAAC,CAAC,CAAC,KAAKd,SAAS,IAAIgB,SAAS,KAAKhB,SAAS,EAAE,OAAOe,YAAY,CAAC;IAC1E,OAAOC,SAAS,GAAGF,IAAI,CAAC,CAAC,CAAC,CAAC;AAC7B,CAAC;AAED,iEAAiE;AACjE,OAAO,SAASG,gBAAgB,CAACC,KAAa,EAAEC,OAAe,EAAE;IAC/D,MAAMC,iBAAiB,GAA+B;QACpDC,IAAI,EAAE,SAAS;QACfC,MAAM,EAAE,SAAS;QACjBC,SAAS,EAAE,KAAK;KACjB,AAAC;IACF,MAAMC,WAAW,GAAG,OAAO,AAAC;IAC5B,MAAMC,KAAK,GAAG,QAAQ,AAAC;IACvB,IAAIN,OAAO,IAAIK,WAAW,EAAE;QAC1BJ,iBAAiB,CAACM,MAAM,GAAG,SAAS,CAAC;IACvC,OAAO,IAAIP,OAAO,IAAIM,KAAK,EAAE;QAC3BL,iBAAiB,CAACO,KAAK,GAAG,SAAS,CAAC;QACpCP,iBAAiB,CAACQ,GAAG,GAAG,SAAS,CAAC;IACpC,CAAC;IACD,MAAMC,WAAW,GAAG,IAAIC,IAAI,CAACC,cAAc,CAAC/B,SAAS,EAAEoB,iBAAiB,CAAC,AAAC;IAC1E,wCAAwC;IACxC,OAAOS,WAAW,CAACG,MAAM,CAACd,KAAK,CAAC,CAACe,OAAO,QAAQ,GAAG,CAAC,CAAC;AACvD,CAAC"}
1
+ {"version":3,"sources":["../../src/LineChart/utils.ts"],"sourcesContent":["// Copyright 2022 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-es';\nimport type { YAXisComponentOption } from 'echarts';\nimport { ECharts as EChartsInstance } from 'echarts/core';\nimport { formatValue, UnitOptions } from '../model';\n\nexport interface ZoomEventData {\n start: number;\n end: number;\n startIndex: number;\n endIndex: number;\n}\n\n/**\n * Enable dataZoom without requring user to click toolbox icon\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 * 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\n/*\n * Determines time granularity for axis labels, defaults to hh:mm\n */\nexport function getFormattedDate(value: number, rangeMs: number) {\n const dateFormatOptions: Intl.DateTimeFormatOptions = {\n hour: 'numeric',\n minute: 'numeric',\n hourCycle: 'h23',\n };\n const thirtyMinMs = 1800000;\n const dayMs = 86400000;\n if (rangeMs <= thirtyMinMs) {\n dateFormatOptions.second = 'numeric';\n } else if (rangeMs >= dayMs) {\n dateFormatOptions.month = 'numeric';\n dateFormatOptions.day = 'numeric';\n }\n const DATE_FORMAT = new Intl.DateTimeFormat(undefined, dateFormatOptions);\n // remove comma when month / day present\n return DATE_FORMAT.format(value).replace(/, /g, ' ');\n}\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"],"names":["merge","formatValue","enableDataZoom","chart","chartModel","undefined","option","toolbox","length","feature","dataZoom","iconStatus","zoom","dispatchAction","type","key","dataZoomSelectActive","restoreChart","getDateRange","data","defaultRange","lastDatum","getFormattedDate","value","rangeMs","dateFormatOptions","hour","minute","hourCycle","thirtyMinMs","dayMs","second","month","day","DATE_FORMAT","Intl","DateTimeFormat","format","replace","getYAxes","yAxis","unit","Y_AXIS_DEFAULT","boundaryGap","axisLabel","formatter"],"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,KAAK,QAAQ,WAAW,CAAC;AAGlC,SAASC,WAAW,QAAqB,UAAU,CAAC;AASpD;;CAEC,GACD,OAAO,SAASC,cAAc,CAACC,KAAsB,EAAE;IACrD,MAAMC,UAAU,GAAGD,KAAK,CAAC,QAAQ,CAAC,AAAC;IACnC,IAAIC,UAAU,KAAKC,SAAS,EAAE,OAAO;IAC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O,AAAC;IAC5B,MAAMC,KAAK,GAAG,QAAQ,AAAC;IACvB,IAAIN,OAAO,IAAIK,WAAW,EAAE;QAC1BJ,iBAAiB,CAACM,MAAM,GAAG,SAAS,CAAC;IACvC,OAAO,IAAIP,OAAO,IAAIM,KAAK,EAAE;QAC3BL,iBAAiB,CAACO,KAAK,GAAG,SAAS,CAAC;QACpCP,iBAAiB,CAACQ,GAAG,GAAG,SAAS,CAAC;IACpC,CAAC;IACD,MAAMC,WAAW,GAAG,IAAIC,IAAI,CAACC,cAAc,CAAC/B,SAAS,EAAEoB,iBAAiB,CAAC,AAAC;IAC1E,wCAAwC;IACxC,OAAOS,WAAW,CAACG,MAAM,CAACd,KAAK,CAAC,CAACe,OAAO,QAAQ,GAAG,CAAC,CAAC;AACvD,CAAC;AAED;;CAEC,GACD,OAAO,SAASC,QAAQ,CAACC,KAA4B,EAAEC,IAAkB,EAAE;IACzE,yDAAyD;IACzD,MAAMC,cAAc,GAAG;QACrB5B,IAAI,EAAE,OAAO;QACb6B,WAAW,EAAE;AAAC,aAAC;YAAE,KAAK;SAAC;QACvBC,SAAS,EAAE;YACTC,SAAS,EAAE,CAACtB,KAAa,GAAK;gBAC5B,OAAOtB,WAAW,CAACsB,KAAK,EAAEkB,IAAI,CAAC,CAAC;YAClC,CAAC;SACF;KACF,AAAC;IACF,OAAO;QAACzC,KAAK,CAAC0C,cAAc,EAAEF,KAAK,CAAC;KAAC,CAAC;AACxC,CAAC"}
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ export declare type OptionsEditorColumnProps = {
3
+ /**
4
+ * Components to render in the column. These will usually be
5
+ * `OptionsEditorGroup` components.
6
+ */
7
+ children: React.ReactNode;
8
+ };
9
+ /**
10
+ * Lay out content in a column within panel options.
11
+ */
12
+ export declare const OptionsEditorColumn: ({ children }: OptionsEditorColumnProps) => JSX.Element;
13
+ //# sourceMappingURL=OptionsEditorColumn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OptionsEditorColumn.d.ts","sourceRoot":"","sources":["../../src/OptionsEditorLayout/OptionsEditorColumn.tsx"],"names":[],"mappings":";AAeA,oBAAY,wBAAwB,GAAG;IACrC;;;OAGG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,iBAAkB,wBAAwB,gBAMzE,CAAC"}
@@ -0,0 +1,28 @@
1
+ // Copyright 2022 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 } from "react/jsx-runtime";
14
+ import { Grid, Stack } from '@mui/material';
15
+ /**
16
+ * Lay out content in a column within panel options.
17
+ */ export const OptionsEditorColumn = ({ children })=>{
18
+ return /*#__PURE__*/ _jsx(Grid, {
19
+ item: true,
20
+ xs: 4,
21
+ children: /*#__PURE__*/ _jsx(Stack, {
22
+ spacing: 3,
23
+ children: children
24
+ })
25
+ });
26
+ };
27
+
28
+ //# sourceMappingURL=OptionsEditorColumn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/OptionsEditorLayout/OptionsEditorColumn.tsx"],"sourcesContent":["// Copyright 2022 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 { Grid, Stack } from '@mui/material';\n\nexport type OptionsEditorColumnProps = {\n /**\n * Components to render in the column. These will usually be\n * `OptionsEditorGroup` components.\n */\n children: React.ReactNode;\n};\n\n/**\n * Lay out content in a column within panel options.\n */\nexport const OptionsEditorColumn = ({ children }: OptionsEditorColumnProps) => {\n return (\n <Grid item xs={4}>\n <Stack spacing={3}>{children}</Stack>\n </Grid>\n );\n};\n"],"names":["Grid","Stack","OptionsEditorColumn","children","item","xs","spacing"],"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,IAAI,EAAEC,KAAK,QAAQ,eAAe,CAAC;AAU5C;;CAEC,GACD,OAAO,MAAMC,mBAAmB,GAAG,CAAC,EAAEC,QAAQ,CAAA,EAA4B,GAAK;IAC7E,qBACE,KAACH,IAAI;QAACI,IAAI;QAACC,EAAE,EAAE,CAAC;kBACd,cAAA,KAACJ,KAAK;YAACK,OAAO,EAAE,CAAC;sBAAGH,QAAQ;UAAS;MAChC,CACP;AACJ,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { FormControlLabelProps } from '@mui/material';
3
+ export declare type OptionsEditorControlProps = Pick<FormControlLabelProps, 'label' | 'control'>;
4
+ export declare const OptionsEditorControl: ({ label, control }: OptionsEditorControlProps) => JSX.Element;
5
+ //# sourceMappingURL=OptionsEditorControl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OptionsEditorControl.d.ts","sourceRoot":"","sources":["../../src/OptionsEditorLayout/OptionsEditorControl.tsx"],"names":[],"mappings":";AAaA,OAAO,EAA0B,qBAAqB,EAAc,MAAM,eAAe,CAAC;AAI1F,oBAAY,yBAAyB,GAAG,IAAI,CAAC,qBAAqB,EAAE,OAAO,GAAG,SAAS,CAAC,CAAC;AAEzF,eAAO,MAAM,oBAAoB,uBAAwB,yBAAyB,gBAkBjF,CAAC"}
@@ -0,0 +1,50 @@
1
+ // Copyright 2022 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 { FormControl, FormLabel, Stack, Box } from '@mui/material';
15
+ import React from 'react';
16
+ import { useId } from '../utils';
17
+ export const OptionsEditorControl = ({ label , control })=>{
18
+ // Make sure we have a unique ID we can use for associating labels and
19
+ // controls for a11y.
20
+ const generatedControlId = useId('EditorSectionControl');
21
+ const controlId = `${generatedControlId}-control`;
22
+ const controlProps = {
23
+ id: controlId
24
+ };
25
+ return /*#__PURE__*/ _jsx(FormControl, {
26
+ children: /*#__PURE__*/ _jsxs(Stack, {
27
+ direction: "row",
28
+ alignItems: "center",
29
+ justifyContent: "space-between",
30
+ children: [
31
+ /*#__PURE__*/ _jsx(FormLabel, {
32
+ htmlFor: controlId,
33
+ children: label
34
+ }),
35
+ /*#__PURE__*/ _jsxs(Box, {
36
+ sx: {
37
+ width: '160px',
38
+ textAlign: 'right'
39
+ },
40
+ children: [
41
+ " ",
42
+ /*#__PURE__*/ React.cloneElement(control, controlProps)
43
+ ]
44
+ })
45
+ ]
46
+ })
47
+ });
48
+ };
49
+
50
+ //# sourceMappingURL=OptionsEditorControl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/OptionsEditorLayout/OptionsEditorControl.tsx"],"sourcesContent":["// Copyright 2022 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 { FormControl, FormLabel, FormControlLabelProps, Stack, Box } from '@mui/material';\nimport React from 'react';\nimport { useId } from '../utils';\n\nexport type OptionsEditorControlProps = Pick<FormControlLabelProps, 'label' | 'control'>;\n\nexport const OptionsEditorControl = ({ label, control }: OptionsEditorControlProps) => {\n // Make sure we have a unique ID we can use for associating labels and\n // controls for a11y.\n const generatedControlId = useId('EditorSectionControl');\n const controlId = `${generatedControlId}-control`;\n\n const controlProps = {\n id: controlId,\n };\n\n return (\n <FormControl>\n <Stack direction=\"row\" alignItems=\"center\" justifyContent=\"space-between\">\n <FormLabel htmlFor={controlId}>{label}</FormLabel>\n <Box sx={{ width: '160px', textAlign: 'right' }}> {React.cloneElement(control, controlProps)}</Box>\n </Stack>\n </FormControl>\n );\n};\n"],"names":["FormControl","FormLabel","Stack","Box","React","useId","OptionsEditorControl","label","control","generatedControlId","controlId","controlProps","id","direction","alignItems","justifyContent","htmlFor","sx","width","textAlign","cloneElement"],"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,WAAW,EAAEC,SAAS,EAAyBC,KAAK,EAAEC,GAAG,QAAQ,eAAe,CAAC;AAC1F,OAAOC,KAAK,MAAM,OAAO,CAAC;AAC1B,SAASC,KAAK,QAAQ,UAAU,CAAC;AAIjC,OAAO,MAAMC,oBAAoB,GAAG,CAAC,EAAEC,KAAK,CAAA,EAAEC,OAAO,CAAA,EAA6B,GAAK;IACrF,sEAAsE;IACtE,qBAAqB;IACrB,MAAMC,kBAAkB,GAAGJ,KAAK,CAAC,sBAAsB,CAAC,AAAC;IACzD,MAAMK,SAAS,GAAG,CAAC,EAAED,kBAAkB,CAAC,QAAQ,CAAC,AAAC;IAElD,MAAME,YAAY,GAAG;QACnBC,EAAE,EAAEF,SAAS;KACd,AAAC;IAEF,qBACE,KAACV,WAAW;kBACV,cAAA,MAACE,KAAK;YAACW,SAAS,EAAC,KAAK;YAACC,UAAU,EAAC,QAAQ;YAACC,cAAc,EAAC,eAAe;;8BACvE,KAACd,SAAS;oBAACe,OAAO,EAAEN,SAAS;8BAAGH,KAAK;kBAAa;8BAClD,MAACJ,GAAG;oBAACc,EAAE,EAAE;wBAAEC,KAAK,EAAE,OAAO;wBAAEC,SAAS,EAAE,OAAO;qBAAE;;wBAAE,GAAC;sCAACf,KAAK,CAACgB,YAAY,CAACZ,OAAO,EAAEG,YAAY,CAAC;;kBAAO;;UAC7F;MACI,CACd;AACJ,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ export declare type OptionsEditorGridProps = {
3
+ /**
4
+ * 1-3 `OptionsEditorColumn` components to render content in columns.
5
+ */
6
+ children: React.ReactNode;
7
+ };
8
+ /**
9
+ * Top level grid container used to lay out content for editing in panel
10
+ * options.
11
+ */
12
+ export declare const OptionsEditorGrid: ({ children }: OptionsEditorGridProps) => JSX.Element;
13
+ //# sourceMappingURL=OptionsEditorGrid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OptionsEditorGrid.d.ts","sourceRoot":"","sources":["../../src/OptionsEditorLayout/OptionsEditorGrid.tsx"],"names":[],"mappings":";AAeA,oBAAY,sBAAsB,GAAG;IACnC;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,iBAAkB,sBAAsB,gBAMrE,CAAC"}
@@ -0,0 +1,26 @@
1
+ // Copyright 2022 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 } from "react/jsx-runtime";
14
+ import { Grid } from '@mui/material';
15
+ /**
16
+ * Top level grid container used to lay out content for editing in panel
17
+ * options.
18
+ */ export const OptionsEditorGrid = ({ children })=>{
19
+ return /*#__PURE__*/ _jsx(Grid, {
20
+ container: true,
21
+ spacing: 8,
22
+ children: children
23
+ });
24
+ };
25
+
26
+ //# sourceMappingURL=OptionsEditorGrid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/OptionsEditorLayout/OptionsEditorGrid.tsx"],"sourcesContent":["// Copyright 2022 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 { Grid } from '@mui/material';\n\nexport type OptionsEditorGridProps = {\n /**\n * 1-3 `OptionsEditorColumn` components to render content in columns.\n */\n children: React.ReactNode;\n};\n\n/**\n * Top level grid container used to lay out content for editing in panel\n * options.\n */\nexport const OptionsEditorGrid = ({ children }: OptionsEditorGridProps) => {\n return (\n <Grid container spacing={8}>\n {children}\n </Grid>\n );\n};\n"],"names":["Grid","OptionsEditorGrid","children","container","spacing"],"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,IAAI,QAAQ,eAAe,CAAC;AASrC;;;CAGC,GACD,OAAO,MAAMC,iBAAiB,GAAG,CAAC,EAAEC,QAAQ,CAAA,EAA0B,GAAK;IACzE,qBACE,KAACF,IAAI;QAACG,SAAS;QAACC,OAAO,EAAE,CAAC;kBACvBF,QAAQ;MACJ,CACP;AACJ,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ export declare type OptionsEditorGroupProps = {
3
+ /**
4
+ * Text that communicates the purpose of the grouping.
5
+ */
6
+ title: string;
7
+ children: React.ReactNode;
8
+ };
9
+ /**
10
+ * Group similar content within panel options.
11
+ */
12
+ export declare const OptionsEditorGroup: ({ title, children }: OptionsEditorGroupProps) => JSX.Element;
13
+ //# sourceMappingURL=OptionsEditorGroup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OptionsEditorGroup.d.ts","sourceRoot":"","sources":["../../src/OptionsEditorLayout/OptionsEditorGroup.tsx"],"names":[],"mappings":";AAeA,oBAAY,uBAAuB,GAAG;IACpC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,wBAAyB,uBAAuB,gBAe9E,CAAC"}
@@ -0,0 +1,36 @@
1
+ // Copyright 2022 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 { Box, Typography, Stack } from '@mui/material';
15
+ /**
16
+ * Group similar content within panel options.
17
+ */ export const OptionsEditorGroup = ({ title , children })=>{
18
+ return /*#__PURE__*/ _jsxs(Box, {
19
+ children: [
20
+ /*#__PURE__*/ _jsx(Typography, {
21
+ variant: "overline",
22
+ component: "h4",
23
+ borderBottom: 1,
24
+ borderColor: "grey.300",
25
+ marginBottom: (theme)=>theme.spacing(1),
26
+ children: title
27
+ }),
28
+ /*#__PURE__*/ _jsx(Stack, {
29
+ spacing: 1,
30
+ children: children
31
+ })
32
+ ]
33
+ });
34
+ };
35
+
36
+ //# sourceMappingURL=OptionsEditorGroup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/OptionsEditorLayout/OptionsEditorGroup.tsx"],"sourcesContent":["// Copyright 2022 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 { Box, Typography, Stack } from '@mui/material';\n\nexport type OptionsEditorGroupProps = {\n /**\n * Text that communicates the purpose of the grouping.\n */\n title: string;\n children: React.ReactNode;\n};\n\n/**\n * Group similar content within panel options.\n */\nexport const OptionsEditorGroup = ({ title, children }: OptionsEditorGroupProps) => {\n return (\n <Box>\n <Typography\n variant=\"overline\"\n component=\"h4\"\n borderBottom={1}\n borderColor=\"grey.300\"\n marginBottom={(theme) => theme.spacing(1)}\n >\n {title}\n </Typography>\n <Stack spacing={1}>{children}</Stack>\n </Box>\n );\n};\n"],"names":["Box","Typography","Stack","OptionsEditorGroup","title","children","variant","component","borderBottom","borderColor","marginBottom","theme","spacing"],"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,GAAG,EAAEC,UAAU,EAAEC,KAAK,QAAQ,eAAe,CAAC;AAUvD;;CAEC,GACD,OAAO,MAAMC,kBAAkB,GAAG,CAAC,EAAEC,KAAK,CAAA,EAAEC,QAAQ,CAAA,EAA2B,GAAK;IAClF,qBACE,MAACL,GAAG;;0BACF,KAACC,UAAU;gBACTK,OAAO,EAAC,UAAU;gBAClBC,SAAS,EAAC,IAAI;gBACdC,YAAY,EAAE,CAAC;gBACfC,WAAW,EAAC,UAAU;gBACtBC,YAAY,EAAE,CAACC,KAAK,GAAKA,KAAK,CAACC,OAAO,CAAC,CAAC,CAAC;0BAExCR,KAAK;cACK;0BACb,KAACF,KAAK;gBAACU,OAAO,EAAE,CAAC;0BAAGP,QAAQ;cAAS;;MACjC,CACN;AACJ,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './OptionsEditorColumn';
2
+ export * from './OptionsEditorControl';
3
+ export * from './OptionsEditorGrid';
4
+ export * from './OptionsEditorGroup';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/OptionsEditorLayout/index.ts"],"names":[],"mappings":"AAaA,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,18 @@
1
+ // Copyright 2022 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 './OptionsEditorColumn';
14
+ export * from './OptionsEditorControl';
15
+ export * from './OptionsEditorGrid';
16
+ export * from './OptionsEditorGroup';
17
+
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/OptionsEditorLayout/index.ts"],"sourcesContent":["// Copyright 2022 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 './OptionsEditorColumn';\nexport * from './OptionsEditorControl';\nexport * from './OptionsEditorGrid';\nexport * from './OptionsEditorGroup';\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,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC"}
@@ -2,6 +2,7 @@
2
2
  interface SeriesInfoProps {
3
3
  seriesName: string;
4
4
  y: number;
5
+ formattedY: string;
5
6
  markerColor: string;
6
7
  totalSeries: number;
7
8
  wrapLabels?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"SeriesInfo.d.ts","sourceRoot":"","sources":["../../src/Tooltip/SeriesInfo.tsx"],"names":[],"mappings":";AAiBA,UAAU,eAAe;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,CAAC,EAAE,MAAM,CAAC;IACV,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,eAkHhD"}
1
+ {"version":3,"file":"SeriesInfo.d.ts","sourceRoot":"","sources":["../../src/Tooltip/SeriesInfo.tsx"],"names":[],"mappings":";AAiBA,UAAU,eAAe;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,CAAC,EAAE,MAAM,CAAC;IACV,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,eAkHhD"}