@perses-dev/timeseries-chart-plugin 0.13.0-beta.2 → 0.13.0-rc.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/__mf/js/TimeSeriesChart.3eab0aad.js +7 -0
- package/__mf/js/async/121.c3c0e54f.js +2 -0
- package/__mf/js/async/137.59c998ab.js +38 -0
- package/__mf/js/async/177.2fef2962.js +1 -0
- package/__mf/js/async/187.f5e8932b.js +1 -0
- package/__mf/js/async/192.c3dd56d5.js +1 -0
- package/__mf/js/async/2.60fa4a40.js +1 -0
- package/__mf/js/async/208.b9f374ad.js +7 -0
- package/__mf/js/async/235.d23c8ef0.js +1 -0
- package/__mf/js/async/274.72dfa9c8.js +2 -0
- package/__mf/js/async/356.8170c96d.js +1 -0
- package/__mf/js/async/392.b9ba5bf2.js +2 -0
- package/__mf/js/async/470.e09f33b7.js +2 -0
- package/__mf/js/async/491.85194549.js +1 -0
- package/__mf/js/async/52.0d78de2b.js +1 -0
- package/__mf/js/async/527.f97d1b86.js +110 -0
- package/__mf/js/async/558.8ac6d4e3.js +3 -0
- package/__mf/js/async/568.45da2c30.js +1 -0
- package/__mf/js/async/587.c9460696.js +1 -0
- package/__mf/js/async/588.0a1aa144.js +1 -0
- package/__mf/js/async/603.3b771310.js +2 -0
- package/__mf/js/async/603.3b771310.js.LICENSE.txt +9 -0
- package/__mf/js/async/616.79484ac8.js +1 -0
- package/__mf/js/async/655.dbf8c618.js +1 -0
- package/__mf/js/async/694.0fb9ee5a.js +2 -0
- package/__mf/js/async/702.785cd635.js +2 -0
- package/__mf/js/async/71.8c6cf914.js +1 -0
- package/__mf/js/async/724.c45dcf5b.js +1 -0
- package/__mf/js/async/873.04a201bf.js +1 -0
- package/__mf/js/async/941.b89f8595.js +2 -0
- package/__mf/js/async/955.176fe200.js +1 -0
- package/__mf/js/async/968.2a9fb1a0.js +1 -0
- package/__mf/js/async/978.a9865b23.js +1 -0
- package/__mf/js/async/984.4793f667.js +22 -0
- package/__mf/js/async/{90.16425d5a.js.LICENSE.txt → 984.4793f667.js.LICENSE.txt} +0 -10
- package/__mf/js/async/__federation_expose_TimeSeriesChart.62d8f589.js +1 -0
- package/__mf/js/async/lib-router.319c02cd.js +2 -0
- package/__mf/js/main.23e38819.js +7 -0
- package/lib/QuerySettingsEditor.d.ts.map +1 -1
- package/lib/QuerySettingsEditor.js +93 -14
- package/lib/QuerySettingsEditor.js.map +1 -1
- package/lib/TimeSeriesChartBase.d.ts +2 -0
- package/lib/TimeSeriesChartBase.d.ts.map +1 -1
- package/lib/TimeSeriesChartBase.js +90 -7
- package/lib/TimeSeriesChartBase.js.map +1 -1
- package/lib/TimeSeriesChartPanel.d.ts.map +1 -1
- package/lib/TimeSeriesChartPanel.js +24 -3
- package/lib/TimeSeriesChartPanel.js.map +1 -1
- package/lib/VisualOptionsEditor.js.map +1 -1
- package/lib/annotations/AnnotationTooltip.d.ts +18 -0
- package/lib/annotations/AnnotationTooltip.d.ts.map +1 -0
- package/lib/annotations/AnnotationTooltip.js +352 -0
- package/lib/annotations/AnnotationTooltip.js.map +1 -0
- package/lib/cjs/QuerySettingsEditor.js +91 -12
- package/lib/cjs/TimeSeriesChartBase.js +90 -7
- package/lib/cjs/TimeSeriesChartPanel.js +24 -3
- package/lib/cjs/annotations/AnnotationTooltip.js +370 -0
- package/lib/cjs/utils/annotation.js +37 -0
- package/lib/cjs/utils/data-transform.js +9 -13
- package/lib/time-series-chart-model.d.ts +7 -0
- package/lib/time-series-chart-model.d.ts.map +1 -1
- package/lib/time-series-chart-model.js.map +1 -1
- package/lib/utils/annotation.d.ts +5 -0
- package/lib/utils/annotation.d.ts.map +1 -0
- package/lib/utils/annotation.js +29 -0
- package/lib/utils/annotation.js.map +1 -0
- package/lib/utils/data-transform.d.ts +1 -0
- package/lib/utils/data-transform.d.ts.map +1 -1
- package/lib/utils/data-transform.js +9 -13
- package/lib/utils/data-transform.js.map +1 -1
- package/mf-manifest.json +61 -36
- package/mf-stats.json +68 -36
- package/package.json +5 -4
- package/__mf/js/TimeSeriesChart.e9912623.js +0 -7
- package/__mf/js/async/121.df4898d6.js +0 -2
- package/__mf/js/async/177.56f1be10.js +0 -1
- package/__mf/js/async/192.beef3a1a.js +0 -1
- package/__mf/js/async/2.c3740bb9.js +0 -1
- package/__mf/js/async/235.c24f24f7.js +0 -1
- package/__mf/js/async/274.d112354f.js +0 -2
- package/__mf/js/async/291.5ce0f3cb.js +0 -39
- package/__mf/js/async/356.9f551c8a.js +0 -1
- package/__mf/js/async/392.2350fb02.js +0 -2
- package/__mf/js/async/470.a4fd777e.js +0 -2
- package/__mf/js/async/491.6f81cf51.js +0 -1
- package/__mf/js/async/568.cdcaf97d.js +0 -1
- package/__mf/js/async/587.c12780da.js +0 -1
- package/__mf/js/async/588.6662e16a.js +0 -1
- package/__mf/js/async/616.52acb1b4.js +0 -1
- package/__mf/js/async/681.8d61b348.js +0 -110
- package/__mf/js/async/702.de247ad8.js +0 -2
- package/__mf/js/async/71.84e486c9.js +0 -1
- package/__mf/js/async/724.3439df06.js +0 -1
- package/__mf/js/async/78.91de282a.js +0 -1
- package/__mf/js/async/821.aa2ab3e8.js +0 -7
- package/__mf/js/async/873.9aad328a.js +0 -1
- package/__mf/js/async/90.16425d5a.js +0 -24
- package/__mf/js/async/941.c0e2d25e.js +0 -2
- package/__mf/js/async/968.6de5fa7c.js +0 -1
- package/__mf/js/async/978.5c14e175.js +0 -1
- package/__mf/js/async/__federation_expose_TimeSeriesChart.58a7f341.js +0 -1
- package/__mf/js/async/lib-router.7a3f7bb4.js +0 -2
- package/__mf/js/main.de1f5d2f.js +0 -7
- /package/__mf/css/async/{821.85c2cbf6.css → 208.85c2cbf6.css} +0 -0
- /package/__mf/js/async/{121.df4898d6.js.LICENSE.txt → 121.c3c0e54f.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{821.aa2ab3e8.js.LICENSE.txt → 208.b9f374ad.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{274.d112354f.js.LICENSE.txt → 274.72dfa9c8.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{392.2350fb02.js.LICENSE.txt → 392.b9ba5bf2.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{470.a4fd777e.js.LICENSE.txt → 470.e09f33b7.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{681.8d61b348.js.LICENSE.txt → 527.f97d1b86.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{291.5ce0f3cb.js.LICENSE.txt → 694.0fb9ee5a.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{702.de247ad8.js.LICENSE.txt → 702.785cd635.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{941.c0e2d25e.js.LICENSE.txt → 941.b89f8595.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{lib-router.7a3f7bb4.js.LICENSE.txt → lib-router.319c02cd.js.LICENSE.txt} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/QuerySettingsEditor.tsx"],"sourcesContent":["// Copyright 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 {\n Box,\n Button,\n IconButton,\n Menu,\n MenuItem,\n Slider,\n Stack,\n TextField,\n ToggleButton,\n ToggleButtonGroup,\n Typography,\n useTheme,\n} from '@mui/material';\nimport { FormatControls, FormatOptions, OptionsColorPicker } from '@perses-dev/components';\nimport React, { ReactElement, useEffect, useMemo, useRef, useState } from 'react';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport AddIcon from 'mdi-material-ui/Plus';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { produce } from 'immer';\nimport { useQueryCountContext } from '@perses-dev/plugin-system';\nimport {\n DEFAULT_AREA_OPACITY,\n LINE_STYLE_CONFIG,\n OPACITY_CONFIG,\n QuerySettingsOptions,\n TimeSeriesChartOptions,\n TimeSeriesChartOptionsEditorProps,\n} from './time-series-chart-model';\n\nconst DEFAULT_COLOR_VALUE = '#555';\nconst NO_INDEX_AVAILABLE = -1; // invalid array index value used to represent the fact that no query index is available\n\nexport function QuerySettingsEditor(props: TimeSeriesChartOptionsEditorProps): ReactElement {\n const { onChange, value } = props;\n const querySettingsList = value.querySettings;\n\n const handleQuerySettingsChange = (newQuerySettings: QuerySettingsOptions[]): void => {\n onChange(\n produce(value, (draft: TimeSeriesChartOptions) => {\n draft.querySettings = newQuerySettings;\n })\n );\n };\n // Every time a new query settings input is added, we want to focus the recently added input\n const recentlyAddedInputRef = useRef<HTMLInputElement | null>(null);\n const focusRef = useRef(false);\n useEffect(() => {\n if (!recentlyAddedInputRef.current || !focusRef.current) return;\n recentlyAddedInputRef.current?.focus();\n focusRef.current = false;\n }, [querySettingsList?.length]);\n\n const handleQueryIndexChange = (e: React.ChangeEvent<HTMLInputElement>, i: number): void => {\n if (querySettingsList !== undefined) {\n handleQuerySettingsChange(\n produce(querySettingsList, (draft) => {\n const querySettings = draft?.[i];\n if (querySettings) {\n querySettings.queryIndex = parseInt(e.target.value);\n }\n })\n );\n }\n };\n\n const handleColorModeChange = (e: React.ChangeEvent<HTMLInputElement>, i: number): void => {\n if (querySettingsList !== undefined) {\n handleQuerySettingsChange(\n produce(querySettingsList, (draft) => {\n if (draft !== undefined) {\n const querySettings = draft[i];\n if (querySettings) {\n const newColorMode = e.target.value;\n if (!newColorMode) {\n querySettings.colorMode = undefined;\n querySettings.colorValue = undefined;\n } else {\n querySettings.colorMode = newColorMode as QuerySettingsOptions['colorMode'];\n }\n }\n }\n })\n );\n }\n };\n\n const handleColorValueChange = (colorValue: string, i: number): void => {\n if (querySettingsList !== undefined) {\n handleQuerySettingsChange(\n produce(querySettingsList, (draft) => {\n if (draft !== undefined) {\n const querySettings = draft[i];\n if (querySettings) {\n querySettings.colorValue = colorValue;\n }\n }\n })\n );\n }\n };\n\n const handleLineStyleChange = (lineStyle: string, i: number): void => {\n if (querySettingsList !== undefined) {\n handleQuerySettingsChange(\n produce(querySettingsList, (draft) => {\n if (draft !== undefined) {\n const querySettings = draft[i];\n if (querySettings) {\n querySettings.lineStyle = lineStyle as QuerySettingsOptions['lineStyle'];\n }\n }\n })\n );\n }\n };\n\n const handleAreaOpacityChange = (_: Event, sliderValue: number | number[], i: number): void => {\n const newValue = Array.isArray(sliderValue) ? sliderValue[0] : sliderValue;\n if (querySettingsList !== undefined) {\n handleQuerySettingsChange(\n produce(querySettingsList, (draft) => {\n if (draft !== undefined) {\n const querySettings = draft[i];\n if (querySettings) {\n querySettings.areaOpacity = newValue;\n }\n }\n })\n );\n }\n };\n\n // Helper function to update query settings at a specific index\n const updateQuerySettings = (i: number, updater: (qs: QuerySettingsOptions) => void): void => {\n if (querySettingsList !== undefined) {\n handleQuerySettingsChange(\n produce(querySettingsList, (draft) => {\n const qs = draft[i];\n if (qs) {\n updater(qs);\n }\n })\n );\n }\n };\n\n const deleteQuerySettingsInput = (i: number): void => {\n if (querySettingsList !== undefined) {\n const updatedQuerySettingsList = produce(querySettingsList, (draft) => {\n draft.splice(i, 1);\n });\n handleQuerySettingsChange(updatedQuerySettingsList);\n }\n };\n\n const addColor = (i: number): void => {\n updateQuerySettings(i, (qs) => {\n qs.colorMode = 'fixed-single';\n qs.colorValue = DEFAULT_COLOR_VALUE;\n });\n };\n\n const removeColor = (i: number): void => {\n updateQuerySettings(i, (qs) => {\n qs.colorMode = undefined;\n qs.colorValue = undefined;\n });\n };\n\n const addLineStyle = (i: number): void => {\n updateQuerySettings(i, (qs) => {\n qs.lineStyle = 'solid';\n });\n };\n\n const removeLineStyle = (i: number): void => {\n updateQuerySettings(i, (qs) => {\n qs.lineStyle = undefined;\n });\n };\n\n const addAreaOpacity = (i: number): void => {\n updateQuerySettings(i, (qs) => {\n qs.areaOpacity = DEFAULT_AREA_OPACITY;\n });\n };\n\n const removeAreaOpacity = (i: number): void => {\n updateQuerySettings(i, (qs) => {\n qs.areaOpacity = undefined;\n });\n };\n\n const addFormat = (i: number): void => {\n updateQuerySettings(i, (qs) => {\n qs.format = { unit: 'decimal', shortValues: true };\n });\n };\n\n const removeFormat = (i: number): void => {\n updateQuerySettings(i, (qs) => {\n qs.format = undefined;\n });\n };\n\n const handleFormatChange = (i: number, format?: FormatOptions): void => {\n updateQuerySettings(i, (qs) => {\n qs.format = format;\n });\n };\n\n const queryCount = useQueryCountContext();\n\n // Compute the list of query indexes for which query settings are not already defined.\n // This is to avoid already-booked indexes to still be selectable in the dropdown(s)\n const availableQueryIndexes = useMemo(() => {\n const bookedQueryIndexes = querySettingsList?.map((querySettings) => querySettings.queryIndex) ?? [];\n const allQueryIndexes = Array.from({ length: queryCount }, (_, i) => i);\n return allQueryIndexes.filter((_, queryIndex) => !bookedQueryIndexes.includes(queryIndex));\n }, [querySettingsList, queryCount]);\n\n const firstAvailableQueryIndex = useMemo(() => {\n return availableQueryIndexes[0] ?? NO_INDEX_AVAILABLE;\n }, [availableQueryIndexes]);\n\n const defaultQuerySettings: QuerySettingsOptions = {\n queryIndex: firstAvailableQueryIndex,\n };\n\n const addQuerySettingsInput = (): void => {\n focusRef.current = true;\n if (querySettingsList === undefined) {\n handleQuerySettingsChange([defaultQuerySettings]);\n } else {\n handleQuerySettingsChange(\n produce(querySettingsList, (draft) => {\n draft.push(defaultQuerySettings);\n })\n );\n }\n };\n\n return (\n <Stack>\n {queryCount === 0 ? (\n <Typography mb={2} fontStyle=\"italic\">\n No query defined\n </Typography>\n ) : (\n querySettingsList?.length &&\n querySettingsList.map((querySettings, i) => (\n <QuerySettingsInput\n inputRef={i === querySettingsList.length - 1 ? recentlyAddedInputRef : undefined}\n key={i}\n querySettings={querySettings}\n availableQueryIndexes={availableQueryIndexes}\n onQueryIndexChange={(e) => {\n handleQueryIndexChange(e, i);\n }}\n onColorModeChange={(e) => handleColorModeChange(e, i)}\n onColorValueChange={(color) => handleColorValueChange(color, i)}\n onLineStyleChange={(lineStyle) => handleLineStyleChange(lineStyle, i)}\n onAreaOpacityChange={(event, value) => handleAreaOpacityChange(event, value, i)}\n onDelete={() => {\n deleteQuerySettingsInput(i);\n }}\n onAddColor={() => addColor(i)}\n onRemoveColor={() => removeColor(i)}\n onAddLineStyle={() => addLineStyle(i)}\n onRemoveLineStyle={() => removeLineStyle(i)}\n onAddAreaOpacity={() => addAreaOpacity(i)}\n onRemoveAreaOpacity={() => removeAreaOpacity(i)}\n onAddFormat={() => addFormat(i)}\n onRemoveFormat={() => removeFormat(i)}\n onFormatChange={(format) => handleFormatChange(i, format)}\n />\n ))\n )}\n {queryCount > 0 && firstAvailableQueryIndex !== NO_INDEX_AVAILABLE && (\n <Button variant=\"contained\" startIcon={<AddIcon />} sx={{ marginTop: 1 }} onClick={addQuerySettingsInput}>\n Add Query Settings\n </Button>\n )}\n </Stack>\n );\n}\n\ninterface QuerySettingsInputProps {\n querySettings: QuerySettingsOptions;\n availableQueryIndexes: number[];\n onQueryIndexChange: (e: React.ChangeEvent<HTMLInputElement>) => void;\n onColorModeChange: (e: React.ChangeEvent<HTMLInputElement>) => void;\n onColorValueChange: (colorValue: string) => void;\n onLineStyleChange: (lineStyle: string) => void;\n onAreaOpacityChange: (event: Event, value: number | number[]) => void;\n onDelete: () => void;\n inputRef?: React.RefObject<HTMLInputElement | null>;\n // Optional control handlers\n onAddColor: () => void;\n onRemoveColor: () => void;\n onAddLineStyle: () => void;\n onRemoveLineStyle: () => void;\n onAddAreaOpacity: () => void;\n onRemoveAreaOpacity: () => void;\n onAddFormat: () => void;\n onRemoveFormat: () => void;\n onFormatChange: (format?: FormatOptions) => void;\n}\n\nfunction QuerySettingsInput({\n querySettings: { queryIndex, colorMode, colorValue, lineStyle, areaOpacity, format },\n availableQueryIndexes,\n onQueryIndexChange,\n onColorModeChange,\n onColorValueChange,\n onLineStyleChange,\n onAreaOpacityChange,\n onDelete,\n inputRef,\n onAddColor: onAddColor,\n onRemoveColor: onRemoveColor,\n onAddLineStyle,\n onRemoveLineStyle,\n onAddAreaOpacity,\n onRemoveAreaOpacity,\n onAddFormat,\n onRemoveFormat,\n onFormatChange,\n}: QuerySettingsInputProps): ReactElement {\n // current query index should also be selectable\n const selectableQueryIndexes = availableQueryIndexes.concat(queryIndex).sort((a, b) => a - b);\n\n // State for dropdown menu\n const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);\n\n // Calculate available options\n const availableOptions = useMemo(() => {\n const options = [];\n if (!colorMode) options.push({ key: 'color', label: 'Color', action: onAddColor });\n if (!lineStyle) options.push({ key: 'lineStyle', label: 'Line Style', action: onAddLineStyle });\n if (areaOpacity === undefined) options.push({ key: 'opacity', label: 'Opacity', action: onAddAreaOpacity });\n if (format === undefined) options.push({ key: 'format', label: 'Format', action: onAddFormat });\n return options;\n }, [colorMode, lineStyle, areaOpacity, format, onAddColor, onAddLineStyle, onAddAreaOpacity, onAddFormat]);\n\n const handleAddMenuClick = (event: React.MouseEvent<HTMLElement>): void => {\n if (availableOptions.length === 1 && availableOptions[0]) {\n // If only one option left, add it directly\n availableOptions[0].action();\n } else {\n // Show dropdown\n setAnchorEl(event.currentTarget);\n }\n };\n\n const handleMenuClose = (): void => {\n setAnchorEl(null);\n };\n\n const handleMenuItemClick = (action: () => void): void => {\n action();\n handleMenuClose();\n };\n\n return (\n <Stack\n sx={{\n borderBottom: '1px solid',\n borderColor: 'divider',\n borderRadius: 1,\n p: 2,\n display: 'flex',\n flexWrap: 'nowrap',\n flexDirection: 'row',\n }}\n >\n <Stack direction=\"row\" alignItems=\"center\" sx={{ flexWrap: 'wrap', gap: 2, flexGrow: 1 }}>\n {/* Query Index Selection */}\n <TextField\n select\n inputRef={inputRef}\n value={queryIndex}\n label=\"Query\"\n onChange={onQueryIndexChange}\n sx={{ minWidth: '75px' }}\n >\n {selectableQueryIndexes.map((qi) => (\n <MenuItem key={`query-${qi}`} value={qi}>\n #{qi + 1}\n </MenuItem>\n ))}\n </TextField>\n\n {/* Color section */}\n {colorMode && (\n <SettingsSection label=\"Color\" onRemove={onRemoveColor}>\n <TextField select value={colorMode} onChange={onColorModeChange} size=\"small\" sx={{ flexGrow: 1 }}>\n <MenuItem value=\"fixed-single\">Fixed (single)</MenuItem>\n <MenuItem value=\"fixed\">Fixed</MenuItem>\n </TextField>\n <OptionsColorPicker\n label={`Query n°${queryIndex + 1}`}\n color={colorValue || DEFAULT_COLOR_VALUE}\n onColorChange={onColorValueChange}\n />\n </SettingsSection>\n )}\n\n {/* Line Style section */}\n {lineStyle && (\n <SettingsSection label=\"Line Style\" onRemove={onRemoveLineStyle}>\n <ToggleButtonGroup\n color=\"primary\"\n exclusive\n value={lineStyle}\n onChange={(__, newValue) => {\n if (newValue !== null) {\n onLineStyleChange(newValue);\n }\n }}\n size=\"small\"\n >\n {Object.entries(LINE_STYLE_CONFIG).map(([styleValue, config]) => (\n <ToggleButton key={styleValue} value={styleValue} aria-label={`${styleValue} line style`}>\n {config.label}\n </ToggleButton>\n ))}\n </ToggleButtonGroup>\n {/* Spacer to push delete button to the right */}\n <Box sx={{ flexGrow: 1 }} />\n </SettingsSection>\n )}\n\n {/* Area Opacity section */}\n {areaOpacity !== undefined && (\n <SettingsSection label=\"Opacity\" onRemove={onRemoveAreaOpacity}>\n {/* Spacer as I don't want to add a prop to SettingsSection for left-padding just for that case.. */}\n <Box />\n <Slider\n value={areaOpacity}\n valueLabelDisplay=\"auto\"\n step={OPACITY_CONFIG.step}\n marks\n min={OPACITY_CONFIG.min}\n max={OPACITY_CONFIG.max}\n onChange={onAreaOpacityChange}\n sx={{ flexGrow: 1 }}\n />\n </SettingsSection>\n )}\n\n {/* Format section */}\n {format !== undefined && (\n <SettingsSection label=\"Format\" onRemove={onRemoveFormat}>\n <Box sx={{ minWidth: '180px', display: 'flex', gap: 1, flexDirection: 'column' }}>\n <FormatControls value={format} onChange={onFormatChange} />\n </Box>\n </SettingsSection>\n )}\n\n {/* Add Options Button - only show if there are available options */}\n {availableOptions.length > 0 && (\n <>\n <IconButton onClick={handleAddMenuClick} aria-label=\"Add option\">\n <AddIcon />\n </IconButton>\n\n {/* Dropdown Menu */}\n <Menu\n anchorEl={anchorEl}\n open={Boolean(anchorEl)}\n onClose={handleMenuClose}\n anchorOrigin={{\n vertical: 'bottom',\n horizontal: 'left',\n }}\n >\n {availableOptions.map((option) => (\n <MenuItem\n key={option.key}\n onClick={() => handleMenuItemClick(option.action)}\n sx={{ minWidth: '120px' }}\n >\n <AddIcon sx={{ mr: 1, fontSize: '1rem' }} />\n {option.label}\n </MenuItem>\n ))}\n </Menu>\n </>\n )}\n </Stack>\n {/* Delete Button for this query settings */}\n <Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>\n <IconButton aria-label={`delete settings for query n°${queryIndex + 1}`} onClick={onDelete}>\n <DeleteIcon />\n </IconButton>\n </Box>\n </Stack>\n );\n}\n\ninterface SettingsSectionProps {\n label: string;\n children: React.ReactNode;\n onRemove: () => void;\n}\n\n// Reusable section component\nfunction SettingsSection(props: SettingsSectionProps): ReactElement {\n const { label, children, onRemove } = props;\n const theme = useTheme();\n\n return (\n <Box sx={{ position: 'relative', minWidth: '250px' }}>\n <Typography\n variant=\"caption\"\n sx={{\n position: 'absolute',\n top: -8,\n left: 12,\n backgroundColor: theme.palette.background.code,\n px: 0.5,\n color: 'text.secondary',\n zIndex: 1,\n }}\n >\n {label}\n </Typography>\n <Stack\n direction=\"row\"\n alignItems=\"center\"\n spacing={1}\n sx={{\n border: '1px solid',\n borderColor: 'divider',\n borderRadius: 1,\n p: 1,\n }}\n >\n {children}\n <IconButton size=\"small\" onClick={onRemove} aria-label={`Remove ${label}`}>\n <CloseIcon />\n </IconButton>\n </Stack>\n </Box>\n );\n}\n"],"names":["Box","Button","IconButton","Menu","MenuItem","Slider","Stack","TextField","ToggleButton","ToggleButtonGroup","Typography","useTheme","FormatControls","OptionsColorPicker","React","useEffect","useMemo","useRef","useState","DeleteIcon","AddIcon","CloseIcon","produce","useQueryCountContext","DEFAULT_AREA_OPACITY","LINE_STYLE_CONFIG","OPACITY_CONFIG","DEFAULT_COLOR_VALUE","NO_INDEX_AVAILABLE","QuerySettingsEditor","props","onChange","value","querySettingsList","querySettings","handleQuerySettingsChange","newQuerySettings","draft","recentlyAddedInputRef","focusRef","current","focus","length","handleQueryIndexChange","e","i","undefined","queryIndex","parseInt","target","handleColorModeChange","newColorMode","colorMode","colorValue","handleColorValueChange","handleLineStyleChange","lineStyle","handleAreaOpacityChange","_","sliderValue","newValue","Array","isArray","areaOpacity","updateQuerySettings","updater","qs","deleteQuerySettingsInput","updatedQuerySettingsList","splice","addColor","removeColor","addLineStyle","removeLineStyle","addAreaOpacity","removeAreaOpacity","addFormat","format","unit","shortValues","removeFormat","handleFormatChange","queryCount","availableQueryIndexes","bookedQueryIndexes","map","allQueryIndexes","from","filter","includes","firstAvailableQueryIndex","defaultQuerySettings","addQuerySettingsInput","push","mb","fontStyle","QuerySettingsInput","inputRef","onQueryIndexChange","onColorModeChange","onColorValueChange","color","onLineStyleChange","onAreaOpacityChange","event","onDelete","onAddColor","onRemoveColor","onAddLineStyle","onRemoveLineStyle","onAddAreaOpacity","onRemoveAreaOpacity","onAddFormat","onRemoveFormat","onFormatChange","variant","startIcon","sx","marginTop","onClick","selectableQueryIndexes","concat","sort","a","b","anchorEl","setAnchorEl","availableOptions","options","key","label","action","handleAddMenuClick","currentTarget","handleMenuClose","handleMenuItemClick","borderBottom","borderColor","borderRadius","p","display","flexWrap","flexDirection","direction","alignItems","gap","flexGrow","select","minWidth","qi","SettingsSection","onRemove","size","onColorChange","exclusive","__","Object","entries","styleValue","config","aria-label","valueLabelDisplay","step","marks","min","max","open","Boolean","onClose","anchorOrigin","vertical","horizontal","option","mr","fontSize","justifyContent","children","theme","position","top","left","backgroundColor","palette","background","code","px","zIndex","spacing","border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AS;oBAAQI,YAAY;oBAAU+B,gBAAgB;gBAAS;0BACzE,cAAA,KAAC7K;oBAAW8J,cAAY,CAAC,4BAA4B,EAAEjH,aAAa,GAAG;oBAAEwE,SAASd;8BAChF,cAAA,KAACtF;;;;;AAKX;AAQA,6BAA6B;AAC7B,SAASmI,gBAAgBxH,KAA2B;IAClD,MAAM,EAAEoG,KAAK,EAAE8C,QAAQ,EAAEzB,QAAQ,EAAE,GAAGzH;IACtC,MAAMmJ,QAAQtK;IAEd,qBACE,MAACX;QAAIqH,IAAI;YAAE6D,UAAU;YAAY9B,UAAU;QAAQ;;0BACjD,KAAC1I;gBACCyG,SAAQ;gBACRE,IAAI;oBACF6D,UAAU;oBACVC,KAAK,CAAC;oBACNC,MAAM;oBACNC,iBAAiBJ,MAAMK,OAAO,CAACC,UAAU,CAACC,IAAI;oBAC9CC,IAAI;oBACJpF,OAAO;oBACPqF,QAAQ;gBACV;0BAECxD;;0BAEH,MAAC5H;gBACCyI,WAAU;gBACVC,YAAW;gBACX2C,SAAS;gBACTtE,IAAI;oBACFuE,QAAQ;oBACRnD,aAAa;oBACbC,cAAc;oBACdC,GAAG;gBACL;;oBAECqC;kCACD,KAAC9K;wBAAWsJ,MAAK;wBAAQjC,SAASgC;wBAAUS,cAAY,CAAC,OAAO,EAAE9B,OAAO;kCACvE,cAAA,KAAC7G;;;;;;AAKX"}
|
|
1
|
+
{"version":3,"sources":["../../src/QuerySettingsEditor.tsx"],"sourcesContent":["// Copyright 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 {\n Box,\n Button,\n IconButton,\n Menu,\n MenuItem,\n Slider,\n Stack,\n Switch,\n TextField,\n ToggleButton,\n ToggleButtonGroup,\n Typography,\n useTheme,\n} from '@mui/material';\nimport { FormatControls, FormatOptions, OptionsColorPicker } from '@perses-dev/components';\nimport React, { ReactElement, useEffect, useMemo, useRef, useState } from 'react';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport AddIcon from 'mdi-material-ui/Plus';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { produce } from 'immer';\nimport { generateQueryNames, useDataQueriesContext } from '@perses-dev/plugin-system';\nimport {\n DEFAULT_AREA_OPACITY,\n LINE_STYLE_CONFIG,\n OPACITY_CONFIG,\n QuerySettingsOptions,\n TimeSeriesChartOptions,\n TimeSeriesChartOptionsEditorProps,\n} from './time-series-chart-model';\n\nconst DEFAULT_COLOR_VALUE = '#555';\nconst NO_INDEX_AVAILABLE = -1; // invalid array index value used to represent the fact that no query index is available\n\nexport function QuerySettingsEditor(props: TimeSeriesChartOptionsEditorProps): ReactElement {\n const { onChange, value } = props;\n const querySettingsList = value.querySettings;\n\n const handleQuerySettingsChange = (newQuerySettings: QuerySettingsOptions[]): void => {\n onChange(\n produce(value, (draft: TimeSeriesChartOptions) => {\n draft.querySettings = newQuerySettings;\n })\n );\n };\n // Every time a new query settings input is added, we want to focus the recently added input\n const recentlyAddedInputRef = useRef<HTMLInputElement | null>(null);\n const focusRef = useRef(false);\n useEffect(() => {\n if (!recentlyAddedInputRef.current || !focusRef.current) return;\n recentlyAddedInputRef.current?.focus();\n focusRef.current = false;\n }, [querySettingsList?.length]);\n\n const handleQueryIndexChange = (e: React.ChangeEvent<HTMLInputElement>, i: number): void => {\n if (querySettingsList !== undefined) {\n handleQuerySettingsChange(\n produce(querySettingsList, (draft) => {\n const querySettings = draft?.[i];\n if (querySettings) {\n querySettings.queryIndex = parseInt(e.target.value);\n }\n })\n );\n }\n };\n\n const handleColorModeChange = (e: React.ChangeEvent<HTMLInputElement>, i: number): void => {\n if (querySettingsList !== undefined) {\n handleQuerySettingsChange(\n produce(querySettingsList, (draft) => {\n if (draft !== undefined) {\n const querySettings = draft[i];\n if (querySettings) {\n const newColorMode = e.target.value;\n if (!newColorMode) {\n querySettings.colorMode = undefined;\n querySettings.colorValue = undefined;\n } else {\n querySettings.colorMode = newColorMode as QuerySettingsOptions['colorMode'];\n }\n }\n }\n })\n );\n }\n };\n\n const handleColorValueChange = (colorValue: string, i: number): void => {\n if (querySettingsList !== undefined) {\n handleQuerySettingsChange(\n produce(querySettingsList, (draft) => {\n if (draft !== undefined) {\n const querySettings = draft[i];\n if (querySettings) {\n querySettings.colorValue = colorValue;\n }\n }\n })\n );\n }\n };\n\n const handleLineStyleChange = (lineStyle: string, i: number): void => {\n if (querySettingsList !== undefined) {\n handleQuerySettingsChange(\n produce(querySettingsList, (draft) => {\n if (draft !== undefined) {\n const querySettings = draft[i];\n if (querySettings) {\n querySettings.lineStyle = lineStyle as QuerySettingsOptions['lineStyle'];\n }\n }\n })\n );\n }\n };\n\n const handleAreaOpacityChange = (_: Event, sliderValue: number | number[], i: number): void => {\n const newValue = Array.isArray(sliderValue) ? sliderValue[0] : sliderValue;\n if (querySettingsList !== undefined) {\n handleQuerySettingsChange(\n produce(querySettingsList, (draft) => {\n if (draft !== undefined) {\n const querySettings = draft[i];\n if (querySettings) {\n querySettings.areaOpacity = newValue;\n }\n }\n })\n );\n }\n };\n\n // Helper function to update query settings at a specific index\n const updateQuerySettings = (i: number, updater: (qs: QuerySettingsOptions) => void): void => {\n if (querySettingsList !== undefined) {\n handleQuerySettingsChange(\n produce(querySettingsList, (draft) => {\n const qs = draft[i];\n if (qs) {\n updater(qs);\n }\n })\n );\n }\n };\n\n const deleteQuerySettingsInput = (i: number): void => {\n if (querySettingsList !== undefined) {\n const updatedQuerySettingsList = produce(querySettingsList, (draft) => {\n draft.splice(i, 1);\n });\n handleQuerySettingsChange(updatedQuerySettingsList);\n }\n };\n\n const addColor = (i: number): void => {\n updateQuerySettings(i, (qs) => {\n qs.colorMode = 'fixed-single';\n qs.colorValue = DEFAULT_COLOR_VALUE;\n });\n };\n\n const removeColor = (i: number): void => {\n updateQuerySettings(i, (qs) => {\n qs.colorMode = undefined;\n qs.colorValue = undefined;\n });\n };\n\n const addLineStyle = (i: number): void => {\n updateQuerySettings(i, (qs) => {\n qs.lineStyle = 'solid';\n });\n };\n\n const removeLineStyle = (i: number): void => {\n updateQuerySettings(i, (qs) => {\n qs.lineStyle = undefined;\n });\n };\n\n const addAreaOpacity = (i: number): void => {\n updateQuerySettings(i, (qs) => {\n qs.areaOpacity = DEFAULT_AREA_OPACITY;\n });\n };\n\n const removeAreaOpacity = (i: number): void => {\n updateQuerySettings(i, (qs) => {\n qs.areaOpacity = undefined;\n });\n };\n\n const addFormat = (i: number): void => {\n updateQuerySettings(i, (qs) => {\n qs.format = { unit: 'decimal', shortValues: true };\n });\n };\n\n const removeFormat = (i: number): void => {\n updateQuerySettings(i, (qs) => {\n qs.format = undefined;\n });\n };\n\n const addStack = (i: number): void => {\n updateQuerySettings(i, (qs) => {\n qs.stack = false;\n });\n };\n\n const removeStack = (i: number): void => {\n updateQuerySettings(i, (qs) => {\n qs.stack = undefined;\n });\n };\n\n const handleStackChange = (i: number, checked: boolean): void => {\n updateQuerySettings(i, (qs) => {\n qs.stack = checked;\n });\n };\n\n const handleFormatChange = (i: number, format?: FormatOptions): void => {\n updateQuerySettings(i, (qs) => {\n qs.format = format;\n });\n };\n\n const addNegativeY = (i: number): void => {\n updateQuerySettings(i, (qs) => {\n qs.negativeY = true;\n });\n };\n\n const removeNegativeY = (i: number): void => {\n updateQuerySettings(i, (qs) => {\n qs.negativeY = undefined;\n });\n };\n\n const { queryDefinitions } = useDataQueriesContext();\n const queryCount = queryDefinitions.length;\n const queryNames = useMemo(() => generateQueryNames(queryDefinitions), [queryDefinitions]);\n\n // Compute the list of query indexes for which query settings are not already defined.\n // This is to avoid already-booked indexes to still be selectable in the dropdown(s)\n const availableQueryIndexes = useMemo(() => {\n const bookedQueryIndexes = querySettingsList?.map((querySettings) => querySettings.queryIndex) ?? [];\n const allQueryIndexes = Array.from({ length: queryCount }, (_, i) => i);\n return allQueryIndexes.filter((_, queryIndex) => !bookedQueryIndexes.includes(queryIndex));\n }, [querySettingsList, queryCount]);\n\n const firstAvailableQueryIndex = useMemo(() => {\n return availableQueryIndexes[0] ?? NO_INDEX_AVAILABLE;\n }, [availableQueryIndexes]);\n\n const defaultQuerySettings: QuerySettingsOptions = {\n queryIndex: firstAvailableQueryIndex,\n };\n\n const addQuerySettingsInput = (): void => {\n focusRef.current = true;\n if (querySettingsList === undefined) {\n handleQuerySettingsChange([defaultQuerySettings]);\n } else {\n handleQuerySettingsChange(\n produce(querySettingsList, (draft) => {\n draft.push(defaultQuerySettings);\n })\n );\n }\n };\n\n return (\n <Stack>\n {queryCount === 0 ? (\n <Typography mb={2} fontStyle=\"italic\">\n No query defined\n </Typography>\n ) : (\n querySettingsList?.map((querySettings, i) => (\n <QuerySettingsInput\n inputRef={i === querySettingsList.length - 1 ? recentlyAddedInputRef : undefined}\n key={i}\n querySettings={querySettings}\n availableQueryIndexes={availableQueryIndexes}\n queryNames={queryNames}\n onQueryIndexChange={(e) => {\n handleQueryIndexChange(e, i);\n }}\n onColorModeChange={(e) => handleColorModeChange(e, i)}\n onColorValueChange={(color) => handleColorValueChange(color, i)}\n onLineStyleChange={(lineStyle) => handleLineStyleChange(lineStyle, i)}\n onAreaOpacityChange={(event, value) => handleAreaOpacityChange(event, value, i)}\n onDelete={() => {\n deleteQuerySettingsInput(i);\n }}\n onAddColor={() => addColor(i)}\n onRemoveColor={() => removeColor(i)}\n onAddLineStyle={() => addLineStyle(i)}\n onRemoveLineStyle={() => removeLineStyle(i)}\n onAddAreaOpacity={() => addAreaOpacity(i)}\n onRemoveAreaOpacity={() => removeAreaOpacity(i)}\n onAddFormat={() => addFormat(i)}\n onRemoveFormat={() => removeFormat(i)}\n onFormatChange={(format) => handleFormatChange(i, format)}\n onAddNegativeY={() => addNegativeY(i)}\n onRemoveNegativeY={() => removeNegativeY(i)}\n onAddStack={() => addStack(i)}\n onRemoveStack={() => removeStack(i)}\n onStackChange={(checked) => handleStackChange(i, checked)}\n />\n ))\n )}\n {queryCount > 0 && firstAvailableQueryIndex !== NO_INDEX_AVAILABLE && (\n <Button variant=\"contained\" startIcon={<AddIcon />} sx={{ marginTop: 1 }} onClick={addQuerySettingsInput}>\n Add Query Settings\n </Button>\n )}\n </Stack>\n );\n}\n\ninterface QuerySettingsInputProps {\n querySettings: QuerySettingsOptions;\n availableQueryIndexes: number[];\n queryNames: string[];\n onQueryIndexChange: (e: React.ChangeEvent<HTMLInputElement>) => void;\n onColorModeChange: (e: React.ChangeEvent<HTMLInputElement>) => void;\n onColorValueChange: (colorValue: string) => void;\n onLineStyleChange: (lineStyle: string) => void;\n onAreaOpacityChange: (event: Event, value: number | number[]) => void;\n onDelete: () => void;\n inputRef?: React.RefObject<HTMLInputElement | null>;\n // Optional control handlers\n onAddColor: () => void;\n onRemoveColor: () => void;\n onAddLineStyle: () => void;\n onRemoveLineStyle: () => void;\n onAddAreaOpacity: () => void;\n onRemoveAreaOpacity: () => void;\n onAddFormat: () => void;\n onRemoveFormat: () => void;\n onFormatChange: (format?: FormatOptions) => void;\n onAddNegativeY: () => void;\n onRemoveNegativeY: () => void;\n onAddStack: () => void;\n onRemoveStack: () => void;\n onStackChange: (checked: boolean) => void;\n}\n\nfunction QuerySettingsInput({\n querySettings: { queryIndex, colorMode, colorValue, lineStyle, areaOpacity, format, negativeY, stack },\n availableQueryIndexes,\n queryNames,\n onQueryIndexChange,\n onColorModeChange,\n onColorValueChange,\n onLineStyleChange,\n onAreaOpacityChange,\n onDelete,\n inputRef,\n onAddColor: onAddColor,\n onRemoveColor: onRemoveColor,\n onAddLineStyle,\n onRemoveLineStyle,\n onAddAreaOpacity,\n onRemoveAreaOpacity,\n onAddFormat,\n onRemoveFormat,\n onFormatChange,\n onAddNegativeY,\n onRemoveNegativeY,\n onAddStack,\n onRemoveStack,\n onStackChange,\n}: QuerySettingsInputProps): ReactElement {\n // current query index should also be selectable\n const selectableQueryIndexes = availableQueryIndexes.concat(queryIndex).sort((a, b) => a - b);\n\n // State for dropdown menu\n const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);\n\n // Calculate available options\n const availableOptions = useMemo(() => {\n const options = [];\n if (!colorMode) options.push({ key: 'color', label: 'Color', action: onAddColor });\n if (!lineStyle) options.push({ key: 'lineStyle', label: 'Line Style', action: onAddLineStyle });\n if (areaOpacity === undefined) options.push({ key: 'opacity', label: 'Opacity', action: onAddAreaOpacity });\n if (format === undefined) options.push({ key: 'format', label: 'Format', action: onAddFormat });\n if (!negativeY) options.push({ key: 'negativeY', label: 'Negative Y', action: onAddNegativeY });\n if (stack === undefined) options.push({ key: 'stack', label: 'Stack', action: onAddStack });\n return options;\n }, [\n colorMode,\n lineStyle,\n areaOpacity,\n format,\n negativeY,\n stack,\n onAddColor,\n onAddLineStyle,\n onAddAreaOpacity,\n onAddFormat,\n onAddNegativeY,\n onAddStack,\n ]);\n\n const handleAddMenuClick = (event: React.MouseEvent<HTMLElement>): void => {\n if (availableOptions.length === 1 && availableOptions[0]) {\n // If only one option left, add it directly\n availableOptions[0].action();\n } else {\n // Show dropdown\n setAnchorEl(event.currentTarget);\n }\n };\n\n const handleMenuClose = (): void => {\n setAnchorEl(null);\n };\n\n const handleMenuItemClick = (action: () => void): void => {\n action();\n handleMenuClose();\n };\n\n return (\n <Stack\n sx={{\n borderBottom: '1px solid',\n borderColor: 'divider',\n borderRadius: 1,\n p: 2,\n display: 'flex',\n flexWrap: 'nowrap',\n flexDirection: 'row',\n }}\n >\n <Stack direction=\"row\" alignItems=\"center\" sx={{ flexWrap: 'wrap', gap: 2, flexGrow: 1 }}>\n {/* Query Index Selection */}\n <TextField\n select\n inputRef={inputRef}\n value={queryIndex}\n label=\"Query\"\n onChange={onQueryIndexChange}\n sx={{ minWidth: '75px' }}\n >\n {selectableQueryIndexes.map((qi) => (\n <MenuItem key={`query-${qi}`} value={qi}>\n {queryNames[qi] ?? `#${qi + 1}`}\n </MenuItem>\n ))}\n </TextField>\n\n {/* Color section */}\n {colorMode && (\n <SettingsSection label=\"Color\" onRemove={onRemoveColor}>\n <TextField select value={colorMode} onChange={onColorModeChange} size=\"small\" sx={{ flexGrow: 1 }}>\n <MenuItem value=\"fixed-single\">Fixed (single)</MenuItem>\n <MenuItem value=\"fixed\">Fixed</MenuItem>\n </TextField>\n <OptionsColorPicker\n label={queryNames[queryIndex] ?? `Query n°${queryIndex + 1}`}\n color={colorValue || DEFAULT_COLOR_VALUE}\n onColorChange={onColorValueChange}\n />\n </SettingsSection>\n )}\n\n {/* Line Style section */}\n {lineStyle && (\n <SettingsSection label=\"Line Style\" onRemove={onRemoveLineStyle}>\n <ToggleButtonGroup\n color=\"primary\"\n exclusive\n value={lineStyle}\n onChange={(__, newValue) => {\n if (newValue !== null) {\n onLineStyleChange(newValue);\n }\n }}\n size=\"small\"\n >\n {Object.entries(LINE_STYLE_CONFIG).map(([styleValue, config]) => (\n <ToggleButton key={styleValue} value={styleValue} aria-label={`${styleValue} line style`}>\n {config.label}\n </ToggleButton>\n ))}\n </ToggleButtonGroup>\n {/* Spacer to push delete button to the right */}\n <Box sx={{ flexGrow: 1 }} />\n </SettingsSection>\n )}\n\n {/* Area Opacity section */}\n {areaOpacity !== undefined && (\n <SettingsSection label=\"Opacity\" onRemove={onRemoveAreaOpacity}>\n {/* Spacer as I don't want to add a prop to SettingsSection for left-padding just for that case.. */}\n <Box />\n <Slider\n value={areaOpacity}\n valueLabelDisplay=\"auto\"\n step={OPACITY_CONFIG.step}\n marks\n min={OPACITY_CONFIG.min}\n max={OPACITY_CONFIG.max}\n onChange={onAreaOpacityChange}\n sx={{ flexGrow: 1 }}\n />\n </SettingsSection>\n )}\n\n {/* Format section */}\n {format !== undefined && (\n <SettingsSection label=\"Format\" onRemove={onRemoveFormat}>\n <Box sx={{ minWidth: '180px', display: 'flex', gap: 1, flexDirection: 'column' }}>\n <FormatControls value={format} onChange={onFormatChange} />\n </Box>\n </SettingsSection>\n )}\n\n {/* Negative Y section (presence-only flag) */}\n {negativeY && (\n <SettingsSection label=\"Negative Y\" onRemove={onRemoveNegativeY}>\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ flexGrow: 1, py: 0.5 }}>\n Series rendered below the X axis\n </Typography>\n </SettingsSection>\n )}\n\n {/* Stack section */}\n {stack !== undefined && (\n <SettingsSection label=\"Stack\" onRemove={onRemoveStack}>\n <Switch\n checked={stack}\n onChange={(e) => onStackChange(e.target.checked)}\n slotProps={{ input: { 'aria-label': 'stack override' } }}\n />\n <Box sx={{ flexGrow: 1 }} />\n </SettingsSection>\n )}\n\n {/* Add Options Button - only show if there are available options */}\n {availableOptions.length > 0 && (\n <>\n <IconButton onClick={handleAddMenuClick} aria-label=\"Add option\">\n <AddIcon />\n </IconButton>\n\n {/* Dropdown Menu */}\n <Menu\n anchorEl={anchorEl}\n open={Boolean(anchorEl)}\n onClose={handleMenuClose}\n anchorOrigin={{\n vertical: 'bottom',\n horizontal: 'left',\n }}\n >\n {availableOptions.map((option) => (\n <MenuItem\n key={option.key}\n onClick={() => handleMenuItemClick(option.action)}\n sx={{ minWidth: '120px' }}\n >\n <AddIcon sx={{ mr: 1, fontSize: '1rem' }} />\n {option.label}\n </MenuItem>\n ))}\n </Menu>\n </>\n )}\n </Stack>\n {/* Delete Button for this query settings */}\n <Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>\n <IconButton\n aria-label={`delete settings for ${queryNames[queryIndex] ?? `query n°${queryIndex + 1}`}`}\n onClick={onDelete}\n >\n <DeleteIcon />\n </IconButton>\n </Box>\n </Stack>\n );\n}\n\ninterface SettingsSectionProps {\n label: string;\n children: React.ReactNode;\n onRemove: () => void;\n}\n\n// Reusable section component\nfunction SettingsSection(props: SettingsSectionProps): ReactElement {\n const { label, children, onRemove } = props;\n const theme = useTheme();\n\n return (\n <Box sx={{ position: 'relative', minWidth: '250px' }}>\n <Typography\n variant=\"caption\"\n sx={{\n position: 'absolute',\n top: -8,\n left: 12,\n backgroundColor: theme.palette.background.code,\n px: 0.5,\n color: 'text.secondary',\n zIndex: 1,\n }}\n >\n {label}\n </Typography>\n <Stack\n direction=\"row\"\n alignItems=\"center\"\n spacing={1}\n sx={{\n border: '1px solid',\n borderColor: 'divider',\n borderRadius: 1,\n p: 1,\n }}\n >\n {children}\n <IconButton size=\"small\" onClick={onRemove} aria-label={`Remove ${label}`}>\n <CloseIcon />\n </IconButton>\n </Stack>\n </Box>\n );\n}\n"],"names":["Box","Button","IconButton","Menu","MenuItem","Slider","Stack","Switch","TextField","ToggleButton","ToggleButtonGroup","Typography","useTheme","FormatControls","OptionsColorPicker","React","useEffect","useMemo","useRef","useState","DeleteIcon","AddIcon","CloseIcon","produce","generateQueryNames","useDataQueriesContext","DEFAULT_AREA_OPACITY","LINE_STYLE_CONFIG","OPACITY_CONFIG","DEFAULT_COLOR_VALUE","NO_INDEX_AVAILABLE","QuerySettingsEditor","props","onChange","value","querySettingsList","querySettings","handleQuerySettingsChange","newQuerySettings","draft","recentlyAddedInputRef","focusRef","current","focus","length","handleQueryIndexChange","e","i","undefined","queryIndex","parseInt","target","handleColorModeChange","newColorMode","colorMode","colorValue","handleColorValueChange","handleLineStyleChange","lineStyle","handleAreaOpacityChange","_","sliderValue","newValue","Array","isArray","areaOpacity","updateQuerySettings","updater","qs","deleteQuerySettingsInput","updatedQuerySettingsList","splice","addColor","removeColor","addLineStyle","removeLineStyle","addAreaOpacity","removeAreaOpacity","addFormat","format","unit","shortValues","removeFormat","addStack","stack","removeStack","handleStackChange","checked","handleFormatChange","addNegativeY","negativeY","removeNegativeY","queryDefinitions","queryCount","queryNames","availableQueryIndexes","bookedQueryIndexes","map","allQueryIndexes","from","filter","includes","firstAvailableQueryIndex","defaultQuerySettings","addQuerySettingsInput","push","mb","fontStyle","QuerySettingsInput","inputRef","onQueryIndexChange","onColorModeChange","onColorValueChange","color","onLineStyleChange","onAreaOpacityChange","event","onDelete","onAddColor","onRemoveColor","onAddLineStyle","onRemoveLineStyle","onAddAreaOpacity","onRemoveAreaOpacity","onAddFormat","onRemoveFormat","onFormatChange","onAddNegativeY","onRemoveNegativeY","onAddStack","onRemoveStack","onStackChange","variant","startIcon","sx","marginTop","onClick","selectableQueryIndexes","concat","sort","a","b","anchorEl","setAnchorEl","availableOptions","options","key","label","action","handleAddMenuClick","currentTarget","handleMenuClose","handleMenuItemClick","borderBottom","borderColor","borderRadius","p","display","flexWrap","flexDirection","direction","alignItems","gap","flexGrow","select","minWidth","qi","SettingsSection","onRemove","size","onColorChange","exclusive","__","Object","entries","styleValue","config","aria-label","valueLabelDisplay","step","marks","min","max","py","slotProps","input","open","Boolean","onClose","anchorOrigin","vertical","horizontal","option","mr","fontSize","justifyContent","children","theme","position","top","left","backgroundColor","palette","background","code","px","zIndex","spacing","border"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SACEA,GAAG,EACHC,MAAM,EACNC,UAAU,EACVC,IAAI,EACJC,QAAQ,EACRC,MAAM,EACNC,KAAK,EACLC,MAAM,EACNC,SAAS,EACTC,YAAY,EACZC,iBAAiB,EACjBC,UAAU,EACVC,QAAQ,QACH,gBAAgB;AACvB,SAASC,cAAc,EAAiBC,kBAAkB,QAAQ,yBAAyB;AAC3F,OAAOC,SAAuBC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAClF,OAAOC,gBAAgB,gCAAgC;AACvD,OAAOC,aAAa,uBAAuB;AAC3C,OAAOC,eAAe,wBAAwB;AAC9C,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAASC,kBAAkB,EAAEC,qBAAqB,QAAQ,4BAA4B;AACtF,SACEC,oBAAoB,EACpBC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QA,6BAA6B;AAC7B,SAASmJ,gBAAgBvI,KAA2B;IAClD,MAAM,EAAEmH,KAAK,EAAEiD,QAAQ,EAAE5B,QAAQ,EAAE,GAAGxI;IACtC,MAAMqK,QAAQzL;IAEd,qBACE,MAACZ;QAAIsI,IAAI;YAAEgE,UAAU;YAAYjC,UAAU;QAAQ;;0BACjD,KAAC1J;gBACCyH,SAAQ;gBACRE,IAAI;oBACFgE,UAAU;oBACVC,KAAK,CAAC;oBACNC,MAAM;oBACNC,iBAAiBJ,MAAMK,OAAO,CAACC,UAAU,CAACC,IAAI;oBAC9CC,IAAI;oBACJ5F,OAAO;oBACP6F,QAAQ;gBACV;0BAEC3D;;0BAEH,MAAC7I;gBACC0J,WAAU;gBACVC,YAAW;gBACX8C,SAAS;gBACTzE,IAAI;oBACF0E,QAAQ;oBACRtD,aAAa;oBACbC,cAAc;oBACdC,GAAG;gBACL;;oBAECwC;kCACD,KAAClM;wBAAWuK,MAAK;wBAAQjC,SAASgC;wBAAUS,cAAY,CAAC,OAAO,EAAE9B,OAAO;kCACvE,cAAA,KAAC7H;;;;;;AAKX"}
|
|
@@ -2,10 +2,12 @@ import { MouseEvent } from 'react';
|
|
|
2
2
|
import type { EChartsCoreOption, GridComponentOption, YAXisComponentOption } from 'echarts';
|
|
3
3
|
import { ChartInstance, FormatOptions, TimeChartSeriesMapping, TooltipConfig, ZoomEventData } from '@perses-dev/components';
|
|
4
4
|
import { TimeScale, TimeSeries } from '@perses-dev/spec';
|
|
5
|
+
import { TimeSeriesAnnotation } from './utils/annotation';
|
|
5
6
|
export interface TimeChartProps {
|
|
6
7
|
height: number;
|
|
7
8
|
data: TimeSeries[];
|
|
8
9
|
seriesMapping: TimeChartSeriesMapping;
|
|
10
|
+
annotations?: TimeSeriesAnnotation[];
|
|
9
11
|
timeScale?: TimeScale;
|
|
10
12
|
yAxis?: YAXisComponentOption | YAXisComponentOption[];
|
|
11
13
|
format?: FormatOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeSeriesChartBase.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesChartBase.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAc,UAAU,EAA0E,MAAM,OAAO,CAAC;AAKvH,OAAO,KAAK,EACV,iBAAiB,EACjB,mBAAmB,EAEnB,oBAAoB,EAErB,MAAM,SAAS,CAAC;AAejB,OAAO,EACL,aAAa,EAQb,aAAa,EAOb,sBAAsB,EAEtB,aAAa,EAGb,aAAa,EACd,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"TimeSeriesChartBase.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesChartBase.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAc,UAAU,EAA0E,MAAM,OAAO,CAAC;AAKvH,OAAO,KAAK,EACV,iBAAiB,EACjB,mBAAmB,EAEnB,oBAAoB,EAErB,MAAM,SAAS,CAAC;AAejB,OAAO,EACL,aAAa,EAQb,aAAa,EAOb,sBAAsB,EAEtB,aAAa,EAGb,aAAa,EACd,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAkB1D,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,aAAa,EAAE,sBAAsB,CAAC;IACtC,WAAW,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACrC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,KAAK,CAAC,EAAE,oBAAoB,GAAG,oBAAoB,EAAE,CAAC;IACtD,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB;;OAEG;IACH,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC7C,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IACxC,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IACxC,oCAAoC,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,iBAAiB,CAAC;CAC1F;AAED,eAAO,MAAM,mBAAmB,0GAoc9B,CAAC"}
|
|
@@ -21,6 +21,7 @@ import { GridComponent, DatasetComponent, DataZoomComponent, MarkAreaComponent,
|
|
|
21
21
|
import { CanvasRenderer } from 'echarts/renderers';
|
|
22
22
|
import { clearHighlightedSeries, DEFAULT_PINNED_CROSSHAIR, DEFAULT_TOOLTIP_CONFIG, EChart, enableDataZoom, getClosestTimestamp, getCommonTimeScale, getFormattedAxis, getPointInGrid, restoreChart, TimeChartTooltip, useChartsContext, useTimeZone } from '@perses-dev/components';
|
|
23
23
|
import { createTimezoneAwareAxisFormatter } from './utils/timezone-formatter';
|
|
24
|
+
import { AnnotationTooltip, buildAnnotationSeries } from './annotations/AnnotationTooltip';
|
|
24
25
|
use([
|
|
25
26
|
EChartsLineChart,
|
|
26
27
|
EChartsBarChart,
|
|
@@ -35,7 +36,7 @@ use([
|
|
|
35
36
|
TooltipComponent,
|
|
36
37
|
CanvasRenderer
|
|
37
38
|
]);
|
|
38
|
-
export const TimeSeriesChartBase = /*#__PURE__*/ forwardRef(function TimeChart({ height, data, seriesMapping, timeScale: timeScaleProp, yAxis, format, seriesFormatMap, grid, isStackedBar = false, tooltipConfig = DEFAULT_TOOLTIP_CONFIG, noDataVariant = 'message', syncGroup, onDataZoom, onDoubleClick, __experimentalEChartsOptionsOverride }, ref) {
|
|
39
|
+
export const TimeSeriesChartBase = /*#__PURE__*/ forwardRef(function TimeChart({ height, data, seriesMapping, annotations, timeScale: timeScaleProp, yAxis, format, seriesFormatMap, grid, isStackedBar = false, tooltipConfig = DEFAULT_TOOLTIP_CONFIG, noDataVariant = 'message', syncGroup, onDataZoom, onDoubleClick, __experimentalEChartsOptionsOverride }, ref) {
|
|
39
40
|
const { chartsTheme, enablePinning, enableSyncGrouping, lastTooltipPinnedCoords, setLastTooltipPinnedCoords } = useChartsContext();
|
|
40
41
|
const isPinningEnabled = tooltipConfig.enablePinning && enablePinning;
|
|
41
42
|
const chartRef = useRef();
|
|
@@ -44,7 +45,10 @@ export const TimeSeriesChartBase = /*#__PURE__*/ forwardRef(function TimeChart({
|
|
|
44
45
|
const [pinnedCrosshair, setPinnedCrosshair] = useState(null);
|
|
45
46
|
const [isDragging, setIsDragging] = useState(false);
|
|
46
47
|
const [startX, setStartX] = useState(0);
|
|
47
|
-
const
|
|
48
|
+
const [hoveredAnnotation, setHoveredAnnotation] = useState(null);
|
|
49
|
+
const [pinnedAnnotation, setPinnedAnnotation] = useState(null);
|
|
50
|
+
const [pinnedAnnotationPos, setPinnedAnnotationPos] = useState(null);
|
|
51
|
+
const { timeZone, formatWithUserTimeZone } = useTimeZone();
|
|
48
52
|
const getTimezoneAwareAxisFormatter = useCallback((rangeMs)=>createTimezoneAwareAxisFormatter(rangeMs, timeZone), [
|
|
49
53
|
timeZone
|
|
50
54
|
]);
|
|
@@ -115,11 +119,44 @@ export const TimeSeriesChartBase = /*#__PURE__*/ forwardRef(function TimeChart({
|
|
|
115
119
|
if (chartRef.current !== undefined) {
|
|
116
120
|
enableDataZoom(chartRef.current);
|
|
117
121
|
}
|
|
122
|
+
},
|
|
123
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
124
|
+
mouseover: (params)=>{
|
|
125
|
+
// Only markPoint (triangles under the X-axis) opens the annotation tooltip.
|
|
126
|
+
// Hovering markLine or anything else keeps the regular TimeSeries tooltip visible
|
|
127
|
+
// and clears any stale hovered annotation (mouseout is sometimes missed by ECharts).
|
|
128
|
+
if (annotations && params.componentType === 'markPoint' && params.data?.annotationIndex !== undefined) {
|
|
129
|
+
const matchedAnnotation = annotations[params.data.annotationIndex] || null;
|
|
130
|
+
if (matchedAnnotation) {
|
|
131
|
+
setHoveredAnnotation(matchedAnnotation);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
setHoveredAnnotation(null);
|
|
136
|
+
},
|
|
137
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
138
|
+
mouseout: (params)=>{
|
|
139
|
+
if (annotations && params.componentType === 'markPoint' && params.data?.annotationIndex !== undefined && annotations) {
|
|
140
|
+
// Only clear if the mouseout corresponds to the currently hovered annotation, so that
|
|
141
|
+
// a quick move from one markPoint to another isn't cancelled by a late mouseout event.
|
|
142
|
+
const leaving = annotations[params.data.annotationIndex] || null;
|
|
143
|
+
setHoveredAnnotation((current)=>current === leaving ? null : current);
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
globalout: ()=>{
|
|
147
|
+
if (annotations) {
|
|
148
|
+
// Cursor left the chart canvas — guarantee the annotation tooltip is dismissed.
|
|
149
|
+
setHoveredAnnotation(null);
|
|
150
|
+
}
|
|
118
151
|
}
|
|
119
152
|
};
|
|
120
153
|
}, [
|
|
121
|
-
|
|
122
|
-
|
|
154
|
+
annotations,
|
|
155
|
+
onDataZoom
|
|
156
|
+
]);
|
|
157
|
+
// Generate annotation series for ECharts markArea (range), markLine (point), and markPoint (markers under X-axis)
|
|
158
|
+
const annotationSeries = useMemo(()=>buildAnnotationSeries(annotations), [
|
|
159
|
+
annotations
|
|
123
160
|
]);
|
|
124
161
|
const { noDataOption } = chartsTheme;
|
|
125
162
|
const option = useMemo(()=>{
|
|
@@ -150,8 +187,12 @@ export const TimeSeriesChartBase = /*#__PURE__*/ forwardRef(function TimeChart({
|
|
|
150
187
|
});
|
|
151
188
|
const updatedSeriesMapping = enablePinning && pinnedCrosshair !== null ? [
|
|
152
189
|
...seriesMapping,
|
|
153
|
-
pinnedCrosshair
|
|
154
|
-
|
|
190
|
+
pinnedCrosshair,
|
|
191
|
+
...annotationSeries
|
|
192
|
+
] : [
|
|
193
|
+
...seriesMapping,
|
|
194
|
+
...annotationSeries
|
|
195
|
+
];
|
|
155
196
|
const option = {
|
|
156
197
|
dataset: dataset,
|
|
157
198
|
series: updatedSeriesMapping,
|
|
@@ -203,6 +244,7 @@ export const TimeSeriesChartBase = /*#__PURE__*/ forwardRef(function TimeChart({
|
|
|
203
244
|
}, [
|
|
204
245
|
data,
|
|
205
246
|
seriesMapping,
|
|
247
|
+
annotationSeries,
|
|
206
248
|
timeScale,
|
|
207
249
|
yAxis,
|
|
208
250
|
format,
|
|
@@ -243,6 +285,34 @@ export const TimeSeriesChartBase = /*#__PURE__*/ forwardRef(function TimeChart({
|
|
|
243
285
|
// e.preventDefault(); // Prevent the default behaviour when right clicked
|
|
244
286
|
// }}
|
|
245
287
|
onClick: (e)=>{
|
|
288
|
+
// If clicking while hovering an annotation, toggle the annotation tooltip pin
|
|
289
|
+
// instead of pinning the TimeChartTooltip, so pinned TimeChartTooltip is preserved.
|
|
290
|
+
if (hoveredAnnotation !== null && e.target instanceof HTMLCanvasElement) {
|
|
291
|
+
const pinnedPos = {
|
|
292
|
+
page: {
|
|
293
|
+
x: e.pageX,
|
|
294
|
+
y: e.pageY
|
|
295
|
+
},
|
|
296
|
+
client: {
|
|
297
|
+
x: e.clientX,
|
|
298
|
+
y: e.clientY
|
|
299
|
+
},
|
|
300
|
+
plotCanvas: {
|
|
301
|
+
x: e.nativeEvent.offsetX,
|
|
302
|
+
y: e.nativeEvent.offsetY
|
|
303
|
+
},
|
|
304
|
+
target: e.target
|
|
305
|
+
};
|
|
306
|
+
setPinnedAnnotation((current)=>{
|
|
307
|
+
if (current === hoveredAnnotation) {
|
|
308
|
+
setPinnedAnnotationPos(null);
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
311
|
+
setPinnedAnnotationPos(pinnedPos);
|
|
312
|
+
return hoveredAnnotation;
|
|
313
|
+
});
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
246
316
|
// Allows user to opt-in to multi tooltip pinning when Ctrl or Cmd key held down
|
|
247
317
|
const isControlKeyPressed = e.ctrlKey || e.metaKey;
|
|
248
318
|
if (isControlKeyPressed) {
|
|
@@ -335,6 +405,8 @@ export const TimeSeriesChartBase = /*#__PURE__*/ forwardRef(function TimeChart({
|
|
|
335
405
|
if (tooltipPinnedCoords === null) {
|
|
336
406
|
setShowTooltip(false);
|
|
337
407
|
}
|
|
408
|
+
// Defensive: clear hovered annotation in case ECharts missed a mouseout event.
|
|
409
|
+
setHoveredAnnotation(null);
|
|
338
410
|
if (chartRef.current !== undefined) {
|
|
339
411
|
clearHighlightedSeries(chartRef.current);
|
|
340
412
|
}
|
|
@@ -357,7 +429,7 @@ export const TimeSeriesChartBase = /*#__PURE__*/ forwardRef(function TimeChart({
|
|
|
357
429
|
}
|
|
358
430
|
},
|
|
359
431
|
children: [
|
|
360
|
-
showTooltip === true && option.tooltip?.showContent === false && tooltipConfig.hidden !== true && /*#__PURE__*/ _jsx(TimeChartTooltip, {
|
|
432
|
+
showTooltip === true && (tooltipPinnedCoords !== null || hoveredAnnotation === null) && option.tooltip?.showContent === false && tooltipConfig.hidden !== true && /*#__PURE__*/ _jsx(TimeChartTooltip, {
|
|
361
433
|
containerId: chartsTheme.tooltipPortalContainerId,
|
|
362
434
|
chartRef: chartRef,
|
|
363
435
|
data: data,
|
|
@@ -374,6 +446,17 @@ export const TimeSeriesChartBase = /*#__PURE__*/ forwardRef(function TimeChart({
|
|
|
374
446
|
setPinnedCrosshair(null);
|
|
375
447
|
}
|
|
376
448
|
}),
|
|
449
|
+
(pinnedAnnotation ?? hoveredAnnotation) && /*#__PURE__*/ _jsx(AnnotationTooltip, {
|
|
450
|
+
annotation: pinnedAnnotation ?? hoveredAnnotation,
|
|
451
|
+
containerId: chartsTheme.tooltipPortalContainerId,
|
|
452
|
+
formatWithUserTimeZone: formatWithUserTimeZone,
|
|
453
|
+
pinnedPos: pinnedAnnotation !== null ? pinnedAnnotationPos : null,
|
|
454
|
+
enablePinning: isPinningEnabled,
|
|
455
|
+
onUnpinClick: ()=>{
|
|
456
|
+
setPinnedAnnotation(null);
|
|
457
|
+
setPinnedAnnotationPos(null);
|
|
458
|
+
}
|
|
459
|
+
}),
|
|
377
460
|
/*#__PURE__*/ _jsx(EChart, {
|
|
378
461
|
sx: {
|
|
379
462
|
width: '100%',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/TimeSeriesChartBase.tsx"],"sourcesContent":["// Copyright 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 { forwardRef, MouseEvent, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';\nimport { Box } from '@mui/material';\nimport merge from 'lodash/merge';\nimport isEqual from 'lodash/isEqual';\n\nimport type {\n EChartsCoreOption,\n GridComponentOption,\n LineSeriesOption,\n YAXisComponentOption,\n TooltipComponentOption,\n} from 'echarts';\nimport { ECharts as EChartsInstance, use } from 'echarts/core';\nimport { LineChart as EChartsLineChart, BarChart as EChartsBarChart } from 'echarts/charts';\nimport {\n GridComponent,\n DatasetComponent,\n DataZoomComponent,\n MarkAreaComponent,\n MarkLineComponent,\n MarkPointComponent,\n TitleComponent,\n ToolboxComponent,\n TooltipComponent,\n} from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport {\n ChartInstance,\n ChartInstanceFocusOpts,\n clearHighlightedSeries,\n CursorCoordinates,\n DEFAULT_PINNED_CROSSHAIR,\n DEFAULT_TOOLTIP_CONFIG,\n EChart,\n enableDataZoom,\n FormatOptions,\n getClosestTimestamp,\n getCommonTimeScale,\n getFormattedAxis,\n getPointInGrid,\n OnEventsType,\n restoreChart,\n TimeChartSeriesMapping,\n TimeChartTooltip,\n TooltipConfig,\n useChartsContext,\n useTimeZone,\n ZoomEventData,\n} from '@perses-dev/components';\nimport { DatasetOption } from 'echarts/types/dist/shared';\nimport { TimeScale, TimeSeries } from '@perses-dev/spec';\nimport { createTimezoneAwareAxisFormatter } from './utils/timezone-formatter';\n\nuse([\n EChartsLineChart,\n EChartsBarChart,\n GridComponent,\n DatasetComponent,\n DataZoomComponent,\n MarkAreaComponent,\n MarkLineComponent,\n MarkPointComponent,\n TitleComponent,\n ToolboxComponent,\n TooltipComponent,\n CanvasRenderer,\n]);\n\nexport interface TimeChartProps {\n height: number;\n data: TimeSeries[];\n seriesMapping: TimeChartSeriesMapping;\n timeScale?: TimeScale;\n yAxis?: YAXisComponentOption | YAXisComponentOption[];\n format?: FormatOptions;\n /**\n * Map of series ID to format options, used for tooltip formatting when series have different units\n */\n seriesFormatMap?: Map<string, FormatOptions>;\n grid?: GridComponentOption;\n tooltipConfig?: TooltipConfig;\n noDataVariant?: 'chart' | 'message';\n syncGroup?: string;\n isStackedBar?: boolean;\n onDataZoom?: (e: ZoomEventData) => void;\n onDoubleClick?: (e: MouseEvent) => void;\n __experimentalEChartsOptionsOverride?: (options: EChartsCoreOption) => EChartsCoreOption;\n}\n\nexport const TimeSeriesChartBase = forwardRef<ChartInstance, TimeChartProps>(function TimeChart(\n {\n height,\n data,\n seriesMapping,\n timeScale: timeScaleProp,\n yAxis,\n format,\n seriesFormatMap,\n grid,\n isStackedBar = false,\n tooltipConfig = DEFAULT_TOOLTIP_CONFIG,\n noDataVariant = 'message',\n syncGroup,\n onDataZoom,\n onDoubleClick,\n __experimentalEChartsOptionsOverride,\n },\n ref\n) {\n const { chartsTheme, enablePinning, enableSyncGrouping, lastTooltipPinnedCoords, setLastTooltipPinnedCoords } =\n useChartsContext();\n const isPinningEnabled = tooltipConfig.enablePinning && enablePinning;\n const chartRef = useRef<EChartsInstance>();\n const [showTooltip, setShowTooltip] = useState<boolean>(true);\n const [tooltipPinnedCoords, setTooltipPinnedCoords] = useState<CursorCoordinates | null>(null);\n const [pinnedCrosshair, setPinnedCrosshair] = useState<LineSeriesOption | null>(null);\n const [isDragging, setIsDragging] = useState(false);\n const [startX, setStartX] = useState(0);\n const { timeZone } = useTimeZone();\n\n const getTimezoneAwareAxisFormatter = useCallback(\n (rangeMs: number): ((value: number) => string) => createTimezoneAwareAxisFormatter(rangeMs, timeZone),\n [timeZone]\n );\n\n let timeScale: TimeScale;\n if (timeScaleProp === undefined) {\n const commonTimeScale = getCommonTimeScale(data);\n if (commonTimeScale === undefined) {\n // set default to past 5 years\n const today = new Date();\n const pastDate = new Date(today);\n pastDate.setFullYear(today.getFullYear() - 5);\n const todayMs = today.getTime();\n const pastDateMs = pastDate.getTime();\n timeScale = { startMs: pastDateMs, endMs: todayMs, stepMs: 1, rangeMs: todayMs - pastDateMs };\n } else {\n timeScale = commonTimeScale;\n }\n } else {\n timeScale = timeScaleProp;\n }\n\n useImperativeHandle(ref, () => {\n return {\n highlightSeries({ name }: ChartInstanceFocusOpts): void {\n if (!chartRef.current) {\n // when chart undef, do not highlight series when hovering over legend\n return;\n }\n\n chartRef.current.dispatchAction({ type: 'highlight', seriesId: name });\n },\n clearHighlightedSeries: (): void => {\n if (!chartRef.current) {\n // when chart undef, do not clear highlight series\n return;\n }\n clearHighlightedSeries(chartRef.current);\n },\n };\n }, []);\n\n const handleEvents: OnEventsType<LineSeriesOption['data'] | unknown> = useMemo(() => {\n return {\n datazoom: (params): void => {\n if (onDataZoom === undefined) {\n setTimeout(() => {\n // workaround so unpin happens after click event\n setTooltipPinnedCoords(null);\n }, 10);\n }\n if (onDataZoom === undefined || params.batch[0] === undefined) return;\n const xAxisStartValue = params.batch[0].startValue;\n const xAxisEndValue = params.batch[0].endValue;\n if (xAxisStartValue !== undefined && xAxisEndValue !== undefined) {\n const zoomEvent: ZoomEventData = {\n start: xAxisStartValue,\n end: xAxisEndValue,\n };\n onDataZoom(zoomEvent);\n }\n },\n finished: (): void => {\n if (chartRef.current !== undefined) {\n enableDataZoom(chartRef.current);\n }\n },\n };\n }, [onDataZoom, setTooltipPinnedCoords]);\n\n const { noDataOption } = chartsTheme;\n\n const option: EChartsCoreOption = useMemo(() => {\n // The \"chart\" `noDataVariant` is only used when the `timeSeries` is an\n // empty array because a `null` value will throw an error.\n if (data === null || (data.length === 0 && noDataVariant === 'message')) return noDataOption;\n\n // Utilizes ECharts dataset so raw data is separate from series option style properties\n // https://apache.github.io/echarts-handbook/en/concepts/dataset/\n const dataset: DatasetOption[] = [];\n data.map((d, index) => {\n const values = d.values.map(([timestamp, value]) => {\n const val: string | number = value === null ? '-' : value; // echarts use '-' to represent null data\n return [timestamp, val];\n });\n dataset.push({ id: index, source: [...values], dimensions: ['time', 'value'] });\n });\n\n const updatedSeriesMapping =\n enablePinning && pinnedCrosshair !== null ? [...seriesMapping, pinnedCrosshair] : seriesMapping;\n\n const option: EChartsCoreOption = {\n dataset: dataset,\n series: updatedSeriesMapping,\n xAxis: {\n type: 'time',\n min: timeScale.startMs,\n max: timeScale.endMs,\n axisLabel: {\n hideOverlap: true,\n formatter: getTimezoneAwareAxisFormatter(timeScale.rangeMs ?? 0),\n },\n axisPointer: {\n snap: false, // important so shared crosshair does not lag\n },\n },\n // If yAxis is already an array (multiple Y axes), use it directly; otherwise use getFormattedAxis\n yAxis: Array.isArray(yAxis) ? yAxis : getFormattedAxis(yAxis, format),\n animation: false,\n tooltip: {\n show: true,\n // ECharts tooltip content hidden by default since we use custom tooltip instead.\n // Stacked bar uses ECharts tooltip so subgroup data shows correctly.\n showContent: isStackedBar,\n trigger: isStackedBar ? 'item' : 'axis',\n appendToBody: isStackedBar,\n },\n // https://echarts.apache.org/en/option.html#axisPointer\n axisPointer: {\n type: 'line',\n z: 0, // ensure point symbol shows on top of dashed line\n triggerEmphasis: false, // https://github.com/apache/echarts/issues/18495\n triggerTooltip: false,\n snap: false, // xAxis.axisPointer.snap takes priority\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 };\n\n if (__experimentalEChartsOptionsOverride) {\n return __experimentalEChartsOptionsOverride(option);\n }\n\n return option;\n }, [\n data,\n seriesMapping,\n timeScale,\n yAxis,\n format,\n grid,\n noDataOption,\n __experimentalEChartsOptionsOverride,\n noDataVariant,\n isStackedBar,\n enablePinning,\n pinnedCrosshair,\n getTimezoneAwareAxisFormatter,\n ]);\n\n // Update adjacent charts so tooltip is unpinned when current chart is clicked.\n useEffect(() => {\n // Only allow pinning one tooltip at a time, subsequent tooltip click unpins previous.\n // Multiple tooltips can only be pinned if Ctrl or Cmd key is pressed while clicking.\n const multipleTooltipsPinned = tooltipPinnedCoords !== null && lastTooltipPinnedCoords !== null;\n if (multipleTooltipsPinned) {\n if (!isEqual(lastTooltipPinnedCoords, tooltipPinnedCoords)) {\n setTooltipPinnedCoords(null);\n if (tooltipPinnedCoords !== null && pinnedCrosshair !== null) {\n setPinnedCrosshair(null);\n }\n }\n }\n // tooltipPinnedCoords CANNOT be in dep array or tooltip pinning breaks in the current chart's onClick\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [lastTooltipPinnedCoords, seriesMapping]);\n\n return (\n <Box\n style={{ height }}\n // onContextMenu={(e) => {\n // // TODO: confirm tooltip pinning works correctly on Windows, should e.preventDefault() be added here\n // e.preventDefault(); // Prevent the default behaviour when right clicked\n // }}\n onClick={(e) => {\n // Allows user to opt-in to multi tooltip pinning when Ctrl or Cmd key held down\n const isControlKeyPressed = e.ctrlKey || e.metaKey;\n if (isControlKeyPressed) {\n e.preventDefault();\n }\n\n // Determine where on chart canvas to plot pinned crosshair as markLine.\n const pointInGrid = getPointInGrid(e.nativeEvent.offsetX, e.nativeEvent.offsetY, chartRef.current);\n if (pointInGrid === null) {\n return;\n }\n\n // Pin and unpin when clicking on chart canvas but not tooltip text.\n if (isPinningEnabled && e.target instanceof HTMLCanvasElement) {\n // Pin tooltip and update shared charts context to remember these coordinates.\n const pinnedPos: CursorCoordinates = {\n page: {\n x: e.pageX,\n y: e.pageY,\n },\n client: {\n x: e.clientX,\n y: e.clientY,\n },\n plotCanvas: {\n x: e.nativeEvent.offsetX,\n y: e.nativeEvent.offsetY,\n },\n target: e.target,\n };\n\n setTooltipPinnedCoords((current) => {\n if (current === null) {\n return pinnedPos;\n } else {\n setPinnedCrosshair(null);\n return null;\n }\n });\n\n setPinnedCrosshair((current) => {\n // Only add pinned crosshair line series when there is not one already in seriesMapping.\n if (current === null) {\n const cursorX = pointInGrid[0];\n\n // Only need to loop through first dataset source since getCommonTimeScale ensures xAxis timestamps are consistent\n const firstTimeSeriesValues = data[0]?.values;\n const closestTimestamp = getClosestTimestamp(firstTimeSeriesValues, cursorX);\n\n // Crosshair snaps to nearest timestamp since cursor may be slightly to left or right\n const pinnedCrosshair = merge({}, DEFAULT_PINNED_CROSSHAIR, {\n markLine: {\n data: [\n {\n xAxis: closestTimestamp,\n },\n ],\n },\n } as LineSeriesOption);\n return pinnedCrosshair;\n } else {\n // Clear previously set pinned crosshair\n return null;\n }\n });\n\n if (!isControlKeyPressed) {\n setLastTooltipPinnedCoords(pinnedPos);\n }\n }\n }}\n onMouseDown={(e) => {\n const { clientX } = e;\n setIsDragging(true);\n setStartX(clientX);\n }}\n onMouseMove={(e) => {\n // Allow clicking inside tooltip to copy labels.\n if (!(e.target instanceof HTMLCanvasElement)) {\n return;\n }\n const { clientX } = e;\n if (isDragging) {\n const deltaX = clientX - startX;\n if (deltaX > 0) {\n // Hide tooltip when user drags to zoom.\n setShowTooltip(false);\n }\n }\n }}\n onMouseUp={() => {\n setIsDragging(false);\n setStartX(0);\n setShowTooltip(true);\n }}\n onMouseLeave={() => {\n if (tooltipPinnedCoords === null) {\n setShowTooltip(false);\n }\n if (chartRef.current !== undefined) {\n clearHighlightedSeries(chartRef.current);\n }\n }}\n onMouseEnter={() => {\n setShowTooltip(true);\n if (chartRef.current !== undefined) {\n enableDataZoom(chartRef.current);\n }\n }}\n onDoubleClick={(e) => {\n setTooltipPinnedCoords(null);\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 {/* Allows overrides prop to hide custom tooltip and use the ECharts option.tooltip instead */}\n {showTooltip === true &&\n (option.tooltip as TooltipComponentOption)?.showContent === false &&\n tooltipConfig.hidden !== true && (\n <TimeChartTooltip\n containerId={chartsTheme.tooltipPortalContainerId}\n chartRef={chartRef}\n data={data}\n seriesMapping={seriesMapping}\n wrapLabels={tooltipConfig.wrapLabels}\n enablePinning={isPinningEnabled}\n pinnedPos={tooltipPinnedCoords}\n format={format}\n seriesFormatMap={seriesFormatMap}\n onUnpinClick={() => {\n // Unpins tooltip when clicking Pin icon in TooltipHeader.\n setTooltipPinnedCoords(null);\n // Clear previously set pinned crosshair.\n setPinnedCrosshair(null);\n }}\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 syncGroup={enableSyncGrouping ? syncGroup : undefined}\n />\n </Box>\n );\n});\n"],"names":["forwardRef","useCallback","useEffect","useImperativeHandle","useMemo","useRef","useState","Box","merge","isEqual","use","LineChart","EChartsLineChart","BarChart","EChartsBarChart","GridComponent","DatasetComponent","DataZoomComponent","MarkAreaComponent","MarkLineComponent","MarkPointComponent","TitleComponent","ToolboxComponent","TooltipComponent","CanvasRenderer","clearHighlightedSeries","DEFAULT_PINNED_CROSSHAIR","DEFAULT_TOOLTIP_CONFIG","EChart","enableDataZoom","getClosestTimestamp","getCommonTimeScale","getFormattedAxis","getPointInGrid","restoreChart","TimeChartTooltip","useChartsContext","useTimeZone","createTimezoneAwareAxisFormatter","TimeSeriesChartBase","TimeChart","height","data","seriesMapping","timeScale","timeScaleProp","yAxis","format","seriesFormatMap","grid","isStackedBar","tooltipConfig","noDataVariant","syncGroup","onDataZoom","onDoubleClick","__experimentalEChartsOptionsOverride","ref","chartsTheme","enablePinning","enableSyncGrouping","lastTooltipPinnedCoords","setLastTooltipPinnedCoords","isPinningEnabled","chartRef","showTooltip","setShowTooltip","tooltipPinnedCoords","setTooltipPinnedCoords","pinnedCrosshair","setPinnedCrosshair","isDragging","setIsDragging","startX","setStartX","timeZone","getTimezoneAwareAxisFormatter","rangeMs","undefined","commonTimeScale","today","Date","pastDate","setFullYear","getFullYear","todayMs","getTime","pastDateMs","startMs","endMs","stepMs","highlightSeries","name","current","dispatchAction","type","seriesId","handleEvents","datazoom","params","setTimeout","batch","xAxisStartValue","startValue","xAxisEndValue","endValue","zoomEvent","start","end","finished","noDataOption","option","length","dataset","map","d","index","values","timestamp","value","val","push","id","source","dimensions","updatedSeriesMapping","series","xAxis","min","max","axisLabel","hideOverlap","formatter","axisPointer","snap","Array","isArray","animation","tooltip","show","showContent","trigger","appendToBody","z","triggerEmphasis","triggerTooltip","toolbox","feature","dataZoom","icon","yAxisIndex","multipleTooltipsPinned","style","onClick","e","isControlKeyPressed","ctrlKey","metaKey","preventDefault","pointInGrid","nativeEvent","offsetX","offsetY","target","HTMLCanvasElement","pinnedPos","page","x","pageX","y","pageY","client","clientX","clientY","plotCanvas","cursorX","firstTimeSeriesValues","closestTimestamp","markLine","onMouseDown","onMouseMove","deltaX","onMouseUp","onMouseLeave","onMouseEnter","hidden","containerId","tooltipPortalContainerId","wrapLabels","onUnpinClick","sx","width","theme","echartsTheme","onEvents","_instance"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CA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;QACF;;YAGCzF,gBAAgB,QACf,AAAC8C,OAAO2B,OAAO,EAA6BE,gBAAgB,SAC5DzF,cAAcsI,MAAM,KAAK,sBACvB,KAACtJ;gBACCuJ,aAAahI,YAAYiI,wBAAwB;gBACjD3H,UAAUA;gBACVtB,MAAMA;gBACNC,eAAeA;gBACfiJ,YAAYzI,cAAcyI,UAAU;gBACpCjI,eAAeI;gBACfsG,WAAWlG;gBACXpB,QAAQA;gBACRC,iBAAiBA;gBACjB6I,cAAc;oBACZ,0DAA0D;oBAC1DzH,uBAAuB;oBACvB,yCAAyC;oBACzCE,mBAAmB;gBACrB;;0BAGN,KAAC1C;gBACCkK,IAAI;oBACFC,OAAO;oBACPtJ,QAAQ;gBACV;gBACAsE,QAAQA;gBACRiF,OAAOtI,YAAYuI,YAAY;gBAC/BC,UAAUjG;gBACVkG,WAAWnI;gBACXX,WAAWO,qBAAqBP,YAAYyB;;;;AAIpD,GAAG"}
|
|
1
|
+
{"version":3,"sources":["../../src/TimeSeriesChartBase.tsx"],"sourcesContent":["// Copyright 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 { forwardRef, MouseEvent, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';\nimport { Box } from '@mui/material';\nimport merge from 'lodash/merge';\nimport isEqual from 'lodash/isEqual';\n\nimport type {\n EChartsCoreOption,\n GridComponentOption,\n LineSeriesOption,\n YAXisComponentOption,\n TooltipComponentOption,\n} from 'echarts';\nimport { ECharts as EChartsInstance, use } from 'echarts/core';\nimport { LineChart as EChartsLineChart, BarChart as EChartsBarChart } from 'echarts/charts';\nimport {\n GridComponent,\n DatasetComponent,\n DataZoomComponent,\n MarkAreaComponent,\n MarkLineComponent,\n MarkPointComponent,\n TitleComponent,\n ToolboxComponent,\n TooltipComponent,\n} from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport {\n ChartInstance,\n ChartInstanceFocusOpts,\n clearHighlightedSeries,\n CursorCoordinates,\n DEFAULT_PINNED_CROSSHAIR,\n DEFAULT_TOOLTIP_CONFIG,\n EChart,\n enableDataZoom,\n FormatOptions,\n getClosestTimestamp,\n getCommonTimeScale,\n getFormattedAxis,\n getPointInGrid,\n OnEventsType,\n restoreChart,\n TimeChartSeriesMapping,\n TimeChartTooltip,\n TooltipConfig,\n useChartsContext,\n useTimeZone,\n ZoomEventData,\n} from '@perses-dev/components';\nimport { DatasetOption } from 'echarts/types/dist/shared';\nimport { TimeScale, TimeSeries } from '@perses-dev/spec';\nimport { createTimezoneAwareAxisFormatter } from './utils/timezone-formatter';\nimport { TimeSeriesAnnotation } from './utils/annotation';\nimport { AnnotationTooltip, buildAnnotationSeries } from './annotations/AnnotationTooltip';\n\nuse([\n EChartsLineChart,\n EChartsBarChart,\n GridComponent,\n DatasetComponent,\n DataZoomComponent,\n MarkAreaComponent,\n MarkLineComponent,\n MarkPointComponent,\n TitleComponent,\n ToolboxComponent,\n TooltipComponent,\n CanvasRenderer,\n]);\n\nexport interface TimeChartProps {\n height: number;\n data: TimeSeries[];\n seriesMapping: TimeChartSeriesMapping;\n annotations?: TimeSeriesAnnotation[];\n timeScale?: TimeScale;\n yAxis?: YAXisComponentOption | YAXisComponentOption[];\n format?: FormatOptions;\n /**\n * Map of series ID to format options, used for tooltip formatting when series have different units\n */\n seriesFormatMap?: Map<string, FormatOptions>;\n grid?: GridComponentOption;\n tooltipConfig?: TooltipConfig;\n noDataVariant?: 'chart' | 'message';\n syncGroup?: string;\n isStackedBar?: boolean;\n onDataZoom?: (e: ZoomEventData) => void;\n onDoubleClick?: (e: MouseEvent) => void;\n __experimentalEChartsOptionsOverride?: (options: EChartsCoreOption) => EChartsCoreOption;\n}\n\nexport const TimeSeriesChartBase = forwardRef<ChartInstance, TimeChartProps>(function TimeChart(\n {\n height,\n data,\n seriesMapping,\n annotations,\n timeScale: timeScaleProp,\n yAxis,\n format,\n seriesFormatMap,\n grid,\n isStackedBar = false,\n tooltipConfig = DEFAULT_TOOLTIP_CONFIG,\n noDataVariant = 'message',\n syncGroup,\n onDataZoom,\n onDoubleClick,\n __experimentalEChartsOptionsOverride,\n },\n ref\n) {\n const { chartsTheme, enablePinning, enableSyncGrouping, lastTooltipPinnedCoords, setLastTooltipPinnedCoords } =\n useChartsContext();\n const isPinningEnabled = tooltipConfig.enablePinning && enablePinning;\n const chartRef = useRef<EChartsInstance>();\n const [showTooltip, setShowTooltip] = useState<boolean>(true);\n const [tooltipPinnedCoords, setTooltipPinnedCoords] = useState<CursorCoordinates | null>(null);\n const [pinnedCrosshair, setPinnedCrosshair] = useState<LineSeriesOption | null>(null);\n const [isDragging, setIsDragging] = useState(false);\n const [startX, setStartX] = useState(0);\n const [hoveredAnnotation, setHoveredAnnotation] = useState<TimeSeriesAnnotation | null>(null);\n const [pinnedAnnotation, setPinnedAnnotation] = useState<TimeSeriesAnnotation | null>(null);\n const [pinnedAnnotationPos, setPinnedAnnotationPos] = useState<CursorCoordinates | null>(null);\n const { timeZone, formatWithUserTimeZone } = useTimeZone();\n\n const getTimezoneAwareAxisFormatter = useCallback(\n (rangeMs: number): ((value: number) => string) => createTimezoneAwareAxisFormatter(rangeMs, timeZone),\n [timeZone]\n );\n\n let timeScale: TimeScale;\n if (timeScaleProp === undefined) {\n const commonTimeScale = getCommonTimeScale(data);\n if (commonTimeScale === undefined) {\n // set default to past 5 years\n const today = new Date();\n const pastDate = new Date(today);\n pastDate.setFullYear(today.getFullYear() - 5);\n const todayMs = today.getTime();\n const pastDateMs = pastDate.getTime();\n timeScale = { startMs: pastDateMs, endMs: todayMs, stepMs: 1, rangeMs: todayMs - pastDateMs };\n } else {\n timeScale = commonTimeScale;\n }\n } else {\n timeScale = timeScaleProp;\n }\n\n useImperativeHandle(ref, () => {\n return {\n highlightSeries({ name }: ChartInstanceFocusOpts): void {\n if (!chartRef.current) {\n // when chart undef, do not highlight series when hovering over legend\n return;\n }\n\n chartRef.current.dispatchAction({ type: 'highlight', seriesId: name });\n },\n clearHighlightedSeries: (): void => {\n if (!chartRef.current) {\n // when chart undef, do not clear highlight series\n return;\n }\n clearHighlightedSeries(chartRef.current);\n },\n };\n }, []);\n\n const handleEvents: OnEventsType<LineSeriesOption['data'] | unknown> = useMemo(() => {\n return {\n datazoom: (params): void => {\n if (onDataZoom === undefined) {\n setTimeout(() => {\n // workaround so unpin happens after click event\n setTooltipPinnedCoords(null);\n }, 10);\n }\n if (onDataZoom === undefined || params.batch[0] === undefined) return;\n const xAxisStartValue = params.batch[0].startValue;\n const xAxisEndValue = params.batch[0].endValue;\n if (xAxisStartValue !== undefined && xAxisEndValue !== undefined) {\n const zoomEvent: ZoomEventData = {\n start: xAxisStartValue,\n end: xAxisEndValue,\n };\n onDataZoom(zoomEvent);\n }\n },\n finished: (): void => {\n if (chartRef.current !== undefined) {\n enableDataZoom(chartRef.current);\n }\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n mouseover: (params: any): void => {\n // Only markPoint (triangles under the X-axis) opens the annotation tooltip.\n // Hovering markLine or anything else keeps the regular TimeSeries tooltip visible\n // and clears any stale hovered annotation (mouseout is sometimes missed by ECharts).\n if (annotations && params.componentType === 'markPoint' && params.data?.annotationIndex !== undefined) {\n const matchedAnnotation = annotations[params.data.annotationIndex] || null;\n if (matchedAnnotation) {\n setHoveredAnnotation(matchedAnnotation);\n return;\n }\n }\n setHoveredAnnotation(null);\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n mouseout: (params: any): void => {\n if (\n annotations &&\n params.componentType === 'markPoint' &&\n params.data?.annotationIndex !== undefined &&\n annotations\n ) {\n // Only clear if the mouseout corresponds to the currently hovered annotation, so that\n // a quick move from one markPoint to another isn't cancelled by a late mouseout event.\n const leaving = annotations[params.data.annotationIndex] || null;\n setHoveredAnnotation((current) => (current === leaving ? null : current));\n }\n },\n globalout: (): void => {\n if (annotations) {\n // Cursor left the chart canvas — guarantee the annotation tooltip is dismissed.\n setHoveredAnnotation(null);\n }\n },\n };\n }, [annotations, onDataZoom]);\n\n // Generate annotation series for ECharts markArea (range), markLine (point), and markPoint (markers under X-axis)\n const annotationSeries = useMemo(() => buildAnnotationSeries(annotations), [annotations]);\n\n const { noDataOption } = chartsTheme;\n\n const option: EChartsCoreOption = useMemo(() => {\n // The \"chart\" `noDataVariant` is only used when the `timeSeries` is an\n // empty array because a `null` value will throw an error.\n if (data === null || (data.length === 0 && noDataVariant === 'message')) return noDataOption;\n\n // Utilizes ECharts dataset so raw data is separate from series option style properties\n // https://apache.github.io/echarts-handbook/en/concepts/dataset/\n const dataset: DatasetOption[] = [];\n data.map((d, index) => {\n const values = d.values.map(([timestamp, value]) => {\n const val: string | number = value === null ? '-' : value; // echarts use '-' to represent null data\n return [timestamp, val];\n });\n dataset.push({ id: index, source: [...values], dimensions: ['time', 'value'] });\n });\n\n const updatedSeriesMapping =\n enablePinning && pinnedCrosshair !== null\n ? [...seriesMapping, pinnedCrosshair, ...annotationSeries]\n : [...seriesMapping, ...annotationSeries];\n\n const option: EChartsCoreOption = {\n dataset: dataset,\n series: updatedSeriesMapping,\n xAxis: {\n type: 'time',\n min: timeScale.startMs,\n max: timeScale.endMs,\n axisLabel: {\n hideOverlap: true,\n formatter: getTimezoneAwareAxisFormatter(timeScale.rangeMs ?? 0),\n },\n axisPointer: {\n snap: false, // important so shared crosshair does not lag\n },\n },\n // If yAxis is already an array (multiple Y axes), use it directly; otherwise use getFormattedAxis\n yAxis: Array.isArray(yAxis) ? yAxis : getFormattedAxis(yAxis, format),\n animation: false,\n tooltip: {\n show: true,\n // ECharts tooltip content hidden by default since we use custom tooltip instead.\n // Stacked bar uses ECharts tooltip so subgroup data shows correctly.\n showContent: isStackedBar,\n trigger: isStackedBar ? 'item' : 'axis',\n appendToBody: isStackedBar,\n },\n // https://echarts.apache.org/en/option.html#axisPointer\n axisPointer: {\n type: 'line',\n z: 0, // ensure point symbol shows on top of dashed line\n triggerEmphasis: false, // https://github.com/apache/echarts/issues/18495\n triggerTooltip: false,\n snap: false, // xAxis.axisPointer.snap takes priority\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 };\n\n if (__experimentalEChartsOptionsOverride) {\n return __experimentalEChartsOptionsOverride(option);\n }\n\n return option;\n }, [\n data,\n seriesMapping,\n annotationSeries,\n timeScale,\n yAxis,\n format,\n grid,\n noDataOption,\n __experimentalEChartsOptionsOverride,\n noDataVariant,\n isStackedBar,\n enablePinning,\n pinnedCrosshair,\n getTimezoneAwareAxisFormatter,\n ]);\n\n // Update adjacent charts so tooltip is unpinned when current chart is clicked.\n useEffect(() => {\n // Only allow pinning one tooltip at a time, subsequent tooltip click unpins previous.\n // Multiple tooltips can only be pinned if Ctrl or Cmd key is pressed while clicking.\n const multipleTooltipsPinned = tooltipPinnedCoords !== null && lastTooltipPinnedCoords !== null;\n if (multipleTooltipsPinned) {\n if (!isEqual(lastTooltipPinnedCoords, tooltipPinnedCoords)) {\n setTooltipPinnedCoords(null);\n if (tooltipPinnedCoords !== null && pinnedCrosshair !== null) {\n setPinnedCrosshair(null);\n }\n }\n }\n // tooltipPinnedCoords CANNOT be in dep array or tooltip pinning breaks in the current chart's onClick\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [lastTooltipPinnedCoords, seriesMapping]);\n\n return (\n <Box\n style={{ height }}\n // onContextMenu={(e) => {\n // // TODO: confirm tooltip pinning works correctly on Windows, should e.preventDefault() be added here\n // e.preventDefault(); // Prevent the default behaviour when right clicked\n // }}\n onClick={(e) => {\n // If clicking while hovering an annotation, toggle the annotation tooltip pin\n // instead of pinning the TimeChartTooltip, so pinned TimeChartTooltip is preserved.\n if (hoveredAnnotation !== null && e.target instanceof HTMLCanvasElement) {\n const pinnedPos: CursorCoordinates = {\n page: { x: e.pageX, y: e.pageY },\n client: { x: e.clientX, y: e.clientY },\n plotCanvas: { x: e.nativeEvent.offsetX, y: e.nativeEvent.offsetY },\n target: e.target,\n };\n setPinnedAnnotation((current) => {\n if (current === hoveredAnnotation) {\n setPinnedAnnotationPos(null);\n return null;\n }\n setPinnedAnnotationPos(pinnedPos);\n return hoveredAnnotation;\n });\n return;\n }\n\n // Allows user to opt-in to multi tooltip pinning when Ctrl or Cmd key held down\n const isControlKeyPressed = e.ctrlKey || e.metaKey;\n if (isControlKeyPressed) {\n e.preventDefault();\n }\n\n // Determine where on chart canvas to plot pinned crosshair as markLine.\n const pointInGrid = getPointInGrid(e.nativeEvent.offsetX, e.nativeEvent.offsetY, chartRef.current);\n if (pointInGrid === null) {\n return;\n }\n\n // Pin and unpin when clicking on chart canvas but not tooltip text.\n if (isPinningEnabled && e.target instanceof HTMLCanvasElement) {\n // Pin tooltip and update shared charts context to remember these coordinates.\n const pinnedPos: CursorCoordinates = {\n page: {\n x: e.pageX,\n y: e.pageY,\n },\n client: {\n x: e.clientX,\n y: e.clientY,\n },\n plotCanvas: {\n x: e.nativeEvent.offsetX,\n y: e.nativeEvent.offsetY,\n },\n target: e.target,\n };\n\n setTooltipPinnedCoords((current) => {\n if (current === null) {\n return pinnedPos;\n } else {\n setPinnedCrosshair(null);\n return null;\n }\n });\n\n setPinnedCrosshair((current) => {\n // Only add pinned crosshair line series when there is not one already in seriesMapping.\n if (current === null) {\n const cursorX = pointInGrid[0];\n\n // Only need to loop through first dataset source since getCommonTimeScale ensures xAxis timestamps are consistent\n const firstTimeSeriesValues = data[0]?.values;\n const closestTimestamp = getClosestTimestamp(firstTimeSeriesValues, cursorX);\n\n // Crosshair snaps to nearest timestamp since cursor may be slightly to left or right\n const pinnedCrosshair = merge({}, DEFAULT_PINNED_CROSSHAIR, {\n markLine: {\n data: [\n {\n xAxis: closestTimestamp,\n },\n ],\n },\n } as LineSeriesOption);\n return pinnedCrosshair;\n } else {\n // Clear previously set pinned crosshair\n return null;\n }\n });\n\n if (!isControlKeyPressed) {\n setLastTooltipPinnedCoords(pinnedPos);\n }\n }\n }}\n onMouseDown={(e) => {\n const { clientX } = e;\n setIsDragging(true);\n setStartX(clientX);\n }}\n onMouseMove={(e) => {\n // Allow clicking inside tooltip to copy labels.\n if (!(e.target instanceof HTMLCanvasElement)) {\n return;\n }\n const { clientX } = e;\n if (isDragging) {\n const deltaX = clientX - startX;\n if (deltaX > 0) {\n // Hide tooltip when user drags to zoom.\n setShowTooltip(false);\n }\n }\n }}\n onMouseUp={() => {\n setIsDragging(false);\n setStartX(0);\n setShowTooltip(true);\n }}\n onMouseLeave={() => {\n if (tooltipPinnedCoords === null) {\n setShowTooltip(false);\n }\n // Defensive: clear hovered annotation in case ECharts missed a mouseout event.\n setHoveredAnnotation(null);\n if (chartRef.current !== undefined) {\n clearHighlightedSeries(chartRef.current);\n }\n }}\n onMouseEnter={() => {\n setShowTooltip(true);\n if (chartRef.current !== undefined) {\n enableDataZoom(chartRef.current);\n }\n }}\n onDoubleClick={(e) => {\n setTooltipPinnedCoords(null);\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 {/* Allows overrides prop to hide custom tooltip and use the ECharts option.tooltip instead.\n Keep the time chart tooltip visible when pinned even if user hovers an annotation. */}\n {showTooltip === true &&\n (tooltipPinnedCoords !== null || hoveredAnnotation === null) &&\n (option.tooltip as TooltipComponentOption)?.showContent === false &&\n tooltipConfig.hidden !== true && (\n <TimeChartTooltip\n containerId={chartsTheme.tooltipPortalContainerId}\n chartRef={chartRef}\n data={data}\n seriesMapping={seriesMapping}\n wrapLabels={tooltipConfig.wrapLabels}\n enablePinning={isPinningEnabled}\n pinnedPos={tooltipPinnedCoords}\n format={format}\n seriesFormatMap={seriesFormatMap}\n onUnpinClick={() => {\n // Unpins tooltip when clicking Pin icon in TooltipHeader.\n setTooltipPinnedCoords(null);\n // Clear previously set pinned crosshair.\n setPinnedCrosshair(null);\n }}\n />\n )}\n {/* Pinned annotation takes priority over hovered. */}\n {(pinnedAnnotation ?? hoveredAnnotation) && (\n <AnnotationTooltip\n annotation={(pinnedAnnotation ?? hoveredAnnotation) as TimeSeriesAnnotation}\n containerId={chartsTheme.tooltipPortalContainerId}\n formatWithUserTimeZone={formatWithUserTimeZone}\n pinnedPos={pinnedAnnotation !== null ? pinnedAnnotationPos : null}\n enablePinning={isPinningEnabled}\n onUnpinClick={() => {\n setPinnedAnnotation(null);\n setPinnedAnnotationPos(null);\n }}\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 syncGroup={enableSyncGrouping ? syncGroup : undefined}\n />\n </Box>\n );\n});\n"],"names":["forwardRef","useCallback","useEffect","useImperativeHandle","useMemo","useRef","useState","Box","merge","isEqual","use","LineChart","EChartsLineChart","BarChart","EChartsBarChart","GridComponent","DatasetComponent","DataZoomComponent","MarkAreaComponent","MarkLineComponent","MarkPointComponent","TitleComponent","ToolboxComponent","TooltipComponent","CanvasRenderer","clearHighlightedSeries","DEFAULT_PINNED_CROSSHAIR","DEFAULT_TOOLTIP_CONFIG","EChart","enableDataZoom","getClosestTimestamp","getCommonTimeScale","getFormattedAxis","getPointInGrid","restoreChart","TimeChartTooltip","useChartsContext","useTimeZone","createTimezoneAwareAxisFormatter","AnnotationTooltip","buildAnnotationSeries","TimeSeriesChartBase","TimeChart","height","data","seriesMapping","annotations","timeScale","timeScaleProp","yAxis","format","seriesFormatMap","grid","isStackedBar","tooltipConfig","noDataVariant","syncGroup","onDataZoom","onDoubleClick","__experimentalEChartsOptionsOverride","ref","chartsTheme","enablePinning","enableSyncGrouping","lastTooltipPinnedCoords","setLastTooltipPinnedCoords","isPinningEnabled","chartRef","showTooltip","setShowTooltip","tooltipPinnedCoords","setTooltipPinnedCoords","pinnedCrosshair","setPinnedCrosshair","isDragging","setIsDragging","startX","setStartX","hoveredAnnotation","setHoveredAnnotation","pinnedAnnotation","setPinnedAnnotation","pinnedAnnotationPos","setPinnedAnnotationPos","timeZone","formatWithUserTimeZone","getTimezoneAwareAxisFormatter","rangeMs","undefined","commonTimeScale","today","Date","pastDate","setFullYear","getFullYear","todayMs","getTime","pastDateMs","startMs","endMs","stepMs","highlightSeries","name","current","dispatchAction","type","seriesId","handleEvents","datazoom","params","setTimeout","batch","xAxisStartValue","startValue","xAxisEndValue","endValue","zoomEvent","start","end","finished","mouseover","componentType","annotationIndex","matchedAnnotation","mouseout","leaving","globalout","annotationSeries","noDataOption","option","length","dataset","map","d","index","values","timestamp","value","val","push","id","source","dimensions","updatedSeriesMapping","series","xAxis","min","max","axisLabel","hideOverlap","formatter","axisPointer","snap","Array","isArray","animation","tooltip","show","showContent","trigger","appendToBody","z","triggerEmphasis","triggerTooltip","toolbox","feature","dataZoom","icon","yAxisIndex","multipleTooltipsPinned","style","onClick","e","target","HTMLCanvasElement","pinnedPos","page","x","pageX","y","pageY","client","clientX","clientY","plotCanvas","nativeEvent","offsetX","offsetY","isControlKeyPressed","ctrlKey","metaKey","preventDefault","pointInGrid","cursorX","firstTimeSeriesValues","closestTimestamp","markLine","onMouseDown","onMouseMove","deltaX","onMouseUp","onMouseLeave","onMouseEnter","hidden","containerId","tooltipPortalContainerId","wrapLabels","onUnpinClick","annotation","sx","width","theme","echartsTheme","onEvents","_instance"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,UAAU,EAAcC,WAAW,EAAEC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imeSeriesChartPanel.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesChartPanel.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAA6B,MAAM,OAAO,CAAC;AAIhE,OAAO,EAEL,UAAU,EAMX,MAAM,2BAA2B,CAAC;AAqBnC,OAAO,EAAc,cAAc,EAAwB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"TimeSeriesChartPanel.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesChartPanel.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAA6B,MAAM,OAAO,CAAC;AAIhE,OAAO,EAEL,UAAU,EAMX,MAAM,2BAA2B,CAAC;AAqBnC,OAAO,EAAc,cAAc,EAAwB,MAAM,kBAAkB,CAAC;AAEpF,OAAO,EACL,sBAAsB,EAKvB,MAAM,2BAA2B,CAAC;AAYnC,MAAM,MAAM,oBAAoB,GAAG,UAAU,CAAC,sBAAsB,EAAE,cAAc,CAAC,CAAC;AAWtF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,oBAAoB,GAAG,YAAY,GAAG,IAAI,CA+crF"}
|
|
@@ -16,10 +16,12 @@ import { Box, useTheme } from '@mui/material';
|
|
|
16
16
|
import merge from 'lodash/merge';
|
|
17
17
|
import { LEGEND_VALUE_CONFIG, useTimeRange, validateLegendSpec, legendValues, getCalculations } from '@perses-dev/plugin-system';
|
|
18
18
|
import { YAxisLabel, useChartsTheme, ContentWithLegend, useId, DEFAULT_TOOLTIP_CONFIG, getFormattedMultipleYAxes, DEFAULT_LEGEND, formatValue, getTimeSeriesValues } from '@perses-dev/components';
|
|
19
|
+
import { useAnnotationsWithData } from '@perses-dev/dashboards';
|
|
19
20
|
import { DEFAULT_FORMAT, DEFAULT_VISUAL, THRESHOLD_PLOT_INTERVAL } from './time-series-chart-model';
|
|
20
21
|
import { getTimeSeries, getCommonTimeScaleForQueries, convertPanelYAxis, getThresholdSeries, convertPercentThreshold } from './utils/data-transform';
|
|
21
22
|
import { getSeriesColor } from './utils/palette-gen';
|
|
22
23
|
import { TimeSeriesChartBase } from './TimeSeriesChartBase';
|
|
24
|
+
import { convertAnnotationToTimeSeriesAnnotation } from './utils/annotation';
|
|
23
25
|
// Using an "ALL" value to handle the case on first loading the chart where we
|
|
24
26
|
// want to select all, but do not want all of the legend items to be visually highlighted.
|
|
25
27
|
// This helps us differentiate those cases more clearly instead of inferring it
|
|
@@ -100,6 +102,10 @@ export function TimeSeriesChartPanel(props) {
|
|
|
100
102
|
const [selectedLegendItems, setSelectedLegendItems] = useState('ALL');
|
|
101
103
|
const [legendSorting, setLegendSorting] = useState();
|
|
102
104
|
const { setTimeRange } = useTimeRange();
|
|
105
|
+
const annotationsWithData = useAnnotationsWithData();
|
|
106
|
+
const annotations = useMemo(()=>convertAnnotationToTimeSeriesAnnotation(annotationsWithData), [
|
|
107
|
+
annotationsWithData
|
|
108
|
+
]);
|
|
103
109
|
// Populate series data based on query results
|
|
104
110
|
const { timeScale, timeChartData, timeSeriesMapping, legendItems, seriesFormatMap: computedSeriesFormatMap, maxValuesByFormat } = useMemo(()=>{
|
|
105
111
|
const timeScale = getCommonTimeScaleForQueries(queryResults);
|
|
@@ -190,9 +196,21 @@ export function TimeSeriesChartPanel(props) {
|
|
|
190
196
|
}
|
|
191
197
|
}
|
|
192
198
|
}
|
|
199
|
+
// When negativeY is set on this query, negate the rendered values so the
|
|
200
|
+
// series renders below the X axis. The original (positive) values are
|
|
201
|
+
// preserved in `timeSeries.values` (used for legend calculations) and in
|
|
202
|
+
// `queryResults` (used for CSV export).
|
|
203
|
+
const baseValues = getTimeSeriesValues(timeSeries, timeScale);
|
|
204
|
+
const renderedValues = querySettings?.negativeY ? baseValues.map((tuple)=>{
|
|
205
|
+
const [t, v] = tuple;
|
|
206
|
+
return [
|
|
207
|
+
t,
|
|
208
|
+
v === null ? null : -v
|
|
209
|
+
];
|
|
210
|
+
}) : baseValues;
|
|
193
211
|
timeChartData.push({
|
|
194
212
|
name: formattedSeriesName,
|
|
195
|
-
values:
|
|
213
|
+
values: renderedValues
|
|
196
214
|
});
|
|
197
215
|
}
|
|
198
216
|
if (legend && legendItems) {
|
|
@@ -348,8 +366,10 @@ export function TimeSeriesChartPanel(props) {
|
|
|
348
366
|
end: new Date(event.end)
|
|
349
367
|
});
|
|
350
368
|
};
|
|
351
|
-
// Used to opt in to ECharts trigger item which show subgroup data accurately
|
|
352
|
-
|
|
369
|
+
// Used to opt in to ECharts trigger item which show subgroup data accurately.
|
|
370
|
+
// Derived from the actual series mapping rather than `visual.stack` alone so that
|
|
371
|
+
// bar charts stacked only via per-query overrides also use the right tooltip mode.
|
|
372
|
+
const isStackedBar = visual.display === 'bar' && timeSeriesMapping.some((s)=>s?.type === 'bar' && s.stack === 'all');
|
|
353
373
|
// Turn on tooltip pinning by default but opt out for stacked bar or if explicitly set in tooltip panel spec
|
|
354
374
|
let enablePinning = true;
|
|
355
375
|
if (isStackedBar) {
|
|
@@ -407,6 +427,7 @@ export function TimeSeriesChartPanel(props) {
|
|
|
407
427
|
height: height,
|
|
408
428
|
data: timeChartData,
|
|
409
429
|
seriesMapping: timeSeriesMapping,
|
|
430
|
+
annotations: annotations,
|
|
410
431
|
timeScale: timeScale,
|
|
411
432
|
yAxis: multipleYAxes ?? echartsYAxis,
|
|
412
433
|
format: format,
|