@perses-dev/components 0.13.0 → 0.15.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.
- package/dist/{TimeRangeSelector → DateTimeRangePicker}/AbsoluteTimePicker.d.ts +0 -0
- package/dist/DateTimeRangePicker/AbsoluteTimePicker.d.ts.map +1 -0
- package/dist/{TimeRangeSelector → DateTimeRangePicker}/AbsoluteTimePicker.js +38 -33
- package/dist/DateTimeRangePicker/AbsoluteTimePicker.js.map +1 -0
- package/dist/DateTimeRangePicker/DateTimeRangePicker.d.ts +11 -0
- package/dist/DateTimeRangePicker/DateTimeRangePicker.d.ts.map +1 -0
- package/dist/DateTimeRangePicker/DateTimeRangePicker.js +77 -0
- package/dist/DateTimeRangePicker/DateTimeRangePicker.js.map +1 -0
- package/dist/{TimeRangeSelector → DateTimeRangePicker}/TimeRangeSelector.d.ts +0 -0
- package/dist/DateTimeRangePicker/TimeRangeSelector.d.ts.map +1 -0
- package/dist/{TimeRangeSelector → DateTimeRangePicker}/TimeRangeSelector.js +0 -0
- package/dist/DateTimeRangePicker/TimeRangeSelector.js.map +1 -0
- package/dist/{TimeRangeSelector → DateTimeRangePicker}/index.d.ts +1 -0
- package/dist/DateTimeRangePicker/index.d.ts.map +1 -0
- package/dist/{TimeRangeSelector → DateTimeRangePicker}/index.js +1 -0
- package/dist/DateTimeRangePicker/index.js.map +1 -0
- package/dist/{TimeRangeSelector → DateTimeRangePicker}/utils.d.ts +0 -0
- package/dist/DateTimeRangePicker/utils.d.ts.map +1 -0
- package/dist/{TimeRangeSelector → DateTimeRangePicker}/utils.js +0 -0
- package/dist/DateTimeRangePicker/utils.js.map +1 -0
- package/dist/Drawer/Drawer.d.ts.map +1 -1
- package/dist/Drawer/Drawer.js +0 -1
- package/dist/Drawer/Drawer.js.map +1 -1
- package/dist/GaugeChart/GaugeChart.js +3 -3
- package/dist/GaugeChart/GaugeChart.js.map +1 -1
- package/dist/Legend/CompactLegend.d.ts +6 -1
- package/dist/Legend/CompactLegend.d.ts.map +1 -1
- package/dist/Legend/CompactLegend.js +16 -7
- package/dist/Legend/CompactLegend.js.map +1 -1
- package/dist/Legend/Legend.d.ts.map +1 -1
- package/dist/Legend/Legend.js +4 -9
- package/dist/Legend/Legend.js.map +1 -1
- package/dist/Legend/ListLegend.d.ts +3 -0
- package/dist/Legend/ListLegend.d.ts.map +1 -1
- package/dist/Legend/ListLegend.js +18 -2
- package/dist/Legend/ListLegend.js.map +1 -1
- package/dist/Legend/ListLegendItem.d.ts +2 -1
- package/dist/Legend/ListLegendItem.d.ts.map +1 -1
- package/dist/Legend/ListLegendItem.js +11 -9
- package/dist/Legend/ListLegendItem.js.map +1 -1
- package/dist/LineChart/LineChart.js +1 -1
- package/dist/LineChart/LineChart.js.map +1 -1
- package/dist/StatChart/StatChart.js +1 -1
- package/dist/StatChart/StatChart.js.map +1 -1
- package/dist/StatChart/StatChart.test.js +1 -2
- package/dist/StatChart/StatChart.test.js.map +1 -1
- package/dist/cjs/{TimeRangeSelector → DateTimeRangePicker}/AbsoluteTimePicker.js +37 -32
- package/dist/cjs/DateTimeRangePicker/DateTimeRangePicker.js +83 -0
- package/dist/cjs/{TimeRangeSelector → DateTimeRangePicker}/TimeRangeSelector.js +0 -0
- package/dist/cjs/{TimeRangeSelector → DateTimeRangePicker}/index.js +1 -0
- package/dist/cjs/{TimeRangeSelector → DateTimeRangePicker}/utils.js +0 -0
- package/dist/cjs/Drawer/Drawer.js +0 -1
- package/dist/cjs/GaugeChart/GaugeChart.js +3 -3
- package/dist/cjs/Legend/CompactLegend.js +12 -6
- package/dist/cjs/Legend/Legend.js +4 -9
- package/dist/cjs/Legend/ListLegend.js +15 -1
- package/dist/cjs/Legend/ListLegendItem.js +48 -13
- package/dist/cjs/LineChart/LineChart.js +1 -1
- package/dist/cjs/StatChart/StatChart.js +1 -1
- package/dist/cjs/StatChart/StatChart.test.js +2 -3
- package/dist/cjs/context/ChartsThemeProvider.js +1 -6
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/model/units.js +1 -1
- package/dist/cjs/test/index.js +0 -1
- package/dist/cjs/test-utils/index.js +28 -0
- package/dist/cjs/{test → test-utils}/theme.js +0 -1
- package/dist/cjs/utils/mathjs.js +25 -0
- package/dist/cjs/utils/theme-gen.js +1 -2
- package/dist/cjs/utils/theme-gen.test.js +1 -2
- package/dist/context/ChartsThemeProvider.d.ts +0 -1
- package/dist/context/ChartsThemeProvider.d.ts.map +1 -1
- package/dist/context/ChartsThemeProvider.js +1 -6
- package/dist/context/ChartsThemeProvider.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/model/theme.d.ts +0 -1
- package/dist/model/theme.d.ts.map +1 -1
- package/dist/model/theme.js.map +1 -1
- package/dist/model/units.js +1 -1
- package/dist/model/units.js.map +1 -1
- package/dist/test/index.d.ts +0 -1
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +0 -1
- package/dist/test/index.js.map +1 -1
- package/dist/test-utils/index.d.ts +2 -0
- package/dist/test-utils/index.d.ts.map +1 -0
- package/dist/test-utils/index.js +15 -0
- package/dist/test-utils/index.js.map +1 -0
- package/dist/test-utils/theme.d.ts +3 -0
- package/dist/test-utils/theme.d.ts.map +1 -0
- package/dist/{test → test-utils}/theme.js +0 -1
- package/dist/test-utils/theme.js.map +1 -0
- package/dist/utils/mathjs.d.ts +6 -0
- package/dist/utils/mathjs.d.ts.map +1 -0
- package/dist/utils/mathjs.js +20 -0
- package/dist/utils/mathjs.js.map +1 -0
- package/dist/utils/theme-gen.d.ts +1 -1
- package/dist/utils/theme-gen.d.ts.map +1 -1
- package/dist/utils/theme-gen.js +1 -2
- package/dist/utils/theme-gen.js.map +1 -1
- package/dist/utils/theme-gen.test.js +1 -2
- package/dist/utils/theme-gen.test.js.map +1 -1
- package/package.json +7 -2
- package/dist/TimeRangeSelector/AbsoluteTimePicker.d.ts.map +0 -1
- package/dist/TimeRangeSelector/AbsoluteTimePicker.js.map +0 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.d.ts.map +0 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.js.map +0 -1
- package/dist/TimeRangeSelector/index.d.ts.map +0 -1
- package/dist/TimeRangeSelector/index.js.map +0 -1
- package/dist/TimeRangeSelector/utils.d.ts.map +0 -1
- package/dist/TimeRangeSelector/utils.js.map +0 -1
- package/dist/test/theme.d.ts +0 -3
- package/dist/test/theme.d.ts.map +0 -1
- package/dist/test/theme.js.map +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { ListItemProps } from '@mui/material';
|
|
2
3
|
import { LegendItem } from '../model';
|
|
3
|
-
interface ListLegendItemProps {
|
|
4
|
+
interface ListLegendItemProps extends ListItemProps {
|
|
4
5
|
item: LegendItem;
|
|
5
6
|
}
|
|
6
7
|
export declare const ListLegendItem: React.NamedExoticComponent<ListLegendItemProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListLegendItem.d.ts","sourceRoot":"","sources":["../../src/Legend/ListLegendItem.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ListLegendItem.d.ts","sourceRoot":"","sources":["../../src/Legend/ListLegendItem.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAA+B,aAAa,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAItC,UAAU,mBAAoB,SAAQ,aAAa;IACjD,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,eAAO,MAAM,cAAc,iDAuBzB,CAAC"}
|
|
@@ -10,20 +10,22 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { createElement as _createElement } from "react";
|
|
14
15
|
import React from 'react';
|
|
15
16
|
import { Box, ListItemText, ListItem } from '@mui/material';
|
|
17
|
+
import { combineSx } from '../utils';
|
|
16
18
|
import { LegendColorBadge } from './LegendColorBadge';
|
|
17
|
-
export const ListLegendItem = /*#__PURE__*/ React.memo(function ListLegendItem({ item
|
|
18
|
-
return /*#__PURE__*/
|
|
19
|
-
|
|
20
|
-
sx: {
|
|
21
|
-
display: 'flex',
|
|
22
|
-
maxWidth: 270,
|
|
19
|
+
export const ListLegendItem = /*#__PURE__*/ React.memo(function ListLegendItem({ item , sx , ...others }) {
|
|
20
|
+
return /*#__PURE__*/ _createElement(ListItem, {
|
|
21
|
+
...others,
|
|
22
|
+
sx: combineSx({
|
|
23
23
|
padding: 0,
|
|
24
24
|
cursor: 'pointer'
|
|
25
|
-
},
|
|
25
|
+
}, sx),
|
|
26
|
+
dense: true,
|
|
26
27
|
"data-testid": `legend-item-${item.color}`,
|
|
28
|
+
key: item.id,
|
|
27
29
|
onClick: item.onClick,
|
|
28
30
|
selected: item.isSelected,
|
|
29
31
|
children: [
|
|
@@ -40,7 +42,7 @@ export const ListLegendItem = /*#__PURE__*/ React.memo(function ListLegendItem({
|
|
|
40
42
|
primary: item.label
|
|
41
43
|
})
|
|
42
44
|
]
|
|
43
|
-
}
|
|
45
|
+
});
|
|
44
46
|
});
|
|
45
47
|
|
|
46
48
|
//# sourceMappingURL=ListLegendItem.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Legend/ListLegendItem.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 React from 'react';\nimport { Box, ListItemText, ListItem } from '@mui/material';\nimport { LegendItem } from '../model';\nimport { LegendColorBadge } from './LegendColorBadge';\n\ninterface ListLegendItemProps {\n item: LegendItem;\n}\n\nexport const ListLegendItem = React.memo(function ListLegendItem({ item }: ListLegendItemProps) {\n return (\n <ListItem\n
|
|
1
|
+
{"version":3,"sources":["../../src/Legend/ListLegendItem.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 React from 'react';\nimport { Box, ListItemText, ListItem, ListItemProps } from '@mui/material';\nimport { LegendItem } from '../model';\nimport { combineSx } from '../utils';\nimport { LegendColorBadge } from './LegendColorBadge';\n\ninterface ListLegendItemProps extends ListItemProps {\n item: LegendItem;\n}\n\nexport const ListLegendItem = React.memo(function ListLegendItem({ item, sx, ...others }: ListLegendItemProps) {\n return (\n <ListItem\n {...others}\n sx={combineSx(\n {\n padding: 0,\n cursor: 'pointer',\n },\n sx\n )}\n dense={true}\n data-testid={`legend-item-${item.color}`}\n key={item.id}\n onClick={item.onClick}\n selected={item.isSelected}\n >\n <Box sx={{ display: 'flex', alignItems: 'center' }}>\n <LegendColorBadge color={item.color} />\n </Box>\n <ListItemText primary={item.label}></ListItemText>\n </ListItem>\n );\n});\n"],"names":["React","Box","ListItemText","ListItem","combineSx","LegendColorBadge","ListLegendItem","memo","item","sx","others","padding","cursor","dense","data-testid","color","key","id","onClick","selected","isSelected","display","alignItems","primary","label"],"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,GAAG,EAAEC,YAAY,EAAEC,QAAQ,QAAuB,eAAe,CAAC;AAE3E,SAASC,SAAS,QAAQ,UAAU,CAAC;AACrC,SAASC,gBAAgB,QAAQ,oBAAoB,CAAC;AAMtD,OAAO,MAAMC,cAAc,iBAAGN,KAAK,CAACO,IAAI,CAAC,SAASD,cAAc,CAAC,EAAEE,IAAI,CAAA,EAAEC,EAAE,CAAA,EAAE,GAAGC,MAAM,EAAuB,EAAE;IAC7G,qBACE,eAACP,QAAQ;QACN,GAAGO,MAAM;QACVD,EAAE,EAAEL,SAAS,CACX;YACEO,OAAO,EAAE,CAAC;YACVC,MAAM,EAAE,SAAS;SAClB,EACDH,EAAE,CACH;QACDI,KAAK,EAAE,IAAI;QACXC,aAAW,EAAE,CAAC,YAAY,EAAEN,IAAI,CAACO,KAAK,CAAC,CAAC;QACxCC,GAAG,EAAER,IAAI,CAACS,EAAE;QACZC,OAAO,EAAEV,IAAI,CAACU,OAAO;QACrBC,QAAQ,EAAEX,IAAI,CAACY,UAAU;;0BAEzB,KAACnB,GAAG;gBAACQ,EAAE,EAAE;oBAAEY,OAAO,EAAE,MAAM;oBAAEC,UAAU,EAAE,QAAQ;iBAAE;0BAChD,cAAA,KAACjB,gBAAgB;oBAACU,KAAK,EAAEP,IAAI,CAACO,KAAK;kBAAI;cACnC;0BACN,KAACb,YAAY;gBAACqB,OAAO,EAAEf,IAAI,CAACgB,KAAK;cAAiB;;MACzC,CACX;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -187,7 +187,7 @@ export function LineChart({ height , data , unit , grid , legend , visualMap , o
|
|
|
187
187
|
height: '100%'
|
|
188
188
|
},
|
|
189
189
|
option: option,
|
|
190
|
-
theme: chartsTheme.
|
|
190
|
+
theme: chartsTheme.echartsTheme,
|
|
191
191
|
onEvents: handleEvents,
|
|
192
192
|
_instance: chartRef
|
|
193
193
|
})
|
|
@@ -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.themeName}\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","themeName","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,CA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JC,MAAM;YACNC,SAAS;SACV,AAAC;QAEF,OAAOoC,MAAM,CAAC;IAChB,CAAC,EAAE;QAACxC,IAAI;QAAEE,IAAI;QAAEC,MAAM;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,SAAS;gBAC5BC,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} 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,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;AAClF,SAASC,WAAW,QAAqB,gBAAgB,CAAC;AAC1D,SAASC,cAAc,QAAQ,gCAAgC,CAAC;AAChE,SAASC,OAAO,QAAQ,oBAAoB,CAAC;AAC7C,SAASC,cAAc,EAAEC,YAAY,EAAEC,YAAY,EAAEC,gBAAgB,QAAuB,SAAS,CAAC;AAEtGtB,GAAG,CAAC;IACFE,gBAAgB;IAChBC,aAAa;IACbC,iBA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;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 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/StatChart/StatChart.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 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 PANEL_PADDING = 32;\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 return (\n <Box>\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 })}\n >\n {formattedValue}\n </Typography>\n {sparkline !== undefined && (\n <EChart\n sx={{\n width: width + PANEL_PADDING, // allows sparkline to extend to edge of panel\n height: height,\n position: 'absolute',\n bottom: 0,\n left: 0,\n }}\n option={option}\n theme={chartsTheme.
|
|
1
|
+
{"version":3,"sources":["../../src/StatChart/StatChart.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 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 PANEL_PADDING = 32;\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 return (\n <Box>\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 })}\n >\n {formattedValue}\n </Typography>\n {sparkline !== undefined && (\n <EChart\n sx={{\n width: width + PANEL_PADDING, // allows sparkline to extend to edge of panel\n height: height,\n position: 'absolute',\n bottom: 0,\n left: 0,\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n renderer=\"svg\"\n />\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","PANEL_PADDING","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","variant","sx","theme","color","palette","text","primary","fontSize","position","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,OAAOA,KAAK,IAAIC,OAAO,QAAQ,OAAO,CAAC;AACvC,SAASC,GAAG,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAChD,SAASC,KAAK,QAAQ,WAAW,CAAC;AAClC,SAASC,GAAG,QAA2B,cAAc,CAAC;AACtD,SAASC,UAAU,IAAIC,iBAAiB,QAA2B,gBAAgB,CAAC;AACpF,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;AAGnCZ,GAAG,CAAC;IACFE,iBAAiB;IACjBE,gBAAgB;IAChBC,aAAa;IACbC,gBAAgB;IAChBC,cAAc;IACdC,gBAAgB;IAChBC,cAAc;CACf,CAAC,CAAC;AAEH,MAAMI,aAAa,GAAG,EAAE,AAAC;AACzB,MAAMC,cAAc,GAAG,EAAE,AAAC;AAC1B,MAAMC,cAAc,GAAG,EAAE,AAAC;AAgB1B,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,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';
|
|
15
15
|
import { render, screen } from '@testing-library/react';
|
|
16
16
|
import { ChartsThemeProvider } from '../context/ChartsThemeProvider';
|
|
17
|
-
import { testChartsTheme } from '../test';
|
|
17
|
+
import { testChartsTheme } from '../test-utils';
|
|
18
18
|
import { StatChart } from './StatChart';
|
|
19
19
|
describe('StatChart', ()=>{
|
|
20
20
|
const contentDimensions = {
|
|
@@ -57,7 +57,6 @@ describe('StatChart', ()=>{
|
|
|
57
57
|
describe('Render default options (no sparkline)', ()=>{
|
|
58
58
|
it('should render', ()=>{
|
|
59
59
|
render(/*#__PURE__*/ _jsx(ChartsThemeProvider, {
|
|
60
|
-
themeName: "perses",
|
|
61
60
|
chartsTheme: testChartsTheme,
|
|
62
61
|
children: /*#__PURE__*/ _jsx(StatChart, {
|
|
63
62
|
width: contentDimensions.width,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/StatChart/StatChart.test.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 React from 'react';\nimport { render, screen } from '@testing-library/react';\nimport { ChartsThemeProvider } from '../context/ChartsThemeProvider';\nimport { UnitOptions } from '../model';\nimport { testChartsTheme } from '../test';\nimport { StatChart, StatChartData } from './StatChart';\n\ndescribe('StatChart', () => {\n const contentDimensions = {\n width: 200,\n height: 200,\n };\n\n const unit: UnitOptions = {\n kind: 'Decimal',\n decimal_places: 2,\n };\n\n const mockStatData: StatChartData = {\n calculatedValue: 7.72931659687181,\n name: 'Example Stat Chart',\n seriesData: {\n name: '(((count(count(node_cpu_seconds_total{job=\"example\"}) by (cpu))',\n values: [\n [1654006170000, 7.736401673473903],\n [1654006185000, 7.733891213538757],\n [1654006200000, 7.731101813010433],\n [1654006215000, 7.722454672079215],\n [1654006230000, 7.722733612256738],\n ],\n },\n };\n\n describe('Render default options (no sparkline)', () => {\n it('should render', () => {\n render(\n <ChartsThemeProvider
|
|
1
|
+
{"version":3,"sources":["../../src/StatChart/StatChart.test.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 React from 'react';\nimport { render, screen } from '@testing-library/react';\nimport { ChartsThemeProvider } from '../context/ChartsThemeProvider';\nimport { UnitOptions } from '../model';\nimport { testChartsTheme } from '../test-utils';\nimport { StatChart, StatChartData } from './StatChart';\n\ndescribe('StatChart', () => {\n const contentDimensions = {\n width: 200,\n height: 200,\n };\n\n const unit: UnitOptions = {\n kind: 'Decimal',\n decimal_places: 2,\n };\n\n const mockStatData: StatChartData = {\n calculatedValue: 7.72931659687181,\n name: 'Example Stat Chart',\n seriesData: {\n name: '(((count(count(node_cpu_seconds_total{job=\"example\"}) by (cpu))',\n values: [\n [1654006170000, 7.736401673473903],\n [1654006185000, 7.733891213538757],\n [1654006200000, 7.731101813010433],\n [1654006215000, 7.722454672079215],\n [1654006230000, 7.722733612256738],\n ],\n },\n };\n\n describe('Render default options (no sparkline)', () => {\n it('should render', () => {\n render(\n <ChartsThemeProvider chartsTheme={testChartsTheme}>\n <StatChart\n width={contentDimensions.width}\n height={contentDimensions.height}\n data={mockStatData}\n unit={unit}\n />\n </ChartsThemeProvider>\n );\n expect(screen.getByText('7.73')).toBeInTheDocument();\n });\n });\n});\n"],"names":["React","render","screen","ChartsThemeProvider","testChartsTheme","StatChart","describe","contentDimensions","width","height","unit","kind","decimal_places","mockStatData","calculatedValue","name","seriesData","values","it","chartsTheme","data","expect","getByText","toBeInTheDocument"],"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,MAAM,QAAQ,wBAAwB,CAAC;AACxD,SAASC,mBAAmB,QAAQ,gCAAgC,CAAC;AAErE,SAASC,eAAe,QAAQ,eAAe,CAAC;AAChD,SAASC,SAAS,QAAuB,aAAa,CAAC;AAEvDC,QAAQ,CAAC,WAAW,EAAE,IAAM;IAC1B,MAAMC,iBAAiB,GAAG;QACxBC,KAAK,EAAE,GAAG;QACVC,MAAM,EAAE,GAAG;KACZ,AAAC;IAEF,MAAMC,IAAI,GAAgB;QACxBC,IAAI,EAAE,SAAS;QACfC,cAAc,EAAE,CAAC;KAClB,AAAC;IAEF,MAAMC,YAAY,GAAkB;QAClCC,eAAe,EAAE,gBAAgB;QACjCC,IAAI,EAAE,oBAAoB;QAC1BC,UAAU,EAAE;YACVD,IAAI,EAAE,iEAAiE;YACvEE,MAAM,EAAE;gBACN;AAAC,iCAAa;AAAE,qCAAiB;iBAAC;gBAClC;AAAC,iCAAa;AAAE,qCAAiB;iBAAC;gBAClC;AAAC,iCAAa;AAAE,qCAAiB;iBAAC;gBAClC;AAAC,iCAAa;AAAE,qCAAiB;iBAAC;gBAClC;AAAC,iCAAa;AAAE,qCAAiB;iBAAC;aACnC;SACF;KACF,AAAC;IAEFX,QAAQ,CAAC,uCAAuC,EAAE,IAAM;QACtDY,EAAE,CAAC,eAAe,EAAE,IAAM;YACxBjB,MAAM,eACJ,KAACE,mBAAmB;gBAACgB,WAAW,EAAEf,eAAe;0BAC/C,cAAA,KAACC,SAAS;oBACRG,KAAK,EAAED,iBAAiB,CAACC,KAAK;oBAC9BC,MAAM,EAAEF,iBAAiB,CAACE,MAAM;oBAChCW,IAAI,EAAEP,YAAY;oBAClBH,IAAI,EAAEA,IAAI;kBACV;cACkB,CACvB,CAAC;YACFW,MAAM,CAACnB,MAAM,CAACoB,SAAS,CAAC,MAAM,CAAC,CAAC,CAACC,iBAAiB,EAAE,CAAC;QACvD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -61,10 +61,10 @@ const AbsoluteTimePicker = ({ initialTimeRange , onChange })=>{
|
|
|
61
61
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_xDatePickers.LocalizationProvider, {
|
|
62
62
|
dateAdapter: _adapterDateFns.AdapterDateFns,
|
|
63
63
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
64
|
-
spacing:
|
|
65
|
-
sx: {
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
spacing: 2,
|
|
65
|
+
sx: (theme)=>({
|
|
66
|
+
padding: theme.spacing(1, 0, 2)
|
|
67
|
+
}),
|
|
68
68
|
children: [
|
|
69
69
|
showStartCalendar && /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
70
70
|
sx: (theme)=>({
|
|
@@ -80,7 +80,9 @@ const AbsoluteTimePicker = ({ initialTimeRange , onChange })=>{
|
|
|
80
80
|
}
|
|
81
81
|
}),
|
|
82
82
|
children: [
|
|
83
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(
|
|
83
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
84
|
+
variant: "h3",
|
|
85
|
+
padding: 1,
|
|
84
86
|
children: "Select Start Time"
|
|
85
87
|
}),
|
|
86
88
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_xDatePickers.StaticDateTimePicker, {
|
|
@@ -119,7 +121,9 @@ const AbsoluteTimePicker = ({ initialTimeRange , onChange })=>{
|
|
|
119
121
|
}
|
|
120
122
|
}),
|
|
121
123
|
children: [
|
|
122
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(
|
|
124
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
125
|
+
variant: "h3",
|
|
126
|
+
padding: 1,
|
|
123
127
|
children: "Select End Time"
|
|
124
128
|
}),
|
|
125
129
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_xDatePickers.StaticDateTimePicker, {
|
|
@@ -147,33 +151,34 @@ const AbsoluteTimePicker = ({ initialTimeRange , onChange })=>{
|
|
|
147
151
|
})
|
|
148
152
|
]
|
|
149
153
|
}),
|
|
150
|
-
/*#__PURE__*/ (0, _jsxRuntime.
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
154
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
155
|
+
direction: "row",
|
|
156
|
+
alignItems: "center",
|
|
157
|
+
gap: 1,
|
|
158
|
+
pl: 1,
|
|
159
|
+
pr: 1,
|
|
160
|
+
children: [
|
|
161
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
162
|
+
onChange: (event)=>{
|
|
163
|
+
// TODO: add helperText, fix validation after we decide on form state solution
|
|
164
|
+
updateDateRange(event.target.value, true);
|
|
165
|
+
},
|
|
166
|
+
value: (0, _dateFns.format)(timeRange.start, DATE_TIME_FORMAT),
|
|
167
|
+
label: "Start Time",
|
|
168
|
+
placeholder: "mm/dd/yyyy hh:mm",
|
|
169
|
+
// tel used to match MUI DateTimePicker, may change in future: https://github.com/mui/material-ui/issues/27590
|
|
170
|
+
type: "tel"
|
|
171
|
+
}),
|
|
172
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
173
|
+
onChange: (event)=>{
|
|
174
|
+
updateDateRange(event.target.value, false);
|
|
175
|
+
},
|
|
176
|
+
value: (0, _dateFns.format)(timeRange.end, DATE_TIME_FORMAT),
|
|
177
|
+
label: "End Time",
|
|
178
|
+
placeholder: "mm/dd/yyyy hh:mm",
|
|
179
|
+
type: "tel"
|
|
166
180
|
})
|
|
167
|
-
|
|
168
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
169
|
-
fullWidth: true,
|
|
170
|
-
onChange: (event)=>{
|
|
171
|
-
updateDateRange(event.target.value, false);
|
|
172
|
-
},
|
|
173
|
-
value: (0, _dateFns.format)(timeRange.end, DATE_TIME_FORMAT),
|
|
174
|
-
label: "End Time",
|
|
175
|
-
placeholder: "mm/dd/yyyy hh:mm",
|
|
176
|
-
type: "tel"
|
|
181
|
+
]
|
|
177
182
|
})
|
|
178
183
|
]
|
|
179
184
|
})
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "DateTimeRangePicker", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>DateTimeRangePicker
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _react = require("react");
|
|
23
|
+
const _material = require("@mui/material");
|
|
24
|
+
const _core = require("@perses-dev/core");
|
|
25
|
+
const _absoluteTimePicker = require("./AbsoluteTimePicker");
|
|
26
|
+
const _timeRangeSelector = require("./TimeRangeSelector");
|
|
27
|
+
function DateTimeRangePicker(props) {
|
|
28
|
+
const { value , onChange , timeOptions } = props;
|
|
29
|
+
const [showCustomDateSelector, setShowCustomDateSelector] = (0, _react.useState)(false);
|
|
30
|
+
const anchorEl = (0, _react.useRef)();
|
|
31
|
+
const convertedTimeRange = (0, _react.useMemo)(()=>{
|
|
32
|
+
return (0, _core.isRelativeTimeRange)(value) ? (0, _core.toAbsoluteTimeRange)(value) : value;
|
|
33
|
+
}, [
|
|
34
|
+
value
|
|
35
|
+
]);
|
|
36
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
37
|
+
direction: "row",
|
|
38
|
+
spacing: 1,
|
|
39
|
+
children: [
|
|
40
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Popover, {
|
|
41
|
+
anchorEl: anchorEl.current,
|
|
42
|
+
anchorOrigin: {
|
|
43
|
+
vertical: 'bottom',
|
|
44
|
+
horizontal: 'center'
|
|
45
|
+
},
|
|
46
|
+
open: showCustomDateSelector,
|
|
47
|
+
onClose: ()=>setShowCustomDateSelector(false),
|
|
48
|
+
sx: (theme)=>({
|
|
49
|
+
padding: theme.spacing(2)
|
|
50
|
+
}),
|
|
51
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_absoluteTimePicker.AbsoluteTimePicker, {
|
|
52
|
+
initialTimeRange: convertedTimeRange,
|
|
53
|
+
onChange: (value)=>{
|
|
54
|
+
onChange(value);
|
|
55
|
+
setShowCustomDateSelector(false);
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
}),
|
|
59
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.FormControl, {
|
|
60
|
+
fullWidth: true,
|
|
61
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
62
|
+
ref: anchorEl,
|
|
63
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_timeRangeSelector.TimeRangeSelector, {
|
|
64
|
+
timeOptions: timeOptions,
|
|
65
|
+
value: value,
|
|
66
|
+
onSelectChange: (event)=>{
|
|
67
|
+
const duration = event.target.value;
|
|
68
|
+
const relativeTimeInput = {
|
|
69
|
+
pastDuration: duration,
|
|
70
|
+
end: new Date()
|
|
71
|
+
};
|
|
72
|
+
onChange(relativeTimeInput);
|
|
73
|
+
setShowCustomDateSelector(false);
|
|
74
|
+
},
|
|
75
|
+
onCustomClick: ()=>{
|
|
76
|
+
setShowCustomDateSelector(true);
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
})
|
|
80
|
+
})
|
|
81
|
+
]
|
|
82
|
+
});
|
|
83
|
+
}
|
|
File without changes
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
+
_exportStar(require("./DateTimeRangePicker"), exports);
|
|
17
18
|
_exportStar(require("./TimeRangeSelector"), exports);
|
|
18
19
|
_exportStar(require("./AbsoluteTimePicker"), exports);
|
|
19
20
|
function _exportStar(from, to) {
|
|
File without changes
|
|
@@ -32,7 +32,6 @@ const Drawer = ({ anchor ='right' , isOpen , onClose , PaperProps , children , .
|
|
|
32
32
|
...PaperProps,
|
|
33
33
|
sx: (0, _utils.combineSx)({
|
|
34
34
|
width: `${DRAWER_DEFAULT_WIDTH}px`,
|
|
35
|
-
padding: (theme)=>theme.spacing(2),
|
|
36
35
|
overflow: 'hidden'
|
|
37
36
|
}, PaperProps === null || PaperProps === void 0 ? void 0 : PaperProps.sx)
|
|
38
37
|
},
|
|
@@ -54,7 +54,7 @@ function GaugeChart(props) {
|
|
|
54
54
|
'50%',
|
|
55
55
|
'65%'
|
|
56
56
|
],
|
|
57
|
-
radius: '
|
|
57
|
+
radius: '86%',
|
|
58
58
|
startAngle: 200,
|
|
59
59
|
endAngle: -20,
|
|
60
60
|
min: 0,
|
|
@@ -115,7 +115,7 @@ function GaugeChart(props) {
|
|
|
115
115
|
'50%',
|
|
116
116
|
'65%'
|
|
117
117
|
],
|
|
118
|
-
radius: '
|
|
118
|
+
radius: '100%',
|
|
119
119
|
startAngle: 200,
|
|
120
120
|
endAngle: -20,
|
|
121
121
|
min: 0,
|
|
@@ -173,6 +173,6 @@ function GaugeChart(props) {
|
|
|
173
173
|
height: height
|
|
174
174
|
},
|
|
175
175
|
option: option,
|
|
176
|
-
theme: chartsTheme.
|
|
176
|
+
theme: chartsTheme.echartsTheme
|
|
177
177
|
});
|
|
178
178
|
}
|
|
@@ -21,15 +21,21 @@ Object.defineProperty(exports, "CompactLegend", {
|
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
22
|
const _material = require("@mui/material");
|
|
23
23
|
const _listLegendItem = require("./ListLegendItem");
|
|
24
|
-
function CompactLegend({ items }) {
|
|
25
|
-
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.
|
|
26
|
-
direction: "row",
|
|
27
|
-
spacing: 2,
|
|
24
|
+
function CompactLegend({ height , items }) {
|
|
25
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
28
26
|
sx: {
|
|
29
|
-
|
|
27
|
+
width: '100%',
|
|
28
|
+
height,
|
|
29
|
+
paddingTop: 1,
|
|
30
|
+
overflowY: 'scroll'
|
|
30
31
|
},
|
|
31
32
|
children: items.map((item)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_listLegendItem.ListLegendItem, {
|
|
32
|
-
item: item
|
|
33
|
+
item: item,
|
|
34
|
+
sx: {
|
|
35
|
+
width: 'auto',
|
|
36
|
+
float: 'left',
|
|
37
|
+
paddingRight: 1.5
|
|
38
|
+
}
|
|
33
39
|
}, item.id))
|
|
34
40
|
});
|
|
35
41
|
}
|
|
@@ -27,7 +27,7 @@ function Legend({ width , height , options , data }) {
|
|
|
27
27
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
28
28
|
sx: {
|
|
29
29
|
width: width,
|
|
30
|
-
height:
|
|
30
|
+
height: '100%',
|
|
31
31
|
position: 'absolute',
|
|
32
32
|
top: 0,
|
|
33
33
|
right: 0,
|
|
@@ -38,13 +38,8 @@ function Legend({ width , height , options , data }) {
|
|
|
38
38
|
})
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
-
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
overflowY: 'scroll'
|
|
45
|
-
},
|
|
46
|
-
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_compactLegend.CompactLegend, {
|
|
47
|
-
items: data
|
|
48
|
-
})
|
|
41
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_compactLegend.CompactLegend, {
|
|
42
|
+
items: data,
|
|
43
|
+
height: height
|
|
49
44
|
});
|
|
50
45
|
}
|
|
@@ -22,9 +22,23 @@ const _jsxRuntime = require("react/jsx-runtime");
|
|
|
22
22
|
const _material = require("@mui/material");
|
|
23
23
|
const _listLegendItem = require("./ListLegendItem");
|
|
24
24
|
function ListLegend({ items }) {
|
|
25
|
+
// show full labels on hover when there are many total series
|
|
26
|
+
const truncateLabels = items.length > 5;
|
|
25
27
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.List, {
|
|
26
28
|
children: items.map((item)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_listLegendItem.ListLegendItem, {
|
|
27
|
-
item: item
|
|
29
|
+
item: item,
|
|
30
|
+
sx: {
|
|
31
|
+
width: 190,
|
|
32
|
+
textOverflow: 'ellipsis',
|
|
33
|
+
wordBreak: 'break-word',
|
|
34
|
+
overflow: truncateLabels ? 'hidden' : 'visible',
|
|
35
|
+
whiteSpace: truncateLabels ? 'nowrap' : 'normal',
|
|
36
|
+
// TODO: add optional hover effect to show unformatted label
|
|
37
|
+
'&:hover': {
|
|
38
|
+
overflow: 'visible',
|
|
39
|
+
whiteSpace: 'normal'
|
|
40
|
+
}
|
|
41
|
+
}
|
|
28
42
|
}, item.id))
|
|
29
43
|
});
|
|
30
44
|
}
|