@perses-dev/timeseries-chart-plugin 0.14.0-beta.8 → 0.14.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.aa6aa96b.js → TimeSeriesChart.89eaf4ff.js} +2 -2
- package/__mf/js/async/1409.855b83fb.js +7 -0
- package/__mf/js/async/1616.547457d5.js +1 -0
- package/__mf/js/async/2490.8d139ea3.js +2 -0
- package/__mf/js/async/392.c9cdaa1e.js +2 -0
- package/__mf/js/async/4077.51fc0aad.js +1 -0
- package/__mf/js/async/4121.5ad4a1ae.js +2 -0
- package/__mf/js/async/{4134.9d3e6a8b.js → 4134.fe1c2e4e.js} +1 -1
- package/__mf/js/async/4496.20ca25bf.js +1 -0
- package/__mf/js/async/4670.c0d3f8f3.js +2 -0
- package/__mf/js/async/5002.89978152.js +1 -0
- package/__mf/js/async/5071.722913e8.js +1 -0
- package/__mf/js/async/{5182.375bbf8e.js → 5182.b8a5b924.js} +2 -2
- package/__mf/js/async/5587.b4b20c0d.js +1 -0
- package/__mf/js/async/6274.c3436b0e.js +2 -0
- package/__mf/js/async/6384.242bb332.js +52 -0
- package/__mf/js/async/6609.7dd273f8.js +88 -0
- package/__mf/js/async/6625.2e9582af.js +1 -0
- package/__mf/js/async/7151.0e3196f4.js +1 -0
- package/__mf/js/async/7192.a261b528.js +1 -0
- package/__mf/js/async/7319.93d10923.js +1 -0
- package/__mf/js/async/7384.58d4a98c.js +1 -0
- package/__mf/js/async/7633.cabd9f90.js +2 -0
- package/__mf/js/async/7955.9a126c8e.js +1 -0
- package/__mf/js/async/7968.c90bbd91.js +1 -0
- package/__mf/js/async/7978.e29a754e.js +1 -0
- package/__mf/js/async/8356.c463987c.js +1 -0
- package/__mf/js/async/836.fbf1cee0.js +1 -0
- package/__mf/js/async/8465.cf3d9a6f.js +1 -0
- package/__mf/js/async/8470.343715da.js +2 -0
- package/__mf/js/async/873.050d950b.js +1 -0
- package/__mf/js/async/9235.b6aec078.js +1 -0
- package/__mf/js/async/941.1fbc4dad.js +2 -0
- package/__mf/js/async/9588.32fa0c1e.js +1 -0
- package/__mf/js/async/9700.4a715883.js +1 -0
- package/__mf/js/async/__federation_expose_TimeSeriesChart.0445a802.js +1 -0
- package/__mf/js/async/lib-router.ecd66a8d.js +2 -0
- package/__mf/js/{main.7434d87e.js → main.3ed11ab8.js} +7 -7
- package/lib/QuerySettingsEditor.d.ts.map +1 -1
- package/lib/QuerySettingsEditor.js +5 -8
- package/lib/QuerySettingsEditor.js.map +1 -1
- package/lib/TimeSeriesChartBase.d.ts.map +1 -1
- package/lib/TimeSeriesChartBase.js +37 -33
- package/lib/TimeSeriesChartBase.js.map +1 -1
- package/lib/TimeSeriesChartPanel.d.ts.map +1 -1
- package/lib/TimeSeriesChartPanel.js +7 -7
- package/lib/TimeSeriesChartPanel.js.map +1 -1
- package/lib/VisualOptionsEditor.d.ts.map +1 -1
- package/lib/VisualOptionsEditor.js +8 -0
- package/lib/VisualOptionsEditor.js.map +1 -1
- package/lib/annotations/AnnotationTooltip.d.ts +3 -2
- package/lib/annotations/AnnotationTooltip.d.ts.map +1 -1
- package/lib/annotations/AnnotationTooltip.js +14 -2
- package/lib/annotations/AnnotationTooltip.js.map +1 -1
- package/lib/components/ColorSwatches.d.ts +5 -0
- package/lib/components/ColorSwatches.d.ts.map +1 -0
- package/lib/components/ColorSwatches.js +35 -0
- package/lib/components/ColorSwatches.js.map +1 -0
- package/lib/components/PaletteSelector.d.ts +8 -0
- package/lib/components/PaletteSelector.d.ts.map +1 -0
- package/lib/components/PaletteSelector.js +93 -0
- package/lib/components/PaletteSelector.js.map +1 -0
- package/lib/time-series-chart-model.d.ts +25 -3
- package/lib/time-series-chart-model.d.ts.map +1 -1
- package/lib/time-series-chart-model.js +34 -0
- package/lib/time-series-chart-model.js.map +1 -1
- package/lib/utils/data-transform.d.ts.map +1 -1
- package/lib/utils/data-transform.js +0 -1
- package/lib/utils/data-transform.js.map +1 -1
- package/lib/utils/palette-gen.d.ts +2 -2
- package/lib/utils/palette-gen.d.ts.map +1 -1
- package/lib/utils/palette-gen.js +12 -8
- package/lib/utils/palette-gen.js.map +1 -1
- package/mf-manifest.json +44 -44
- package/mf-stats.json +44 -44
- package/package.json +10 -6
- package/__mf/js/async/1616.2ad408f8.js +0 -1
- package/__mf/js/async/2490.7e5650e7.js +0 -2
- package/__mf/js/async/3068.c95fecc7.js +0 -88
- package/__mf/js/async/3441.65e1728a.js +0 -52
- package/__mf/js/async/392.11188127.js +0 -2
- package/__mf/js/async/4077.cf1d675f.js +0 -1
- package/__mf/js/async/4121.2a21582b.js +0 -2
- package/__mf/js/async/4496.eb53e477.js +0 -1
- package/__mf/js/async/4670.b5dafbaa.js +0 -2
- package/__mf/js/async/5002.e3ab6daa.js +0 -1
- package/__mf/js/async/5071.586de8fa.js +0 -1
- package/__mf/js/async/5394.f1c40599.js +0 -7
- package/__mf/js/async/5587.bfa64ec3.js +0 -1
- package/__mf/js/async/6274.c6a9892d.js +0 -2
- package/__mf/js/async/6625.e3624f20.js +0 -1
- package/__mf/js/async/7151.f8879976.js +0 -1
- package/__mf/js/async/7192.f5f93b5e.js +0 -1
- package/__mf/js/async/7319.3e3c9686.js +0 -1
- package/__mf/js/async/7384.4be917ee.js +0 -1
- package/__mf/js/async/7633.9cb6de7a.js +0 -2
- package/__mf/js/async/7955.877daa4d.js +0 -1
- package/__mf/js/async/7968.cf8a4d6a.js +0 -1
- package/__mf/js/async/7978.67c99e22.js +0 -1
- package/__mf/js/async/8356.b7f7e7f3.js +0 -1
- package/__mf/js/async/8465.56096f79.js +0 -1
- package/__mf/js/async/8470.f137ffe2.js +0 -2
- package/__mf/js/async/8724.0d169bb2.js +0 -1
- package/__mf/js/async/873.b41b449a.js +0 -1
- package/__mf/js/async/9235.4831e488.js +0 -1
- package/__mf/js/async/941.76f11ced.js +0 -2
- package/__mf/js/async/9588.883e3395.js +0 -1
- package/__mf/js/async/9700.628e2532.js +0 -1
- package/__mf/js/async/__federation_expose_TimeSeriesChart.40d2d053.js +0 -1
- package/__mf/js/async/lib-router.4f5ed027.js +0 -2
- /package/__mf/css/async/{5394.85c2cbf6.css → 1409.85c2cbf6.css} +0 -0
- /package/__mf/js/async/{5394.f1c40599.js.LICENSE.txt → 1409.855b83fb.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{2490.7e5650e7.js.LICENSE.txt → 2490.8d139ea3.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{392.11188127.js.LICENSE.txt → 392.c9cdaa1e.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{4121.2a21582b.js.LICENSE.txt → 4121.5ad4a1ae.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{5182.375bbf8e.js.LICENSE.txt → 5182.b8a5b924.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{6274.c6a9892d.js.LICENSE.txt → 6274.c3436b0e.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{3068.c95fecc7.js.LICENSE.txt → 6609.7dd273f8.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{7633.9cb6de7a.js.LICENSE.txt → 7633.cabd9f90.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{8470.f137ffe2.js.LICENSE.txt → 8470.343715da.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{941.76f11ced.js.LICENSE.txt → 941.1fbc4dad.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{lib-router.4f5ed027.js.LICENSE.txt → lib-router.ecd66a8d.js.LICENSE.txt} +0 -0
|
@@ -12,11 +12,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
import { Box, useTheme } from "@mui/material";
|
|
15
|
-
import { YAxisLabel, useChartsTheme, ContentWithLegend,
|
|
15
|
+
import { YAxisLabel, useChartsTheme, ContentWithLegend, DEFAULT_TOOLTIP_CONFIG, getFormattedMultipleYAxes, DEFAULT_LEGEND, formatValue, getTimeSeriesValues } from "@perses-dev/components";
|
|
16
16
|
import { usePanelAnnotationsWithData } from "@perses-dev/dashboards";
|
|
17
17
|
import { LEGEND_VALUE_CONFIG, useTimeRange, validateLegendSpec, legendValues, getCalculations } from "@perses-dev/plugin-system";
|
|
18
18
|
import merge from "lodash/merge";
|
|
19
|
-
import { memo, useCallback, useMemo, useRef, useState } from "react";
|
|
19
|
+
import { memo, useCallback, useId, useMemo, useRef, useState } from "react";
|
|
20
20
|
import { DEFAULT_FORMAT, DEFAULT_VISUAL, THRESHOLD_PLOT_INTERVAL } from "./time-series-chart-model.js";
|
|
21
21
|
import { TimeSeriesChartBase } from "./TimeSeriesChartBase.js";
|
|
22
22
|
import { convertAnnotationToTimeSeriesAnnotation } from "./utils/annotation.js";
|
|
@@ -43,7 +43,7 @@ function TimeSeriesChartPanelComponent(props) {
|
|
|
43
43
|
const { spec: { thresholds, yAxis, tooltip, querySettings: querySettingsList }, contentDimensions, queryResults } = props;
|
|
44
44
|
const chartsTheme = useChartsTheme();
|
|
45
45
|
const muiTheme = useTheme();
|
|
46
|
-
const chartId = useId(
|
|
46
|
+
const chartId = useId();
|
|
47
47
|
const chartRef = useRef(null);
|
|
48
48
|
// ECharts theme comes from ChartsProvider, more info: https://echarts.apache.org/en/option.html#color
|
|
49
49
|
// Colors are manually applied since our legend and tooltip are built custom with React.
|
|
@@ -179,7 +179,7 @@ function TimeSeriesChartPanelComponent(props) {
|
|
|
179
179
|
seriesId,
|
|
180
180
|
seriesName,
|
|
181
181
|
color: getSeriesColor({
|
|
182
|
-
|
|
182
|
+
defaultCategoricalPalette: categoricalPalette,
|
|
183
183
|
visual,
|
|
184
184
|
muiPrimaryColor: muiTheme.palette.primary.main,
|
|
185
185
|
seriesName,
|
|
@@ -193,7 +193,7 @@ function TimeSeriesChartPanelComponent(props) {
|
|
|
193
193
|
exemplars: []
|
|
194
194
|
});
|
|
195
195
|
}
|
|
196
|
-
seriesIndex
|
|
196
|
+
seriesIndex += 1;
|
|
197
197
|
}
|
|
198
198
|
for (const group of exemplars ?? []){
|
|
199
199
|
if (group.exemplars.length === 0) continue;
|
|
@@ -246,7 +246,7 @@ function TimeSeriesChartPanelComponent(props) {
|
|
|
246
246
|
// Color is used for line, tooltip, and legend
|
|
247
247
|
const seriesColor = getSeriesColor({
|
|
248
248
|
// ECharts type for color is not always an array but it is always an array in ChartsProvider
|
|
249
|
-
|
|
249
|
+
defaultCategoricalPalette: categoricalPalette,
|
|
250
250
|
visual,
|
|
251
251
|
muiPrimaryColor: muiTheme.palette.primary.main,
|
|
252
252
|
seriesName: formattedSeriesName,
|
|
@@ -331,7 +331,7 @@ function TimeSeriesChartPanelComponent(props) {
|
|
|
331
331
|
values: thresholdTimeValueTuple
|
|
332
332
|
});
|
|
333
333
|
timeSeriesMapping.push(getThresholdSeries(thresholdName, stepOption, seriesIndex));
|
|
334
|
-
seriesIndex
|
|
334
|
+
seriesIndex += 1;
|
|
335
335
|
});
|
|
336
336
|
}
|
|
337
337
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/TimeSeriesChartPanel.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 { Box, useTheme } from '@mui/material';\nimport type {\n ChartInstance,\n ZoomEventData,\n SelectedLegendItemState,\n TableColumnConfig,\n LegendItem,\n LegendProps,\n TooltipConfig,\n TimeChartSeriesMapping,\n StepOptions,\n} from '@perses-dev/components';\nimport {\n YAxisLabel,\n useChartsTheme,\n ContentWithLegend,\n useId,\n DEFAULT_TOOLTIP_CONFIG,\n getFormattedMultipleYAxes,\n DEFAULT_LEGEND,\n formatValue,\n getTimeSeriesValues,\n} from '@perses-dev/components';\nimport { usePanelAnnotationsWithData } from '@perses-dev/dashboards';\nimport type { PanelProps, CalculationType } from '@perses-dev/plugin-system';\nimport {\n LEGEND_VALUE_CONFIG,\n useTimeRange,\n validateLegendSpec,\n legendValues,\n getCalculations,\n} from '@perses-dev/plugin-system';\nimport type { Labels, TimeSeries, TimeSeriesData, TimeSeriesValueTuple } from '@perses-dev/spec';\nimport type { GridComponentOption } from 'echarts';\nimport merge from 'lodash/merge';\nimport type { ReactElement } from 'react';\nimport { memo, useCallback, useMemo, useRef, useState } from 'react';\n\nimport type { TimeSeriesChartOptions } from './time-series-chart-model';\nimport { DEFAULT_FORMAT, DEFAULT_VISUAL, THRESHOLD_PLOT_INTERVAL } from './time-series-chart-model';\nimport { TimeSeriesChartBase } from './TimeSeriesChartBase';\nimport type { TimeSeriesAnnotation } from './utils/annotation';\nimport { convertAnnotationToTimeSeriesAnnotation } from './utils/annotation';\nimport type { ExemplarChartData } from './utils/data-transform';\nimport {\n getTimeSeries,\n getCommonTimeScaleForQueries,\n convertPanelYAxis,\n getThresholdSeries,\n convertPercentThreshold,\n} from './utils/data-transform';\nimport { getSeriesColor } from './utils/palette-gen';\n\nexport type TimeSeriesChartProps = PanelProps<TimeSeriesChartOptions, TimeSeriesData>;\n\n/**\n * Stable string key for a labels record, so exemplars can be matched to their\n * series regardless of the labels order.\n */\nfunction labelsKey(labels: Labels): string {\n return JSON.stringify(\n Object.keys(labels)\n .toSorted()\n .map((labelName) => [labelName, labels[labelName]]),\n );\n}\n\n// Using an \"ALL\" value to handle the case on first loading the chart where we\n// want to select all, but do not want all of the legend items to be visually highlighted.\n// This helps us differentiate those cases more clearly instead of inferring it\n// based on the state of the data. This also helps us avoid some coding\n// complexity around initializing a full record for the initial load that would\n// currently require significantly more refactoring of this component.\n// TODO: simplify this if we switch the list-based legend UI to use checkboxes,\n// where we *would* want to visually select all items in this case.\n\nfunction TimeSeriesChartPanelComponent(props: TimeSeriesChartProps): ReactElement | null {\n const {\n spec: { thresholds, yAxis, tooltip, querySettings: querySettingsList },\n contentDimensions,\n queryResults,\n } = props;\n const chartsTheme = useChartsTheme();\n const muiTheme = useTheme();\n const chartId = useId('time-series-panel');\n\n const chartRef = useRef<ChartInstance>(null);\n\n // ECharts theme comes from ChartsProvider, more info: https://echarts.apache.org/en/option.html#color\n // Colors are manually applied since our legend and tooltip are built custom with React.\n const categoricalPalette = chartsTheme.echartsTheme.color;\n\n // TODO: consider refactoring how the layout/spacing/alignment are calculated\n // the next time significant changes are made to the time series panel (e.g.\n // when making improvements to the legend to more closely match designs).\n // This may also want to include moving some of this logic down to the shared,\n // embeddable components.\n const contentPadding = chartsTheme.container.padding.default;\n const adjustedContentDimensions: typeof contentDimensions = contentDimensions\n ? {\n width: contentDimensions.width - contentPadding * 2,\n height: contentDimensions.height - contentPadding * 2,\n }\n : undefined;\n\n // populate default 'position' and other future properties\n const legend = useMemo(() => {\n return props.spec.legend && validateLegendSpec(props.spec.legend)\n ? merge({}, DEFAULT_LEGEND, props.spec.legend)\n : undefined;\n }, [props.spec.legend]);\n\n // TODO: add support for y_axis_alt.format\n const format = props.spec.yAxis?.format ?? DEFAULT_FORMAT;\n\n // ensures there are fallbacks for unset properties since most\n // users should not need to customize visual display\n const visual = useMemo(() => {\n return merge({}, DEFAULT_VISUAL, props.spec.visual);\n }, [props.spec.visual]);\n\n // convert Perses dashboard format to be ECharts compatible\n const echartsYAxis = useMemo(() => {\n return convertPanelYAxis(yAxis);\n }, [yAxis]);\n\n // Collect unique formats from query settings that differ from the base format\n // These will create additional Y axes on the right side\n const { additionalFormats, formatToYAxisIndex } = useMemo(() => {\n const baseUnit = format?.unit ?? 'decimal';\n const additionalFormats: Array<typeof format> = [];\n const formatToYAxisIndex = new Map<string, number>();\n\n // Index 0 is reserved for the base Y axis\n formatToYAxisIndex.set(baseUnit, 0);\n\n // Collect unique formats from query settings\n for (const qs of querySettingsList ?? []) {\n if (qs.format?.unit && qs.format.unit !== baseUnit) {\n const unitKey = qs.format.unit;\n if (!formatToYAxisIndex.has(unitKey)) {\n // Add new format - index is 1 + position in additionalFormats array\n formatToYAxisIndex.set(unitKey, 1 + additionalFormats.length);\n additionalFormats.push(qs.format);\n }\n }\n }\n\n return { additionalFormats, formatToYAxisIndex };\n }, [format, querySettingsList]);\n\n const [selectedLegendItems, setSelectedLegendItems] = useState<SelectedLegendItemState>('ALL');\n const [legendSorting, setLegendSorting] = useState<NonNullable<LegendProps['tableProps']>['sorting']>();\n\n const { setTimeRange } = useTimeRange();\n\n const annotationsWithData = usePanelAnnotationsWithData(props.definition?.spec.annotations);\n\n const annotations: TimeSeriesAnnotation[] = useMemo(\n () => convertAnnotationToTimeSeriesAnnotation(annotationsWithData),\n [annotationsWithData],\n );\n\n const calculationTypes = legend?.values;\n\n // Point processing and legend statistics depend on query data, not legend selection.\n // Reuse these arrays when toggling series instead of rescanning every sample.\n const { timeScale, preparedQueries } = useMemo(() => {\n const commonScale = getCommonTimeScaleForQueries(queryResults);\n const settingsByQuery = new Map(querySettingsList?.map((settings) => [settings.queryIndex, settings]));\n let seriesIndex = 0;\n const queries = commonScale\n ? queryResults.map((result, queryIndex) => {\n const querySettings = settingsByQuery.get(queryIndex);\n const series = result.data.series.map((timeSeries) => {\n const baseValues = getTimeSeriesValues(timeSeries, commonScale);\n const values = querySettings?.negativeY\n ? baseValues.map(([t, v]): TimeSeriesValueTuple => [t, v === null ? null : -v])\n : baseValues;\n const calculations = calculationTypes\n ? getCalculations(timeSeries.values, calculationTypes as CalculationType[])\n : undefined;\n let maxValue = 0;\n if (querySettings?.format?.unit) {\n for (const [, value] of timeSeries.values) {\n maxValue = Math.max(maxValue, Math.abs(value ?? 0));\n }\n }\n const seriesId = `${chartId}${timeSeries.name}${seriesIndex}`;\n seriesIndex += 1;\n return { timeSeries, seriesId, values, calculations, maxValue };\n });\n return { querySettings, series, exemplars: result.data.exemplars };\n })\n : [];\n return { timeScale: commonScale, preparedQueries: queries };\n }, [queryResults, querySettingsList, calculationTypes, chartId]);\n\n // Prepare all exemplar groups independently of legend selection. The base chart\n // filters their scatter series without rebuilding marker data for visible groups.\n const chartExemplars = useMemo(() => {\n const groups: ExemplarChartData[] = [];\n let seriesIndex = 0;\n for (const { querySettings, series, exemplars } of preparedQueries) {\n // Labels identify a series within a query, not across different queries.\n const seriesByLabels = new Map<string, ExemplarChartData>();\n for (const { timeSeries, seriesId } of series) {\n const seriesName = timeSeries.formattedName ?? timeSeries.name;\n if (exemplars?.length && timeSeries.labels) {\n seriesByLabels.set(labelsKey(timeSeries.labels), {\n seriesId,\n seriesName,\n color: getSeriesColor({\n categoricalPalette: categoricalPalette as string[],\n visual,\n muiPrimaryColor: muiTheme.palette.primary.main,\n seriesName,\n seriesIndex,\n querySettings,\n queryHasMultipleResults: series.length > 1,\n }),\n seriesLabels: timeSeries.labels,\n yAxisIndex: formatToYAxisIndex.get(querySettings?.format?.unit ?? '') ?? 0,\n negativeY: querySettings?.negativeY,\n exemplars: [],\n });\n }\n seriesIndex++;\n }\n for (const group of exemplars ?? []) {\n if (group.exemplars.length === 0) continue;\n const matched = seriesByLabels.get(labelsKey(group.seriesLabels));\n if (matched) groups.push({ ...matched, exemplars: group.exemplars });\n }\n }\n return groups;\n }, [preparedQueries, categoricalPalette, visual, muiTheme.palette.primary.main, formatToYAxisIndex]);\n\n // Populate series data based on query results\n const {\n timeChartData,\n timeSeriesMapping,\n legendItems,\n seriesFormatMap: computedSeriesFormatMap,\n maxValuesByFormat,\n } = useMemo(() => {\n if (timeScale === undefined) {\n return {\n timeChartData: [] as TimeSeries[],\n timeSeriesMapping: [] as TimeChartSeriesMapping,\n legendItems: [] as LegendItem[],\n seriesFormatMap: new Map(),\n maxValuesByFormat: new Map<string, number>(),\n };\n }\n\n const legendItems: LegendItem[] = [];\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 timeChartData: TimeSeries[] = [];\n const timeSeriesMapping: TimeChartSeriesMapping = [];\n\n // Track max values for each format unit (used for dynamic Y axis offset calculation)\n const maxValuesByFormat = new Map<string, number>();\n const seriesFormatMap = new Map<string, typeof format>();\n\n let visibleSeriesCount = 0;\n for (const { series } of preparedQueries) {\n for (const { seriesId } of series) {\n if (selectedLegendItems === 'ALL' || selectedLegendItems[seriesId]) visibleSeriesCount++;\n }\n }\n\n // Index is counted across multiple queries which ensures the categorical color palette does not reset for every query\n let seriesIndex = 0;\n\n for (const { querySettings, series } of preparedQueries) {\n for (const { timeSeries, seriesId, values, calculations, maxValue } of series) {\n // Format is determined by seriesNameFormat in query spec\n const formattedSeriesName = timeSeries.formattedName ?? timeSeries.name;\n\n // Color is used for line, tooltip, and legend\n const seriesColor = getSeriesColor({\n // ECharts type for color is not always an array but it is always an array in ChartsProvider\n categoricalPalette: categoricalPalette as string[],\n visual,\n muiPrimaryColor: muiTheme.palette.primary.main,\n seriesName: formattedSeriesName,\n seriesIndex,\n querySettings: querySettings,\n queryHasMultipleResults: series.length > 1,\n });\n\n // When we initially load the chart, we want to show all series, but\n // DO NOT want to visualy highlight all the items in the legend.\n const isSelectAll = selectedLegendItems === 'ALL';\n const isSelected = !isSelectAll && !!selectedLegendItems[seriesId];\n const showTimeSeries = isSelected || isSelectAll;\n\n if (showTimeSeries) {\n // Use timeChartData.length to ensure the data that is passed into the tooltip accounts for\n // which legend items are selected. This must happen before timeChartData.push to avoid an\n // off-by-one error, seriesIndex cannot be used since it's needed to cycle through palette\n const datasetIndex = timeChartData.length;\n\n // Determine yAxisIndex based on the query's format setting\n const queryFormat = querySettings?.format;\n const yAxisIndex = queryFormat?.unit ? (formatToYAxisIndex.get(queryFormat.unit) ?? 0) : 0;\n\n // Each series is stored as a separate dataset source.\n // https://apache.github.io/echarts-handbook/en/concepts/dataset/#how-to-reference-several-datasets\n timeSeriesMapping.push(\n getTimeSeries(\n seriesId,\n datasetIndex,\n formattedSeriesName,\n visual,\n timeScale,\n seriesColor,\n querySettings,\n yAxisIndex,\n visibleSeriesCount,\n ),\n );\n\n // Store the format for this series for tooltip formatting\n if (queryFormat) {\n seriesFormatMap.set(seriesId, queryFormat);\n\n // Track max value for this format unit (used for dynamic Y axis offset calculation)\n const unitKey = queryFormat.unit;\n if (unitKey) {\n const currentMax = maxValuesByFormat.get(unitKey) ?? 0;\n if (maxValue > currentMax) {\n maxValuesByFormat.set(unitKey, maxValue);\n }\n }\n }\n\n timeChartData.push({\n name: formattedSeriesName,\n values,\n });\n }\n\n if (legend && legendItems) {\n legendItems.push({\n id: seriesId, // Avoids duplicate key console errors when there are duplicate series names\n label: formattedSeriesName,\n color: seriesColor,\n data: calculations,\n });\n }\n\n // Used for repeating colors in Categorical palette\n seriesIndex += 1;\n }\n }\n\n // map thresholds only if there is at least one time series to avoid displaying thresholds without any data\n if (thresholds && thresholds.steps && timeChartData.length > 0) {\n // Convert how thresholds are defined in the panel spec to valid ECharts 'line' series.\n // These are styled with predefined colors and a dashed style to look different than series from query results.\n // Regular series are used instead of markLines since thresholds currently show in our React TimeSeriesTooltip.\n const thresholdsColors = chartsTheme.thresholds;\n const defaultThresholdColor = thresholds.defaultColor ?? thresholdsColors.defaultColor;\n thresholds.steps.forEach((step: StepOptions, index: number) => {\n const stepPaletteColor = thresholdsColors.palette[index] ?? defaultThresholdColor;\n const thresholdLineColor = step.color ?? stepPaletteColor;\n const stepOption: StepOptions = {\n color: thresholdLineColor,\n value:\n // yAxis is passed here since it corresponds to dashboard JSON instead of the already converted ECharts yAxis\n thresholds.mode === 'percent'\n ? convertPercentThreshold(step.value, timeChartData, yAxis?.max, yAxis?.min)\n : step.value,\n };\n const thresholdName = step.name ?? `Threshold ${index + 1}`;\n\n // Generates array of [time, step.value] where time ranges from timescale.startMs to timescale.endMs with an interval of 15s\n const thresholdTimeValueTuple: TimeSeriesValueTuple[] = [];\n let currentTimestamp = timeScale.startMs;\n while (currentTimestamp <= timeScale.endMs) {\n thresholdTimeValueTuple.push([currentTimestamp, stepOption.value]);\n // Used to plot fake thresholds datapoints so correct nearby threshold series shows in tooltip without flicker\n currentTimestamp += 1000 * THRESHOLD_PLOT_INTERVAL;\n }\n\n timeChartData.push({\n name: thresholdName,\n values: thresholdTimeValueTuple,\n });\n timeSeriesMapping.push(getThresholdSeries(thresholdName, stepOption, seriesIndex));\n seriesIndex++;\n });\n }\n\n return {\n timeScale,\n timeChartData,\n timeSeriesMapping,\n legendItems,\n seriesFormatMap,\n maxValuesByFormat,\n };\n }, [\n preparedQueries,\n timeScale,\n thresholds,\n selectedLegendItems,\n legend,\n visual,\n yAxis?.max,\n yAxis?.min,\n categoricalPalette,\n chartsTheme.thresholds,\n muiTheme.palette.primary.main,\n formatToYAxisIndex,\n ]);\n\n // Create multiple Y axes if there are additional formats\n // Uses max values from data to compute dynamic offsets that adapt to label widths\n const multipleYAxes = useMemo(() => {\n if (additionalFormats.length === 0) {\n return undefined; // Use single Y axis (default behavior)\n }\n // Build array of max values for each additional format (in order)\n const maxValues = additionalFormats.map((fmt) => {\n const unitKey = fmt.unit;\n return unitKey ? (maxValuesByFormat?.get(unitKey) ?? 1000) : 1000;\n });\n return getFormattedMultipleYAxes(echartsYAxis, format, additionalFormats, maxValues);\n }, [echartsYAxis, format, additionalFormats, maxValuesByFormat]);\n\n // Translate the legend values into columns for the table legend.\n const legendColumns = useMemo(() => {\n if (!legend?.values) {\n return [];\n }\n\n // Iterating the predefined list of possible values to retain a specific\n // intended order of values.\n return legendValues.reduce(\n (columns, legendValue) => {\n const legendConfig = LEGEND_VALUE_CONFIG[legendValue];\n\n if (legendConfig && legend?.values?.includes(legendValue)) {\n columns.push({\n accessorKey: `data.${legendValue}`,\n header: legendConfig.label,\n headerDescription: legendConfig.description,\n // Intentionally hardcoding a column width to start based on discussions\n // with design around keeping this simple to start. This may need\n // revisiting in the future to handle edge cases with very large values.\n width: 72,\n align: 'right',\n cell: ({ getValue }) => {\n const cellValue = getValue();\n return typeof cellValue === 'number' && format ? formatValue(cellValue, format) : cellValue;\n },\n cellDescription: true,\n enableSorting: true,\n });\n }\n\n return columns;\n },\n [] as Array<TableColumnConfig<LegendItem>>,\n );\n }, [legend?.values, format]);\n\n const gridOverrides: GridComponentOption = useMemo(() => {\n // When Y axes are hidden, disable containLabel to prevent auto-spacing, but add bottom padding for X axis\n return echartsYAxis.show === false\n ? {\n left: 0,\n right: 0,\n bottom: 30,\n containLabel: false,\n }\n : {\n left: yAxis && yAxis.label ? 30 : 20,\n // With containLabel: true in theme, ECharts auto-reserves space for axis labels.\n // For multiple right axes, add extra padding for the last axis labels that extend beyond the grid.\n right: additionalFormats.length > 0 ? 10 : 20,\n bottom: 0,\n containLabel: true,\n };\n }, [echartsYAxis.show, yAxis, additionalFormats.length]);\n\n const handleDataZoom = useCallback(\n (event: ZoomEventData): void => {\n setTimeRange({ start: new Date(event.start), end: new Date(event.end) });\n },\n [setTimeRange],\n );\n\n if (adjustedContentDimensions === undefined) {\n return null;\n }\n\n // Used to opt in to ECharts trigger item which show subgroup data accurately.\n // Derived from the actual series mapping rather than `visual.stack` alone so that\n // bar charts stacked only via per-query overrides also use the right tooltip mode.\n const isStackedBar =\n visual.display === 'bar' && timeSeriesMapping.some((s) => s?.type === 'bar' && s.stack === 'all');\n\n // Turn on tooltip pinning by default but opt out for stacked bar or if explicitly set in tooltip panel spec\n let enablePinning = true;\n if (isStackedBar) {\n enablePinning = false;\n } else if (tooltip?.enablePinning !== undefined) {\n enablePinning = tooltip.enablePinning;\n }\n const tooltipConfig: TooltipConfig = {\n ...DEFAULT_TOOLTIP_CONFIG,\n enablePinning,\n };\n\n return (\n <Box sx={{ padding: `${contentPadding}px` }}>\n <ContentWithLegend\n width={adjustedContentDimensions.width}\n height={adjustedContentDimensions.height}\n // Making this small enough that the medium size doesn't get\n // responsive-handling-ed away when in the panel options editor.\n minChildrenHeight={50}\n legendSize={legend?.size}\n legendProps={\n legend && {\n options: legend,\n data: legendItems || [],\n selectedItems: selectedLegendItems,\n onSelectedItemsChange: setSelectedLegendItems,\n tableProps: {\n columns: legendColumns,\n sorting: legendSorting,\n onSortingChange: setLegendSorting,\n },\n onItemMouseOver: (e, { id }): void => {\n chartRef.current?.highlightSeries({ name: id });\n },\n onItemMouseOut: (): void => {\n chartRef.current?.clearHighlightedSeries();\n },\n }\n }\n >\n {({ height, width }) => {\n return (\n <Box style={{ height, width }}>\n {yAxis && yAxis.show && yAxis.label && <YAxisLabel name={yAxis.label} height={height} />}\n <TimeSeriesChartBase\n ref={chartRef}\n height={height}\n data={timeChartData}\n seriesMapping={timeSeriesMapping}\n exemplars={chartExemplars}\n annotations={annotations}\n timeScale={timeScale}\n yAxis={multipleYAxes ?? echartsYAxis}\n format={format}\n seriesFormatMap={computedSeriesFormatMap}\n grid={gridOverrides}\n isStackedBar={isStackedBar}\n tooltipConfig={tooltipConfig}\n syncGroup=\"default-panel-group\" // TODO: make configurable from dashboard settings and per panel-group overrides\n onDataZoom={handleDataZoom}\n // Show an empty chart when there is no data because the user unselected all items in\n // the legend. Otherwise, show a \"no data\" message.\n noDataVariant={!timeChartData.length && legendItems && legendItems.length > 0 ? 'chart' : 'message'}\n />\n </Box>\n );\n }}\n </ContentWithLegend>\n </Box>\n );\n}\n\n// PanelContent recreates the queryResults array and its wrappers on dashboard\n// hover/focus updates. Compare the underlying references in query order so those\n// updates do not invalidate data preparation or scan the samples and exemplars.\nexport const TimeSeriesChartPanel = memo(\n TimeSeriesChartPanelComponent,\n (previous, next): boolean =>\n previous.spec === next.spec &&\n previous.definition === next.definition &&\n previous.contentDimensions?.width === next.contentDimensions?.width &&\n previous.contentDimensions?.height === next.contentDimensions?.height &&\n previous.queryResults.length === next.queryResults.length &&\n previous.queryResults.every(\n (query, index) =>\n query.data === next.queryResults[index]?.data && query.definition === next.queryResults[index]?.definition,\n ),\n);\n"],"names":["Box","useTheme","YAxisLabel","useChartsTheme","ContentWithLegend","useId","DEFAULT_TOOLTIP_CONFIG","getFormattedMultipleYAxes","DEFAULT_LEGEND","formatValue","getTimeSeriesValues","usePanelAnnotationsWithData","LEGEND_VALUE_CONFIG","useTimeRange","validateLegendSpec","legendValues","getCalculations","merge","memo","useCallback","useMemo","useRef","useState","DEFAULT_FORMAT","DEFAULT_VISUAL","THRESHOLD_PLOT_INTERVAL","TimeSeriesChartBase","convertAnnotationToTimeSeriesAnnotation","getTimeSeries","getCommonTimeScaleForQueries","convertPanelYAxis","getThresholdSeries","convertPercentThreshold","getSeriesColor","labelsKey","labels","JSON","stringify","Object","keys","toSorted","map","labelName","TimeSeriesChartPanelComponent","props","spec","thresholds","yAxis","tooltip","querySettings","querySettingsList","contentDimensions","queryResults","chartsTheme","muiTheme","chartId","chartRef","categoricalPalette","echartsTheme","color","contentPadding","container","padding","default","adjustedContentDimensions","width","height","undefined","legend","format","visual","echartsYAxis","additionalFormats","formatToYAxisIndex","baseUnit","unit","Map","set","qs","unitKey","has","length","push","selectedLegendItems","setSelectedLegendItems","legendSorting","setLegendSorting","setTimeRange","annotationsWithData","definition","annotations","calculationTypes","values","timeScale","preparedQueries","commonScale","settingsByQuery","settings","queryIndex","seriesIndex","queries","result","get","series","data","timeSeries","baseValues","negativeY","t","v","calculations","maxValue","value","Math","max","abs","seriesId","name","exemplars","chartExemplars","groups","seriesByLabels","seriesName","formattedName","muiPrimaryColor","palette","primary","main","queryHasMultipleResults","seriesLabels","yAxisIndex","group","matched","timeChartData","timeSeriesMapping","legendItems","seriesFormatMap","computedSeriesFormatMap","maxValuesByFormat","visibleSeriesCount","formattedSeriesName","seriesColor","isSelectAll","isSelected","showTimeSeries","datasetIndex","queryFormat","currentMax","id","label","steps","thresholdsColors","defaultThresholdColor","defaultColor","forEach","step","index","stepPaletteColor","thresholdLineColor","stepOption","mode","min","thresholdName","thresholdTimeValueTuple","currentTimestamp","startMs","endMs","multipleYAxes","maxValues","fmt","legendColumns","reduce","columns","legendValue","legendConfig","includes","accessorKey","header","headerDescription","description","align","cell","getValue","cellValue","cellDescription","enableSorting","gridOverrides","show","left","right","bottom","containLabel","handleDataZoom","event","start","Date","end","isStackedBar","display","some","s","type","stack","enablePinning","tooltipConfig","sx","minChildrenHeight","legendSize","size","legendProps","options","selectedItems","onSelectedItemsChange","tableProps","sorting","onSortingChange","onItemMouseOver","e","current","highlightSeries","onItemMouseOut","clearHighlightedSeries","style","ref","seriesMapping","grid","syncGroup","onDataZoom","noDataVariant","TimeSeriesChartPanel","previous","next","every","query"],"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,GAAG,EAAEC,QAAQ,QAAQ,gBAAgB;AAY9C,SACEC,UAAU,EACVC,cAAc,EACdC,iBAAiB,EACjBC,KAAK,EACLC,sBAAsB,EACtBC,yBAAyB,EACzBC,cAAc,EACdC,WAAW,EACXC,mBAAmB,QACd,yBAAyB;AAChC,SAASC,2BAA2B,QAAQ,yBAAyB;AAErE,SACEC,mBAAmB,EACnBC,YAAY,EACZC,kBAAkB,EAClBC,YAAY,EACZC,eAAe,QACV,4BAA4B;AAGnC,OAAOC,WAAW,eAAe;AAEjC,SAASC,IAAI,EAAEC,WAAW,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAGrE,SAASC,cAAc,EAAEC,cAAc,EAAEC,uBAAuB,QAAQ,+BAA4B;AACpG,SAASC,mBAAmB,QAAQ,2BAAwB;AAE5D,SAASC,uCAAuC,QAAQ,wBAAqB;AAE7E,SACEC,aAAa,EACbC,4BAA4B,EAC5BC,iBAAiB,EACjBC,kBAAkB,EAClBC,uBAAuB,QAClB,4BAAyB;AAChC,SAASC,cAAc,QAAQ,yBAAsB;AAIrD;;;CAGC,GACD,SAASC,UAAUC,MAAc;IAC/B,OAAOC,KAAKC,SAA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DqJ,SAASlL,YAAY,CAACoL,KAAK,CACzB,CAACC,OAAO7E,QACN6E,MAAMjI,IAAI,KAAK+H,KAAKnL,YAAY,CAACwG,MAAM,EAAEpD,QAAQiI,MAAMhJ,UAAU,KAAK8I,KAAKnL,YAAY,CAACwG,MAAM,EAAEnE,aAEtG"}
|
|
1
|
+
{"version":3,"sources":["../../src/TimeSeriesChartPanel.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 { Box, useTheme } from '@mui/material';\nimport type {\n ChartInstance,\n ZoomEventData,\n SelectedLegendItemState,\n TableColumnConfig,\n LegendItem,\n LegendProps,\n TooltipConfig,\n TimeChartSeriesMapping,\n StepOptions,\n} from '@perses-dev/components';\nimport {\n YAxisLabel,\n useChartsTheme,\n ContentWithLegend,\n DEFAULT_TOOLTIP_CONFIG,\n getFormattedMultipleYAxes,\n DEFAULT_LEGEND,\n formatValue,\n getTimeSeriesValues,\n} from '@perses-dev/components';\nimport { usePanelAnnotationsWithData } from '@perses-dev/dashboards';\nimport type { PanelProps, CalculationType } from '@perses-dev/plugin-system';\nimport {\n LEGEND_VALUE_CONFIG,\n useTimeRange,\n validateLegendSpec,\n legendValues,\n getCalculations,\n} from '@perses-dev/plugin-system';\nimport type { Labels, TimeSeries, TimeSeriesData, TimeSeriesValueTuple } from '@perses-dev/spec';\nimport type { GridComponentOption } from 'echarts';\nimport merge from 'lodash/merge';\nimport type { ReactElement } from 'react';\nimport { memo, useCallback, useId, useMemo, useRef, useState } from 'react';\n\nimport type { TimeSeriesChartOptions } from './time-series-chart-model';\nimport { DEFAULT_FORMAT, DEFAULT_VISUAL, THRESHOLD_PLOT_INTERVAL } from './time-series-chart-model';\nimport { TimeSeriesChartBase } from './TimeSeriesChartBase';\nimport type { TimeSeriesAnnotation } from './utils/annotation';\nimport { convertAnnotationToTimeSeriesAnnotation } from './utils/annotation';\nimport type { ExemplarChartData } from './utils/data-transform';\nimport {\n getTimeSeries,\n getCommonTimeScaleForQueries,\n convertPanelYAxis,\n getThresholdSeries,\n convertPercentThreshold,\n} from './utils/data-transform';\nimport { getSeriesColor } from './utils/palette-gen';\n\nexport type TimeSeriesChartProps = PanelProps<TimeSeriesChartOptions, TimeSeriesData>;\n\n/**\n * Stable string key for a labels record, so exemplars can be matched to their\n * series regardless of the labels order.\n */\nfunction labelsKey(labels: Labels): string {\n return JSON.stringify(\n Object.keys(labels)\n .toSorted()\n .map((labelName) => [labelName, labels[labelName]]),\n );\n}\n\n// Using an \"ALL\" value to handle the case on first loading the chart where we\n// want to select all, but do not want all of the legend items to be visually highlighted.\n// This helps us differentiate those cases more clearly instead of inferring it\n// based on the state of the data. This also helps us avoid some coding\n// complexity around initializing a full record for the initial load that would\n// currently require significantly more refactoring of this component.\n// TODO: simplify this if we switch the list-based legend UI to use checkboxes,\n// where we *would* want to visually select all items in this case.\n\nfunction TimeSeriesChartPanelComponent(props: TimeSeriesChartProps): ReactElement | null {\n const {\n spec: { thresholds, yAxis, tooltip, querySettings: querySettingsList },\n contentDimensions,\n queryResults,\n } = props;\n const chartsTheme = useChartsTheme();\n const muiTheme = useTheme();\n const chartId = useId();\n\n const chartRef = useRef<ChartInstance>(null);\n\n // ECharts theme comes from ChartsProvider, more info: https://echarts.apache.org/en/option.html#color\n // Colors are manually applied since our legend and tooltip are built custom with React.\n const categoricalPalette = chartsTheme.echartsTheme.color;\n\n // TODO: consider refactoring how the layout/spacing/alignment are calculated\n // the next time significant changes are made to the time series panel (e.g.\n // when making improvements to the legend to more closely match designs).\n // This may also want to include moving some of this logic down to the shared,\n // embeddable components.\n const contentPadding = chartsTheme.container.padding.default;\n const adjustedContentDimensions: typeof contentDimensions = contentDimensions\n ? {\n width: contentDimensions.width - contentPadding * 2,\n height: contentDimensions.height - contentPadding * 2,\n }\n : undefined;\n\n // populate default 'position' and other future properties\n const legend = useMemo(() => {\n return props.spec.legend && validateLegendSpec(props.spec.legend)\n ? merge({}, DEFAULT_LEGEND, props.spec.legend)\n : undefined;\n }, [props.spec.legend]);\n\n // TODO: add support for y_axis_alt.format\n const format = props.spec.yAxis?.format ?? DEFAULT_FORMAT;\n\n // ensures there are fallbacks for unset properties since most\n // users should not need to customize visual display\n const visual = useMemo(() => {\n return merge({}, DEFAULT_VISUAL, props.spec.visual);\n }, [props.spec.visual]);\n\n // convert Perses dashboard format to be ECharts compatible\n const echartsYAxis = useMemo(() => {\n return convertPanelYAxis(yAxis);\n }, [yAxis]);\n\n // Collect unique formats from query settings that differ from the base format\n // These will create additional Y axes on the right side\n const { additionalFormats, formatToYAxisIndex } = useMemo(() => {\n const baseUnit = format?.unit ?? 'decimal';\n const additionalFormats: Array<typeof format> = [];\n const formatToYAxisIndex = new Map<string, number>();\n\n // Index 0 is reserved for the base Y axis\n formatToYAxisIndex.set(baseUnit, 0);\n\n // Collect unique formats from query settings\n for (const qs of querySettingsList ?? []) {\n if (qs.format?.unit && qs.format.unit !== baseUnit) {\n const unitKey = qs.format.unit;\n if (!formatToYAxisIndex.has(unitKey)) {\n // Add new format - index is 1 + position in additionalFormats array\n formatToYAxisIndex.set(unitKey, 1 + additionalFormats.length);\n additionalFormats.push(qs.format);\n }\n }\n }\n\n return { additionalFormats, formatToYAxisIndex };\n }, [format, querySettingsList]);\n\n const [selectedLegendItems, setSelectedLegendItems] = useState<SelectedLegendItemState>('ALL');\n const [legendSorting, setLegendSorting] = useState<NonNullable<LegendProps['tableProps']>['sorting']>();\n\n const { setTimeRange } = useTimeRange();\n\n const annotationsWithData = usePanelAnnotationsWithData(props.definition?.spec.annotations);\n\n const annotations: TimeSeriesAnnotation[] = useMemo(\n () => convertAnnotationToTimeSeriesAnnotation(annotationsWithData),\n [annotationsWithData],\n );\n\n const calculationTypes = legend?.values;\n\n // Point processing and legend statistics depend on query data, not legend selection.\n // Reuse these arrays when toggling series instead of rescanning every sample.\n const { timeScale, preparedQueries } = useMemo(() => {\n const commonScale = getCommonTimeScaleForQueries(queryResults);\n const settingsByQuery = new Map(querySettingsList?.map((settings) => [settings.queryIndex, settings]));\n let seriesIndex = 0;\n const queries = commonScale\n ? queryResults.map((result, queryIndex) => {\n const querySettings = settingsByQuery.get(queryIndex);\n const series = result.data.series.map((timeSeries) => {\n const baseValues = getTimeSeriesValues(timeSeries, commonScale);\n const values = querySettings?.negativeY\n ? baseValues.map(([t, v]): TimeSeriesValueTuple => [t, v === null ? null : -v])\n : baseValues;\n const calculations = calculationTypes\n ? getCalculations(timeSeries.values, calculationTypes as CalculationType[])\n : undefined;\n let maxValue = 0;\n if (querySettings?.format?.unit) {\n for (const [, value] of timeSeries.values) {\n maxValue = Math.max(maxValue, Math.abs(value ?? 0));\n }\n }\n const seriesId = `${chartId}${timeSeries.name}${seriesIndex}`;\n seriesIndex += 1;\n return { timeSeries, seriesId, values, calculations, maxValue };\n });\n return { querySettings, series, exemplars: result.data.exemplars };\n })\n : [];\n return { timeScale: commonScale, preparedQueries: queries };\n }, [queryResults, querySettingsList, calculationTypes, chartId]);\n\n // Prepare all exemplar groups independently of legend selection. The base chart\n // filters their scatter series without rebuilding marker data for visible groups.\n const chartExemplars = useMemo(() => {\n const groups: ExemplarChartData[] = [];\n let seriesIndex = 0;\n for (const { querySettings, series, exemplars } of preparedQueries) {\n // Labels identify a series within a query, not across different queries.\n const seriesByLabels = new Map<string, ExemplarChartData>();\n for (const { timeSeries, seriesId } of series) {\n const seriesName = timeSeries.formattedName ?? timeSeries.name;\n if (exemplars?.length && timeSeries.labels) {\n seriesByLabels.set(labelsKey(timeSeries.labels), {\n seriesId,\n seriesName,\n color: getSeriesColor({\n defaultCategoricalPalette: categoricalPalette as string[],\n visual,\n muiPrimaryColor: muiTheme.palette.primary.main,\n seriesName,\n seriesIndex,\n querySettings,\n queryHasMultipleResults: series.length > 1,\n }),\n seriesLabels: timeSeries.labels,\n yAxisIndex: formatToYAxisIndex.get(querySettings?.format?.unit ?? '') ?? 0,\n negativeY: querySettings?.negativeY,\n exemplars: [],\n });\n }\n seriesIndex += 1;\n }\n for (const group of exemplars ?? []) {\n if (group.exemplars.length === 0) continue;\n const matched = seriesByLabels.get(labelsKey(group.seriesLabels));\n if (matched) groups.push({ ...matched, exemplars: group.exemplars });\n }\n }\n return groups;\n }, [preparedQueries, categoricalPalette, visual, muiTheme.palette.primary.main, formatToYAxisIndex]);\n\n // Populate series data based on query results\n const {\n timeChartData,\n timeSeriesMapping,\n legendItems,\n seriesFormatMap: computedSeriesFormatMap,\n maxValuesByFormat,\n } = useMemo(() => {\n if (timeScale === undefined) {\n return {\n timeChartData: [] as TimeSeries[],\n timeSeriesMapping: [] as TimeChartSeriesMapping,\n legendItems: [] as LegendItem[],\n seriesFormatMap: new Map(),\n maxValuesByFormat: new Map<string, number>(),\n };\n }\n\n const legendItems: LegendItem[] = [];\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 timeChartData: TimeSeries[] = [];\n const timeSeriesMapping: TimeChartSeriesMapping = [];\n\n // Track max values for each format unit (used for dynamic Y axis offset calculation)\n const maxValuesByFormat = new Map<string, number>();\n const seriesFormatMap = new Map<string, typeof format>();\n\n let visibleSeriesCount = 0;\n for (const { series } of preparedQueries) {\n for (const { seriesId } of series) {\n if (selectedLegendItems === 'ALL' || selectedLegendItems[seriesId]) visibleSeriesCount++;\n }\n }\n\n // Index is counted across multiple queries which ensures the categorical color palette does not reset for every query\n let seriesIndex = 0;\n\n for (const { querySettings, series } of preparedQueries) {\n for (const { timeSeries, seriesId, values, calculations, maxValue } of series) {\n // Format is determined by seriesNameFormat in query spec\n const formattedSeriesName = timeSeries.formattedName ?? timeSeries.name;\n\n // Color is used for line, tooltip, and legend\n const seriesColor = getSeriesColor({\n // ECharts type for color is not always an array but it is always an array in ChartsProvider\n defaultCategoricalPalette: categoricalPalette as string[],\n visual,\n muiPrimaryColor: muiTheme.palette.primary.main,\n seriesName: formattedSeriesName,\n seriesIndex,\n querySettings: querySettings,\n queryHasMultipleResults: series.length > 1,\n });\n\n // When we initially load the chart, we want to show all series, but\n // DO NOT want to visualy highlight all the items in the legend.\n const isSelectAll = selectedLegendItems === 'ALL';\n const isSelected = !isSelectAll && !!selectedLegendItems[seriesId];\n const showTimeSeries = isSelected || isSelectAll;\n\n if (showTimeSeries) {\n // Use timeChartData.length to ensure the data that is passed into the tooltip accounts for\n // which legend items are selected. This must happen before timeChartData.push to avoid an\n // off-by-one error, seriesIndex cannot be used since it's needed to cycle through palette\n const datasetIndex = timeChartData.length;\n\n // Determine yAxisIndex based on the query's format setting\n const queryFormat = querySettings?.format;\n const yAxisIndex = queryFormat?.unit ? (formatToYAxisIndex.get(queryFormat.unit) ?? 0) : 0;\n\n // Each series is stored as a separate dataset source.\n // https://apache.github.io/echarts-handbook/en/concepts/dataset/#how-to-reference-several-datasets\n timeSeriesMapping.push(\n getTimeSeries(\n seriesId,\n datasetIndex,\n formattedSeriesName,\n visual,\n timeScale,\n seriesColor,\n querySettings,\n yAxisIndex,\n visibleSeriesCount,\n ),\n );\n\n // Store the format for this series for tooltip formatting\n if (queryFormat) {\n seriesFormatMap.set(seriesId, queryFormat);\n\n // Track max value for this format unit (used for dynamic Y axis offset calculation)\n const unitKey = queryFormat.unit;\n if (unitKey) {\n const currentMax = maxValuesByFormat.get(unitKey) ?? 0;\n if (maxValue > currentMax) {\n maxValuesByFormat.set(unitKey, maxValue);\n }\n }\n }\n\n timeChartData.push({\n name: formattedSeriesName,\n values,\n });\n }\n\n if (legend && legendItems) {\n legendItems.push({\n id: seriesId, // Avoids duplicate key console errors when there are duplicate series names\n label: formattedSeriesName,\n color: seriesColor,\n data: calculations,\n });\n }\n\n // Used for repeating colors in Categorical palette\n seriesIndex += 1;\n }\n }\n\n // map thresholds only if there is at least one time series to avoid displaying thresholds without any data\n if (thresholds && thresholds.steps && timeChartData.length > 0) {\n // Convert how thresholds are defined in the panel spec to valid ECharts 'line' series.\n // These are styled with predefined colors and a dashed style to look different than series from query results.\n // Regular series are used instead of markLines since thresholds currently show in our React TimeSeriesTooltip.\n const thresholdsColors = chartsTheme.thresholds;\n const defaultThresholdColor = thresholds.defaultColor ?? thresholdsColors.defaultColor;\n thresholds.steps.forEach((step: StepOptions, index: number) => {\n const stepPaletteColor = thresholdsColors.palette[index] ?? defaultThresholdColor;\n const thresholdLineColor = step.color ?? stepPaletteColor;\n const stepOption: StepOptions = {\n color: thresholdLineColor,\n value:\n // yAxis is passed here since it corresponds to dashboard JSON instead of the already converted ECharts yAxis\n thresholds.mode === 'percent'\n ? convertPercentThreshold(step.value, timeChartData, yAxis?.max, yAxis?.min)\n : step.value,\n };\n const thresholdName = step.name ?? `Threshold ${index + 1}`;\n\n // Generates array of [time, step.value] where time ranges from timescale.startMs to timescale.endMs with an interval of 15s\n const thresholdTimeValueTuple: TimeSeriesValueTuple[] = [];\n let currentTimestamp = timeScale.startMs;\n while (currentTimestamp <= timeScale.endMs) {\n thresholdTimeValueTuple.push([currentTimestamp, stepOption.value]);\n // Used to plot fake thresholds datapoints so correct nearby threshold series shows in tooltip without flicker\n currentTimestamp += 1000 * THRESHOLD_PLOT_INTERVAL;\n }\n\n timeChartData.push({\n name: thresholdName,\n values: thresholdTimeValueTuple,\n });\n timeSeriesMapping.push(getThresholdSeries(thresholdName, stepOption, seriesIndex));\n seriesIndex += 1;\n });\n }\n\n return {\n timeScale,\n timeChartData,\n timeSeriesMapping,\n legendItems,\n seriesFormatMap,\n maxValuesByFormat,\n };\n }, [\n preparedQueries,\n timeScale,\n thresholds,\n selectedLegendItems,\n legend,\n visual,\n yAxis?.max,\n yAxis?.min,\n categoricalPalette,\n chartsTheme.thresholds,\n muiTheme.palette.primary.main,\n formatToYAxisIndex,\n ]);\n\n // Create multiple Y axes if there are additional formats\n // Uses max values from data to compute dynamic offsets that adapt to label widths\n const multipleYAxes = useMemo(() => {\n if (additionalFormats.length === 0) {\n return undefined; // Use single Y axis (default behavior)\n }\n // Build array of max values for each additional format (in order)\n const maxValues = additionalFormats.map((fmt) => {\n const unitKey = fmt.unit;\n return unitKey ? (maxValuesByFormat?.get(unitKey) ?? 1000) : 1000;\n });\n return getFormattedMultipleYAxes(echartsYAxis, format, additionalFormats, maxValues);\n }, [echartsYAxis, format, additionalFormats, maxValuesByFormat]);\n\n // Translate the legend values into columns for the table legend.\n const legendColumns = useMemo(() => {\n if (!legend?.values) {\n return [];\n }\n\n // Iterating the predefined list of possible values to retain a specific\n // intended order of values.\n return legendValues.reduce(\n (columns, legendValue) => {\n const legendConfig = LEGEND_VALUE_CONFIG[legendValue];\n\n if (legendConfig && legend?.values?.includes(legendValue)) {\n columns.push({\n accessorKey: `data.${legendValue}`,\n header: legendConfig.label,\n headerDescription: legendConfig.description,\n // Intentionally hardcoding a column width to start based on discussions\n // with design around keeping this simple to start. This may need\n // revisiting in the future to handle edge cases with very large values.\n width: 72,\n align: 'right',\n cell: ({ getValue }) => {\n const cellValue = getValue();\n return typeof cellValue === 'number' && format ? formatValue(cellValue, format) : cellValue;\n },\n cellDescription: true,\n enableSorting: true,\n });\n }\n\n return columns;\n },\n [] as Array<TableColumnConfig<LegendItem>>,\n );\n }, [legend?.values, format]);\n\n const gridOverrides: GridComponentOption = useMemo(() => {\n // When Y axes are hidden, disable containLabel to prevent auto-spacing, but add bottom padding for X axis\n return echartsYAxis.show === false\n ? {\n left: 0,\n right: 0,\n bottom: 30,\n containLabel: false,\n }\n : {\n left: yAxis && yAxis.label ? 30 : 20,\n // With containLabel: true in theme, ECharts auto-reserves space for axis labels.\n // For multiple right axes, add extra padding for the last axis labels that extend beyond the grid.\n right: additionalFormats.length > 0 ? 10 : 20,\n bottom: 0,\n containLabel: true,\n };\n }, [echartsYAxis.show, yAxis, additionalFormats.length]);\n\n const handleDataZoom = useCallback(\n (event: ZoomEventData): void => {\n setTimeRange({ start: new Date(event.start), end: new Date(event.end) });\n },\n [setTimeRange],\n );\n\n if (adjustedContentDimensions === undefined) {\n return null;\n }\n\n // Used to opt in to ECharts trigger item which show subgroup data accurately.\n // Derived from the actual series mapping rather than `visual.stack` alone so that\n // bar charts stacked only via per-query overrides also use the right tooltip mode.\n const isStackedBar =\n visual.display === 'bar' && timeSeriesMapping.some((s) => s?.type === 'bar' && s.stack === 'all');\n\n // Turn on tooltip pinning by default but opt out for stacked bar or if explicitly set in tooltip panel spec\n let enablePinning = true;\n if (isStackedBar) {\n enablePinning = false;\n } else if (tooltip?.enablePinning !== undefined) {\n enablePinning = tooltip.enablePinning;\n }\n const tooltipConfig: TooltipConfig = {\n ...DEFAULT_TOOLTIP_CONFIG,\n enablePinning,\n };\n\n return (\n <Box sx={{ padding: `${contentPadding}px` }}>\n <ContentWithLegend\n width={adjustedContentDimensions.width}\n height={adjustedContentDimensions.height}\n // Making this small enough that the medium size doesn't get\n // responsive-handling-ed away when in the panel options editor.\n minChildrenHeight={50}\n legendSize={legend?.size}\n legendProps={\n legend && {\n options: legend,\n data: legendItems || [],\n selectedItems: selectedLegendItems,\n onSelectedItemsChange: setSelectedLegendItems,\n tableProps: {\n columns: legendColumns,\n sorting: legendSorting,\n onSortingChange: setLegendSorting,\n },\n onItemMouseOver: (e, { id }): void => {\n chartRef.current?.highlightSeries({ name: id });\n },\n onItemMouseOut: (): void => {\n chartRef.current?.clearHighlightedSeries();\n },\n }\n }\n >\n {({ height, width }) => {\n return (\n <Box style={{ height, width }}>\n {yAxis && yAxis.show && yAxis.label && <YAxisLabel name={yAxis.label} height={height} />}\n <TimeSeriesChartBase\n ref={chartRef}\n height={height}\n data={timeChartData}\n seriesMapping={timeSeriesMapping}\n exemplars={chartExemplars}\n annotations={annotations}\n timeScale={timeScale}\n yAxis={multipleYAxes ?? echartsYAxis}\n format={format}\n seriesFormatMap={computedSeriesFormatMap}\n grid={gridOverrides}\n isStackedBar={isStackedBar}\n tooltipConfig={tooltipConfig}\n syncGroup=\"default-panel-group\" // TODO: make configurable from dashboard settings and per panel-group overrides\n onDataZoom={handleDataZoom}\n // Show an empty chart when there is no data because the user unselected all items in\n // the legend. Otherwise, show a \"no data\" message.\n noDataVariant={!timeChartData.length && legendItems && legendItems.length > 0 ? 'chart' : 'message'}\n />\n </Box>\n );\n }}\n </ContentWithLegend>\n </Box>\n );\n}\n\n// PanelContent recreates the queryResults array and its wrappers on dashboard\n// hover/focus updates. Compare the underlying references in query order so those\n// updates do not invalidate data preparation or scan the samples and exemplars.\nexport const TimeSeriesChartPanel = memo(\n TimeSeriesChartPanelComponent,\n (previous, next): boolean =>\n previous.spec === next.spec &&\n previous.definition === next.definition &&\n previous.contentDimensions?.width === next.contentDimensions?.width &&\n previous.contentDimensions?.height === next.contentDimensions?.height &&\n previous.queryResults.length === next.queryResults.length &&\n previous.queryResults.every(\n (query, index) =>\n query.data === next.queryResults[index]?.data && query.definition === next.queryResults[index]?.definition,\n ),\n);\n"],"names":["Box","useTheme","YAxisLabel","useChartsTheme","ContentWithLegend","DEFAULT_TOOLTIP_CONFIG","getFormattedMultipleYAxes","DEFAULT_LEGEND","formatValue","getTimeSeriesValues","usePanelAnnotationsWithData","LEGEND_VALUE_CONFIG","useTimeRange","validateLegendSpec","legendValues","getCalculations","merge","memo","useCallback","useId","useMemo","useRef","useState","DEFAULT_FORMAT","DEFAULT_VISUAL","THRESHOLD_PLOT_INTERVAL","TimeSeriesChartBase","convertAnnotationToTimeSeriesAnnotation","getTimeSeries","getCommonTimeScaleForQueries","convertPanelYAxis","getThresholdSeries","convertPercentThreshold","getSeriesColor","labelsKey","labels","JSON","stringify","Object","keys","toSorted","map","labelName","TimeSeriesChartPanelComponent","props","spec","thresholds","yAxis","tooltip","querySettings","querySettingsList","contentDimensions","queryResults","chartsTheme","muiTheme","chartId","chartRef","categoricalPalette","echartsTheme","color","contentPadding","container","padding","default","adjustedContentDimensions","width","height","undefined","legend","format","visual","echartsYAxis","additionalFormats","formatToYAxisIndex","baseUnit","unit","Map","set","qs","unitKey","has","length","push","selectedLegendItems","setSelectedLegendItems","legendSorting","setLegendSorting","setTimeRange","annotationsWithData","definition","annotations","calculationTypes","values","timeScale","preparedQueries","commonScale","settingsByQuery","settings","queryIndex","seriesIndex","queries","result","get","series","data","timeSeries","baseValues","negativeY","t","v","calculations","maxValue","value","Math","max","abs","seriesId","name","exemplars","chartExemplars","groups","seriesByLabels","seriesName","formattedName","defaultCategoricalPalette","muiPrimaryColor","palette","primary","main","queryHasMultipleResults","seriesLabels","yAxisIndex","group","matched","timeChartData","timeSeriesMapping","legendItems","seriesFormatMap","computedSeriesFormatMap","maxValuesByFormat","visibleSeriesCount","formattedSeriesName","seriesColor","isSelectAll","isSelected","showTimeSeries","datasetIndex","queryFormat","currentMax","id","label","steps","thresholdsColors","defaultThresholdColor","defaultColor","forEach","step","index","stepPaletteColor","thresholdLineColor","stepOption","mode","min","thresholdName","thresholdTimeValueTuple","currentTimestamp","startMs","endMs","multipleYAxes","maxValues","fmt","legendColumns","reduce","columns","legendValue","legendConfig","includes","accessorKey","header","headerDescription","description","align","cell","getValue","cellValue","cellDescription","enableSorting","gridOverrides","show","left","right","bottom","containLabel","handleDataZoom","event","start","Date","end","isStackedBar","display","some","s","type","stack","enablePinning","tooltipConfig","sx","minChildrenHeight","legendSize","size","legendProps","options","selectedItems","onSelectedItemsChange","tableProps","sorting","onSortingChange","onItemMouseOver","e","current","highlightSeries","onItemMouseOut","clearHighlightedSeries","style","ref","seriesMapping","grid","syncGroup","onDataZoom","noDataVariant","TimeSeriesChartPanel","previous","next","every","query"],"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;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AKxK;4BACLU,QAAQA;4BACRsC,MAAM8B;4BACN2F,eAAe1F;4BACfjB,WAAWC;4BACX7B,aAAaA;4BACbG,WAAWA;4BACX9C,OAAOyH,iBAAiBjG;4BACxBF,QAAQA;4BACRoE,iBAAiBC;4BACjBwF,MAAMvC;4BACNW,cAAcA;4BACdO,eAAeA;4BACfsB,WAAU;4BACVC,YAAYnC;4BACZ,sFAAsF;4BACtF,mDAAmD;4BACnDoC,eAAe,CAAC/F,cAAcrD,MAAM,IAAIuD,eAAeA,YAAYvD,MAAM,GAAG,IAAI,UAAU;;;;YAIlG;;;AAIR;AAEA,8EAA8E;AAC9E,iFAAiF;AACjF,gFAAgF;AAChF,OAAO,MAAMqJ,qCAAuBrN,KAClC0B,+BACA,CAAC4L,UAAUC,OACTD,SAAS1L,IAAI,KAAK2L,KAAK3L,IAAI,IAC3B0L,SAAS9I,UAAU,KAAK+I,KAAK/I,UAAU,IACvC8I,SAASpL,iBAAiB,EAAEc,UAAUuK,KAAKrL,iBAAiB,EAAEc,SAC9DsK,SAASpL,iBAAiB,EAAEe,WAAWsK,KAAKrL,iBAAiB,EAAEe,UAC/DqK,SAASnL,YAAY,CAAC6B,MAAM,KAAKuJ,KAAKpL,YAAY,CAAC6B,MAAM,IACzDsJ,SAASnL,YAAY,CAACqL,KAAK,CACzB,CAACC,OAAO7E,QACN6E,MAAMlI,IAAI,KAAKgI,KAAKpL,YAAY,CAACyG,MAAM,EAAErD,QAAQkI,MAAMjJ,UAAU,KAAK+I,KAAKpL,YAAY,CAACyG,MAAM,EAAEpE,aAEtG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VisualOptionsEditor.d.ts","sourceRoot":"","sources":["../../src/VisualOptionsEditor.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"VisualOptionsEditor.d.ts","sourceRoot":"","sources":["../../src/VisualOptionsEditor.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,KAAK,EAAgB,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAe5F,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,4BAA4B,CAAC;IACpC,QAAQ,EAAE,CAAC,MAAM,EAAE,4BAA4B,KAAK,IAAI,CAAC;CAC1D;AAED,wBAAgB,mBAAmB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,wBAAwB,GAAG,YAAY,CAuJ/F"}
|
|
@@ -14,6 +14,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
14
14
|
import { Slider, Switch, ToggleButton, ToggleButtonGroup } from "@mui/material";
|
|
15
15
|
import { OptionsEditorControl, OptionsEditorGroup, SettingsAutocomplete } from "@perses-dev/components";
|
|
16
16
|
import { produce } from "immer";
|
|
17
|
+
import { PaletteSelector } from "./components/PaletteSelector.js";
|
|
17
18
|
import { DEFAULT_AREA_OPACITY, DEFAULT_CONNECT_NULLS, DEFAULT_LINE_WIDTH, DEFAULT_LINE_STYLE, DEFAULT_POINT_RADIUS, POINT_SIZE_OFFSET, STACK_CONFIG, STACK_OPTIONS, LINE_STYLE_CONFIG, VISUAL_CONFIG, DEFAULT_DISPLAY } from "./time-series-chart-model.js";
|
|
18
19
|
export function VisualOptionsEditor({ value, onChange }) {
|
|
19
20
|
const handleLineWidthChange = (_, sliderValue)=>{
|
|
@@ -58,6 +59,13 @@ export function VisualOptionsEditor({ value, onChange }) {
|
|
|
58
59
|
disableClearable: true
|
|
59
60
|
})
|
|
60
61
|
}),
|
|
62
|
+
/*#__PURE__*/ _jsx(PaletteSelector, {
|
|
63
|
+
value: value.palette,
|
|
64
|
+
onChange: (palette)=>onChange({
|
|
65
|
+
...value,
|
|
66
|
+
palette
|
|
67
|
+
})
|
|
68
|
+
}),
|
|
61
69
|
/*#__PURE__*/ _jsx(OptionsEditorControl, {
|
|
62
70
|
label: "Display",
|
|
63
71
|
control: /*#__PURE__*/ _jsxs(ToggleButtonGroup, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/VisualOptionsEditor.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 { Slider, Switch, ToggleButton, ToggleButtonGroup } from '@mui/material';\nimport { OptionsEditorControl, OptionsEditorGroup, SettingsAutocomplete } from '@perses-dev/components';\nimport { produce } from 'immer';\nimport type { ReactElement } from 'react';\n\nimport type { StackOptions, TimeSeriesChartVisualOptions } from './time-series-chart-model';\nimport {\n DEFAULT_AREA_OPACITY,\n DEFAULT_CONNECT_NULLS,\n DEFAULT_LINE_WIDTH,\n DEFAULT_LINE_STYLE,\n DEFAULT_POINT_RADIUS,\n POINT_SIZE_OFFSET,\n STACK_CONFIG,\n STACK_OPTIONS,\n LINE_STYLE_CONFIG,\n VISUAL_CONFIG,\n DEFAULT_DISPLAY,\n} from './time-series-chart-model';\n\nexport interface VisualOptionsEditorProps {\n value: TimeSeriesChartVisualOptions;\n onChange: (visual: TimeSeriesChartVisualOptions) => void;\n}\n\nexport function VisualOptionsEditor({ value, onChange }: VisualOptionsEditorProps): ReactElement {\n const handleLineWidthChange = (_: Event, sliderValue: number | number[]): void => {\n const newValue = Array.isArray(sliderValue) ? sliderValue[0] : sliderValue;\n const symbolSize = newValue !== undefined ? newValue + POINT_SIZE_OFFSET : DEFAULT_POINT_RADIUS;\n onChange(\n produce(value, (draft) => {\n draft.lineWidth = newValue;\n draft.pointRadius = symbolSize;\n }),\n );\n };\n\n const handleAreaOpacityChange = (_: Event, sliderValue: number | number[]): void => {\n const newValue = Array.isArray(sliderValue) ? sliderValue[0] : sliderValue;\n onChange(\n produce(value, (draft) => {\n draft.areaOpacity = newValue;\n }),\n );\n };\n\n const currentStack: StackOptions = value.stack ?? 'none';\n const stackConfig = STACK_CONFIG[currentStack];\n\n return (\n <OptionsEditorGroup title=\"Visual\">\n <OptionsEditorControl\n label={VISUAL_CONFIG.stack.label}\n control={\n <SettingsAutocomplete\n value={{\n ...stackConfig,\n id: currentStack,\n }}\n options={STACK_OPTIONS}\n onChange={(__, newValue) => {\n const updatedValue: TimeSeriesChartVisualOptions = {\n ...value,\n stack: newValue.id === 'none' ? undefined : newValue.id,\n };\n // stacked area chart preset to automatically set area under a curve shading\n if (newValue.id === 'all' && !value.areaOpacity) {\n updatedValue.areaOpacity = 0.3;\n }\n onChange(updatedValue);\n }}\n disabled={value === undefined}\n disableClearable\n ></SettingsAutocomplete>\n }\n />\n <OptionsEditorControl\n label=\"Display\"\n control={\n <ToggleButtonGroup\n color=\"primary\"\n exclusive\n value={value.display ?? DEFAULT_DISPLAY}\n onChange={(__, newValue) => {\n onChange({\n ...value,\n display: newValue,\n });\n }}\n >\n <ToggleButton\n value=\"line\"\n selected={value.display === undefined || value.display === 'line'}\n aria-label=\"display line series\"\n >\n Line\n </ToggleButton>\n <ToggleButton value=\"bar\" aria-label=\"display bar series\">\n Bar\n </ToggleButton>\n </ToggleButtonGroup>\n }\n />\n {value.display === 'line' && (\n <>\n <OptionsEditorControl\n label={VISUAL_CONFIG.lineWidth.label}\n control={\n <Slider\n data-testid={VISUAL_CONFIG.lineWidth.testId}\n value={value.lineWidth ?? DEFAULT_LINE_WIDTH}\n valueLabelDisplay=\"auto\"\n step={VISUAL_CONFIG.lineWidth.step}\n marks\n min={VISUAL_CONFIG.lineWidth.min}\n max={VISUAL_CONFIG.lineWidth.max}\n onChange={handleLineWidthChange}\n />\n }\n />\n <OptionsEditorControl\n label={VISUAL_CONFIG.lineStyle.label}\n control={\n <ToggleButtonGroup\n color=\"primary\"\n exclusive\n value={value.lineStyle ?? DEFAULT_LINE_STYLE}\n onChange={(__, newValue) => {\n onChange({\n ...value,\n lineStyle: newValue,\n });\n }}\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 }\n />\n <OptionsEditorControl\n label={VISUAL_CONFIG.areaOpacity.label}\n control={\n <Slider\n data-testid={VISUAL_CONFIG.areaOpacity.testId}\n value={value.areaOpacity ?? DEFAULT_AREA_OPACITY}\n valueLabelDisplay=\"auto\"\n step={VISUAL_CONFIG.areaOpacity.step}\n marks\n min={VISUAL_CONFIG.areaOpacity.min}\n max={VISUAL_CONFIG.areaOpacity.max}\n onChange={handleAreaOpacityChange}\n />\n }\n />\n <OptionsEditorControl\n label={VISUAL_CONFIG.connectNulls.label}\n control={\n <Switch\n checked={value.connectNulls ?? DEFAULT_CONNECT_NULLS}\n onChange={(e) => {\n onChange({\n ...value,\n connectNulls: e.target.checked,\n });\n }}\n />\n }\n />\n </>\n )}\n </OptionsEditorGroup>\n );\n}\n"],"names":["Slider","Switch","ToggleButton","ToggleButtonGroup","OptionsEditorControl","OptionsEditorGroup","SettingsAutocomplete","produce","DEFAULT_AREA_OPACITY","DEFAULT_CONNECT_NULLS","DEFAULT_LINE_WIDTH","DEFAULT_LINE_STYLE","DEFAULT_POINT_RADIUS","POINT_SIZE_OFFSET","STACK_CONFIG","STACK_OPTIONS","LINE_STYLE_CONFIG","VISUAL_CONFIG","DEFAULT_DISPLAY","VisualOptionsEditor","value","onChange","handleLineWidthChange","_","sliderValue","newValue","Array","isArray","symbolSize","undefined","draft","lineWidth","pointRadius","handleAreaOpacityChange","areaOpacity","currentStack","stack","stackConfig","title","label","control","id","options","__","updatedValue","disabled","disableClearable","color","exclusive","display","selected","aria-label","data-testid","testId","valueLabelDisplay","step","marks","min","max","lineStyle","Object","entries","map","styleValue","config","connectNulls","checked","e","target"],"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,MAAM,EAAEC,MAAM,EAAEC,YAAY,EAAEC,iBAAiB,QAAQ,gBAAgB;AAChF,SAASC,oBAAoB,EAAEC,kBAAkB,EAAEC,oBAAoB,QAAQ,yBAAyB;AACxG,SAASC,OAAO,QAAQ,QAAQ;AAIhC,SACEC,oBAAoB,EACpBC,qBAAqB,EACrBC,kBAAkB,EAClBC,kBAAkB,EAClBC,oBAAoB,EACpBC,iBAAiB,EACjBC,YAAY,EACZC,aAAa,EACbC,iBAAiB,EACjBC,aAAa,EACbC,eAAe,QACV,+BAA4B;AAOnC,OAAO,SAASC,oBAAoB,EAAEC,KAAK,EAAEC,QAAQ,EAA4B;IAC/E,MAAMC,wBAAwB,CAACC,GAAUC;QACvC,MAAMC,WAAWC,MAAMC,OAAO,CAACH,eAAeA,WAAW,CAAC,EAAE,GAAGA;QAC/D,MAAMI,aAAaH,aAAaI,YAAYJ,WAAWZ,oBAAoBD;QAC3ES,SACEd,QAAQa,OAAO,CAACU;YACdA,MAAMC,SAAS,GAAGN;YAClBK,MAAME,WAAW,GAAGJ;QACtB;IAEJ;IAEA,MAAMK,0BAA0B,CAACV,GAAUC;QACzC,MAAMC,WAAWC,MAAMC,OAAO,CAACH,eAAeA,WAAW,CAAC,EAAE,GAAGA;QAC/DH,SACEd,QAAQa,OAAO,CAACU;YACdA,MAAMI,WAAW,GAAGT;QACtB;IAEJ;IAEA,MAAMU,eAA6Bf,MAAMgB,KAAK,IAAI;IAClD,MAAMC,cAAcvB,YAAY,CAACqB,aAAa;IAE9C,qBACE,MAAC9B;QAAmBiC,OAAM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BAChCrC,UAAUC;;;kCAIhB,KAAClB;wBACCmC,OAAOtB,cAAc0C,SAAS,CAACpB,KAAK;wBACpCC,uBACE,KAACrC;4BACC4C,OAAM;4BACNC,SAAS;4BACT5B,OAAOA,MAAMuC,SAAS,IAAIhD;4BAC1BU,UAAU,CAACsB,IAAIlB;gCACbJ,SAAS;oCACP,GAAGD,KAAK;oCACRuC,WAAWlC;gCACb;4BACF;sCAECmC,OAAOC,OAAO,CAAC7C,mBAAmB8C,GAAG,CAAC,CAAC,CAACC,YAAYC,OAAO,iBAC1D,KAAC9D;oCAA8BkB,OAAO2C;oCAAYZ,cAAY,GAAGY,WAAW,WAAW,CAAC;8CACrFC,OAAOzB,KAAK;mCADIwB;;;kCAO3B,KAAC3D;wBACCmC,OAAOtB,cAAciB,WAAW,CAACK,KAAK;wBACtCC,uBACE,KAACxC;4BACCoD,eAAanC,cAAciB,WAAW,CAACmB,MAAM;4BAC7CjC,OAAOA,MAAMc,WAAW,IAAI1B;4BAC5B8C,mBAAkB;4BAClBC,MAAMtC,cAAciB,WAAW,CAACqB,IAAI;4BACpCC,KAAK;4BACLC,KAAKxC,cAAciB,WAAW,CAACuB,GAAG;4BAClCC,KAAKzC,cAAciB,WAAW,CAACwB,GAAG;4BAClCrC,UAAUY;;;kCAIhB,KAAC7B;wBACCmC,OAAOtB,cAAcgD,YAAY,CAAC1B,KAAK;wBACvCC,uBACE,KAACvC;4BACCiE,SAAS9C,MAAM6C,YAAY,IAAIxD;4BAC/BY,UAAU,CAAC8C;gCACT9C,SAAS;oCACP,GAAGD,KAAK;oCACR6C,cAAcE,EAAEC,MAAM,CAACF,OAAO;gCAChC;4BACF;;;;;;;AAQhB"}
|
|
1
|
+
{"version":3,"sources":["../../src/VisualOptionsEditor.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 { Slider, Switch, ToggleButton, ToggleButtonGroup } from '@mui/material';\nimport { OptionsEditorControl, OptionsEditorGroup, SettingsAutocomplete } from '@perses-dev/components';\nimport { produce } from 'immer';\nimport type { ReactElement } from 'react';\n\nimport { PaletteSelector } from './components/PaletteSelector';\nimport type { StackOptions, TimeSeriesChartVisualOptions } from './time-series-chart-model';\nimport {\n DEFAULT_AREA_OPACITY,\n DEFAULT_CONNECT_NULLS,\n DEFAULT_LINE_WIDTH,\n DEFAULT_LINE_STYLE,\n DEFAULT_POINT_RADIUS,\n POINT_SIZE_OFFSET,\n STACK_CONFIG,\n STACK_OPTIONS,\n LINE_STYLE_CONFIG,\n VISUAL_CONFIG,\n DEFAULT_DISPLAY,\n} from './time-series-chart-model';\n\nexport interface VisualOptionsEditorProps {\n value: TimeSeriesChartVisualOptions;\n onChange: (visual: TimeSeriesChartVisualOptions) => void;\n}\n\nexport function VisualOptionsEditor({ value, onChange }: VisualOptionsEditorProps): ReactElement {\n const handleLineWidthChange = (_: Event, sliderValue: number | number[]): void => {\n const newValue = Array.isArray(sliderValue) ? sliderValue[0] : sliderValue;\n const symbolSize = newValue !== undefined ? newValue + POINT_SIZE_OFFSET : DEFAULT_POINT_RADIUS;\n onChange(\n produce(value, (draft) => {\n draft.lineWidth = newValue;\n draft.pointRadius = symbolSize;\n }),\n );\n };\n\n const handleAreaOpacityChange = (_: Event, sliderValue: number | number[]): void => {\n const newValue = Array.isArray(sliderValue) ? sliderValue[0] : sliderValue;\n onChange(\n produce(value, (draft) => {\n draft.areaOpacity = newValue;\n }),\n );\n };\n\n const currentStack: StackOptions = value.stack ?? 'none';\n const stackConfig = STACK_CONFIG[currentStack];\n\n return (\n <OptionsEditorGroup title=\"Visual\">\n <OptionsEditorControl\n label={VISUAL_CONFIG.stack.label}\n control={\n <SettingsAutocomplete\n value={{\n ...stackConfig,\n id: currentStack,\n }}\n options={STACK_OPTIONS}\n onChange={(__, newValue) => {\n const updatedValue: TimeSeriesChartVisualOptions = {\n ...value,\n stack: newValue.id === 'none' ? undefined : newValue.id,\n };\n // stacked area chart preset to automatically set area under a curve shading\n if (newValue.id === 'all' && !value.areaOpacity) {\n updatedValue.areaOpacity = 0.3;\n }\n onChange(updatedValue);\n }}\n disabled={value === undefined}\n disableClearable\n ></SettingsAutocomplete>\n }\n />\n <PaletteSelector value={value.palette} onChange={(palette) => onChange({ ...value, palette })} />\n <OptionsEditorControl\n label=\"Display\"\n control={\n <ToggleButtonGroup\n color=\"primary\"\n exclusive\n value={value.display ?? DEFAULT_DISPLAY}\n onChange={(__, newValue) => {\n onChange({\n ...value,\n display: newValue,\n });\n }}\n >\n <ToggleButton\n value=\"line\"\n selected={value.display === undefined || value.display === 'line'}\n aria-label=\"display line series\"\n >\n Line\n </ToggleButton>\n <ToggleButton value=\"bar\" aria-label=\"display bar series\">\n Bar\n </ToggleButton>\n </ToggleButtonGroup>\n }\n />\n {value.display === 'line' && (\n <>\n <OptionsEditorControl\n label={VISUAL_CONFIG.lineWidth.label}\n control={\n <Slider\n data-testid={VISUAL_CONFIG.lineWidth.testId}\n value={value.lineWidth ?? DEFAULT_LINE_WIDTH}\n valueLabelDisplay=\"auto\"\n step={VISUAL_CONFIG.lineWidth.step}\n marks\n min={VISUAL_CONFIG.lineWidth.min}\n max={VISUAL_CONFIG.lineWidth.max}\n onChange={handleLineWidthChange}\n />\n }\n />\n <OptionsEditorControl\n label={VISUAL_CONFIG.lineStyle.label}\n control={\n <ToggleButtonGroup\n color=\"primary\"\n exclusive\n value={value.lineStyle ?? DEFAULT_LINE_STYLE}\n onChange={(__, newValue) => {\n onChange({\n ...value,\n lineStyle: newValue,\n });\n }}\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 }\n />\n <OptionsEditorControl\n label={VISUAL_CONFIG.areaOpacity.label}\n control={\n <Slider\n data-testid={VISUAL_CONFIG.areaOpacity.testId}\n value={value.areaOpacity ?? DEFAULT_AREA_OPACITY}\n valueLabelDisplay=\"auto\"\n step={VISUAL_CONFIG.areaOpacity.step}\n marks\n min={VISUAL_CONFIG.areaOpacity.min}\n max={VISUAL_CONFIG.areaOpacity.max}\n onChange={handleAreaOpacityChange}\n />\n }\n />\n <OptionsEditorControl\n label={VISUAL_CONFIG.connectNulls.label}\n control={\n <Switch\n checked={value.connectNulls ?? DEFAULT_CONNECT_NULLS}\n onChange={(e) => {\n onChange({\n ...value,\n connectNulls: e.target.checked,\n });\n }}\n />\n }\n />\n </>\n )}\n </OptionsEditorGroup>\n );\n}\n"],"names":["Slider","Switch","ToggleButton","ToggleButtonGroup","OptionsEditorControl","OptionsEditorGroup","SettingsAutocomplete","produce","PaletteSelector","DEFAULT_AREA_OPACITY","DEFAULT_CONNECT_NULLS","DEFAULT_LINE_WIDTH","DEFAULT_LINE_STYLE","DEFAULT_POINT_RADIUS","POINT_SIZE_OFFSET","STACK_CONFIG","STACK_OPTIONS","LINE_STYLE_CONFIG","VISUAL_CONFIG","DEFAULT_DISPLAY","VisualOptionsEditor","value","onChange","handleLineWidthChange","_","sliderValue","newValue","Array","isArray","symbolSize","undefined","draft","lineWidth","pointRadius","handleAreaOpacityChange","areaOpacity","currentStack","stack","stackConfig","title","label","control","id","options","__","updatedValue","disabled","disableClearable","palette","color","exclusive","display","selected","aria-label","data-testid","testId","valueLabelDisplay","step","marks","min","max","lineStyle","Object","entries","map","styleValue","config","connectNulls","checked","e","target"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;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AOtB,cAAc2C,SAAS,CAACrB,KAAK;wBACpCC,uBACE,KAACtC;4BACC8C,OAAM;4BACNC,SAAS;4BACT7B,OAAOA,MAAMwC,SAAS,IAAIjD;4BAC1BU,UAAU,CAACsB,IAAIlB;gCACbJ,SAAS;oCACP,GAAGD,KAAK;oCACRwC,WAAWnC;gCACb;4BACF;sCAECoC,OAAOC,OAAO,CAAC9C,mBAAmB+C,GAAG,CAAC,CAAC,CAACC,YAAYC,OAAO,iBAC1D,KAAChE;oCAA8BmB,OAAO4C;oCAAYZ,cAAY,GAAGY,WAAW,WAAW,CAAC;8CACrFC,OAAO1B,KAAK;mCADIyB;;;kCAO3B,KAAC7D;wBACCoC,OAAOtB,cAAciB,WAAW,CAACK,KAAK;wBACtCC,uBACE,KAACzC;4BACCsD,eAAapC,cAAciB,WAAW,CAACoB,MAAM;4BAC7ClC,OAAOA,MAAMc,WAAW,IAAI1B;4BAC5B+C,mBAAkB;4BAClBC,MAAMvC,cAAciB,WAAW,CAACsB,IAAI;4BACpCC,KAAK;4BACLC,KAAKzC,cAAciB,WAAW,CAACwB,GAAG;4BAClCC,KAAK1C,cAAciB,WAAW,CAACyB,GAAG;4BAClCtC,UAAUY;;;kCAIhB,KAAC9B;wBACCoC,OAAOtB,cAAciD,YAAY,CAAC3B,KAAK;wBACvCC,uBACE,KAACxC;4BACCmE,SAAS/C,MAAM8C,YAAY,IAAIzD;4BAC/BY,UAAU,CAAC+C;gCACT/C,SAAS;oCACP,GAAGD,KAAK;oCACR8C,cAAcE,EAAEC,MAAM,CAACF,OAAO;gCAChC;4BACF;;;;;;;AAQhB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { CursorCoordinates } from '@perses-dev/components';
|
|
2
|
-
import type { LineSeriesOption } from 'echarts';
|
|
2
|
+
import type { LineSeriesOption, YAXisComponentOption } from 'echarts';
|
|
3
3
|
import type { TimeSeriesAnnotation } from '../utils/annotation';
|
|
4
|
+
export declare const ANNOTATION_Y_AXIS: YAXisComponentOption;
|
|
4
5
|
export interface AnnotationTooltipProps {
|
|
5
6
|
annotation: TimeSeriesAnnotation;
|
|
6
7
|
containerId?: string;
|
|
@@ -14,5 +15,5 @@ export declare function AnnotationTooltip({ annotation, containerId, formatWithU
|
|
|
14
15
|
* Build ECharts series options for rendering annotations as markArea (range),
|
|
15
16
|
* markLine (vertical dashed lines) and markPoint (triangle markers under the X-axis).
|
|
16
17
|
*/
|
|
17
|
-
export declare function buildAnnotationSeries(annotations: TimeSeriesAnnotation[] | undefined): LineSeriesOption[];
|
|
18
|
+
export declare function buildAnnotationSeries(annotations: TimeSeriesAnnotation[] | undefined, annotationYAxisIndex: number): LineSeriesOption[];
|
|
18
19
|
//# sourceMappingURL=AnnotationTooltip.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnnotationTooltip.d.ts","sourceRoot":"","sources":["../../../src/annotations/AnnotationTooltip.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAYhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"AnnotationTooltip.d.ts","sourceRoot":"","sources":["../../../src/annotations/AnnotationTooltip.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAYhE,OAAO,KAAK,EAAE,gBAAgB,EAA4B,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAKhG,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAGhE,eAAO,MAAM,iBAAiB,EAAE,oBAM/B,CAAC;AAEF,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,oBAAoB,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sBAAsB,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,KAAK,MAAM,CAAC;IACrE,SAAS,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACpC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B;AAED,wBAAgB,iBAAiB,CAAC,EAChC,UAAU,EACV,WAAW,EACX,sBAAsB,EACtB,SAAS,EACT,aAAoB,EACpB,YAAY,GACb,EAAE,sBAAsB,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CA2G7C;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,oBAAoB,EAAE,GAAG,SAAS,EAC/C,oBAAoB,EAAE,MAAM,GAC3B,gBAAgB,EAAE,CAiIpB"}
|
|
@@ -17,6 +17,16 @@ import { DEFAULT_ANNOTATION_COLOR } from "@perses-dev/plugin-system";
|
|
|
17
17
|
import Pin from "mdi-material-ui/Pin";
|
|
18
18
|
import PinOutline from "mdi-material-ui/PinOutline";
|
|
19
19
|
import useResizeObserver from "use-resize-observer";
|
|
20
|
+
// Hidden Y axis to guarantee annotations being shown
|
|
21
|
+
export const ANNOTATION_Y_AXIS = {
|
|
22
|
+
type: 'value',
|
|
23
|
+
show: false,
|
|
24
|
+
min: 0,
|
|
25
|
+
max: 1,
|
|
26
|
+
axisLabel: {
|
|
27
|
+
show: false
|
|
28
|
+
}
|
|
29
|
+
};
|
|
20
30
|
export function AnnotationTooltip({ annotation, containerId, formatWithUserTimeZone, pinnedPos, enablePinning = true, onUnpinClick }) {
|
|
21
31
|
const mousePos = useMousePosition();
|
|
22
32
|
const { height, width, ref: tooltipRef } = useResizeObserver();
|
|
@@ -198,11 +208,10 @@ export function AnnotationTooltip({ annotation, containerId, formatWithUserTimeZ
|
|
|
198
208
|
/**
|
|
199
209
|
* Build ECharts series options for rendering annotations as markArea (range),
|
|
200
210
|
* markLine (vertical dashed lines) and markPoint (triangle markers under the X-axis).
|
|
201
|
-
*/ export function buildAnnotationSeries(annotations) {
|
|
211
|
+
*/ export function buildAnnotationSeries(annotations, annotationYAxisIndex) {
|
|
202
212
|
if (!annotations?.length) return [];
|
|
203
213
|
const markAreaData = [];
|
|
204
214
|
const markLineData = [];
|
|
205
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
206
215
|
const markPointData = [];
|
|
207
216
|
annotations.forEach((annotation, index)=>{
|
|
208
217
|
const color = annotation.color ?? DEFAULT_ANNOTATION_COLOR;
|
|
@@ -251,6 +260,7 @@ export function AnnotationTooltip({ annotation, containerId, formatWithUserTimeZ
|
|
|
251
260
|
false
|
|
252
261
|
]){
|
|
253
262
|
markPointData.push({
|
|
263
|
+
name: '',
|
|
254
264
|
coord: [
|
|
255
265
|
isStart ? annotation.start : annotation.end,
|
|
256
266
|
0
|
|
@@ -292,6 +302,7 @@ export function AnnotationTooltip({ annotation, containerId, formatWithUserTimeZ
|
|
|
292
302
|
});
|
|
293
303
|
// Add point marker
|
|
294
304
|
markPointData.push({
|
|
305
|
+
name: '',
|
|
295
306
|
coord: [
|
|
296
307
|
annotation.start,
|
|
297
308
|
0
|
|
@@ -317,6 +328,7 @@ export function AnnotationTooltip({ annotation, containerId, formatWithUserTimeZ
|
|
|
317
328
|
const series = {
|
|
318
329
|
type: 'line',
|
|
319
330
|
data: [],
|
|
331
|
+
yAxisIndex: annotationYAxisIndex,
|
|
320
332
|
silent: false,
|
|
321
333
|
markArea: markAreaData.length > 0 ? {
|
|
322
334
|
silent: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/annotations/AnnotationTooltip.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 { Box, Divider, Portal, Stack, Typography } from '@mui/material';\nimport type { CursorCoordinates } from '@perses-dev/components';\nimport {\n assembleTransform,\n getDateAndTime,\n getTooltipStyles,\n PIN_TOOLTIP_HELP_TEXT,\n TOOLTIP_BG_COLOR_FALLBACK,\n TOOLTIP_MAX_WIDTH,\n UNPIN_TOOLTIP_HELP_TEXT,\n useMousePosition,\n} from '@perses-dev/components';\nimport { DEFAULT_ANNOTATION_COLOR } from '@perses-dev/plugin-system';\nimport type { LineSeriesOption } from 'echarts';\nimport Pin from 'mdi-material-ui/Pin';\nimport PinOutline from 'mdi-material-ui/PinOutline';\nimport useResizeObserver from 'use-resize-observer';\n\nimport type { TimeSeriesAnnotation } from '../utils/annotation';\n\nexport interface AnnotationTooltipProps {\n annotation: TimeSeriesAnnotation;\n containerId?: string;\n formatWithUserTimeZone: (date: Date, formatString: string) => string;\n pinnedPos: CursorCoordinates | null;\n enablePinning?: boolean;\n onUnpinClick?: () => void;\n}\n\nexport function AnnotationTooltip({\n annotation,\n containerId,\n formatWithUserTimeZone,\n pinnedPos,\n enablePinning = true,\n onUnpinClick,\n}: AnnotationTooltipProps): JSX.Element | null {\n const mousePos = useMousePosition();\n const { height, width, ref: tooltipRef } = useResizeObserver<HTMLDivElement>();\n\n const isPinned = pinnedPos !== null;\n if (!isPinned && mousePos === null) return null;\n\n const containerElement = containerId ? document.querySelector(containerId) : undefined;\n const maxHeight = containerElement ? containerElement.getBoundingClientRect().height : undefined;\n const transform = assembleTransform(mousePos, pinnedPos, height ?? 0, width ?? 0, containerElement);\n\n const start = getDateAndTime(annotation.start, formatWithUserTimeZone);\n const end = annotation.end !== undefined ? getDateAndTime(annotation.end, formatWithUserTimeZone) : null;\n\n return (\n <Portal container={containerElement}>\n <Box ref={tooltipRef} sx={(theme) => getTooltipStyles(theme, pinnedPos, maxHeight)} style={{ transform }}>\n <Stack spacing={0.5}>\n <Box\n sx={(theme) => ({\n width: '100%',\n maxWidth: TOOLTIP_MAX_WIDTH,\n padding: theme.spacing(1.5, 2, 0.5, 2),\n backgroundColor: theme.palette.designSystem?.grey[800] ?? TOOLTIP_BG_COLOR_FALLBACK,\n position: 'sticky',\n top: 0,\n left: 0,\n })}\n >\n <Box sx={{ display: 'flex', alignItems: 'center', paddingBottom: 0.5, width: '100%' }}>\n <Box\n sx={{\n width: 8,\n height: 8,\n borderRadius: '50%',\n backgroundColor: annotation.color ?? DEFAULT_ANNOTATION_COLOR,\n marginRight: 1,\n flexShrink: 0,\n }}\n />\n <Box sx={{ flexGrow: 1, minWidth: 0 }}>\n <Typography variant=\"caption\">\n {start.formattedDate} - <strong>{start.formattedTime}</strong>\n </Typography>\n {end && (\n <>\n <Typography variant=\"caption\">{' → '}</Typography>\n <Typography variant=\"caption\">\n {end.formattedDate} - <strong>{end.formattedTime}</strong>\n </Typography>\n </>\n )}\n </Box>\n {enablePinning && (\n <Stack direction=\"row\" alignItems=\"center\" sx={{ marginLeft: 1, flexShrink: 0 }}>\n <Typography sx={{ marginRight: 0.5, fontSize: 11, verticalAlign: 'middle' }}>\n {isPinned ? UNPIN_TOOLTIP_HELP_TEXT : PIN_TOOLTIP_HELP_TEXT}\n </Typography>\n {isPinned ? (\n <Pin\n onClick={() => {\n if (onUnpinClick !== undefined) onUnpinClick();\n }}\n sx={{ fontSize: 16, cursor: 'pointer' }}\n />\n ) : (\n <PinOutline sx={{ fontSize: 16 }} />\n )}\n </Stack>\n )}\n </Box>\n <Divider sx={(theme) => ({ width: '100%', borderColor: theme.palette.grey['500'] })} />\n </Box>\n <Box sx={(theme) => ({ padding: theme.spacing(0.5, 2, 1.5, 2) })}>\n {annotation.title && (\n <Typography variant=\"caption\" sx={{ display: 'block', fontWeight: 'bold', marginBottom: 0.5 }}>\n {annotation.title}\n </Typography>\n )}\n {annotation.legend && (\n <Typography variant=\"caption\" sx={{ display: 'block', marginBottom: 0.5 }}>\n {annotation.legend}\n </Typography>\n )}\n {annotation.tags && Object.keys(annotation.tags).length > 0 && (\n <Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 0.5, marginTop: 0.5 }}>\n {Object.entries(annotation.tags).map(([key, value]) => (\n <Box\n key={key}\n sx={(theme) => ({\n backgroundColor: theme.palette.grey['700'],\n borderRadius: '4px',\n padding: '2px 6px',\n fontSize: '0.7rem',\n fontFamily: 'monospace',\n })}\n >\n {key}: {value}\n </Box>\n ))}\n </Box>\n )}\n </Box>\n </Stack>\n </Box>\n </Portal>\n );\n}\n\n/**\n * Build ECharts series options for rendering annotations as markArea (range),\n * markLine (vertical dashed lines) and markPoint (triangle markers under the X-axis).\n */\nexport function buildAnnotationSeries(annotations: TimeSeriesAnnotation[] | undefined): LineSeriesOption[] {\n if (!annotations?.length) return [];\n\n const markAreaData: Array<[{ xAxis: number; itemStyle?: { color: string; opacity: number } }, { xAxis: number }]> =\n [];\n const markLineData: Array<{\n xAxis: number;\n lineStyle?: { color: string; width: number; type: 'dashed' | 'solid' | 'dotted' };\n label?: { show: boolean };\n annotationIndex?: number;\n }> = [];\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const markPointData: any[] = [];\n\n annotations.forEach((annotation, index) => {\n const color = annotation.color ?? DEFAULT_ANNOTATION_COLOR;\n const opacity = 0.3;\n\n if (annotation.end !== undefined) {\n // Range annotation - use markArea and markLine (silent) + markers at start/end\n markLineData.push({\n xAxis: annotation.start,\n lineStyle: { color, width: 2, type: 'dashed' as const },\n label: { show: false },\n annotationIndex: index,\n });\n\n markLineData.push({\n xAxis: annotation.end,\n lineStyle: { color, width: 2, type: 'dashed' as const },\n label: { show: false },\n annotationIndex: index,\n });\n\n markAreaData.push([\n {\n xAxis: annotation.start,\n itemStyle: { color, opacity },\n },\n { xAxis: annotation.end },\n ]);\n\n // Add start and end markers\n for (const isStart of [true, false]) {\n markPointData.push({\n coord: [isStart ? annotation.start : annotation.end, 0],\n symbol: 'triangle',\n symbolSize: [12, 12],\n symbolRotate: 0,\n symbolOffset: [0, 4], // Position below X-axis\n itemStyle: { color },\n annotationIndex: index,\n emphasis: {\n disabled: true,\n },\n isStart: isStart,\n isEnd: !isStart,\n });\n }\n } else {\n // Point annotation - use markLine (silent) + single marker\n markLineData.push({\n xAxis: annotation.start,\n lineStyle: { color, width: 2, type: 'dashed' as const },\n label: { show: false },\n annotationIndex: index,\n });\n\n // Add point marker\n markPointData.push({\n coord: [annotation.start, 0],\n symbol: 'triangle',\n symbolSize: [12, 10],\n symbolRotate: 0,\n symbolOffset: [0, '120%'], // Position below X-axis\n itemStyle: { color },\n annotationIndex: index,\n isPoint: true,\n });\n }\n });\n\n const series: LineSeriesOption = {\n type: 'line',\n data: [],\n silent: false,\n markArea:\n markAreaData.length > 0\n ? {\n silent: true, // Make area silent, only markers are interactive\n data: markAreaData,\n label: {\n show: false,\n },\n }\n : undefined,\n markLine:\n markLineData.length > 0\n ? {\n silent: true, // Non-interactive: hovering the dashed line keeps the TimeSeries tooltip\n symbol: ['none', 'none'],\n data: markLineData,\n lineStyle: {\n type: 'dashed',\n },\n }\n : undefined,\n markPoint:\n markPointData.length > 0\n ? {\n silent: false, // Markers are interactive\n data: markPointData,\n label: {\n show: false,\n },\n }\n : undefined,\n };\n\n return [series];\n}\n"],"names":["Box","Divider","Portal","Stack","Typography","assembleTransform","getDateAndTime","getTooltipStyles","PIN_TOOLTIP_HELP_TEXT","TOOLTIP_BG_COLOR_FALLBACK","TOOLTIP_MAX_WIDTH","UNPIN_TOOLTIP_HELP_TEXT","useMousePosition","DEFAULT_ANNOTATION_COLOR","Pin","PinOutline","useResizeObserver","AnnotationTooltip","annotation","containerId","formatWithUserTimeZone","pinnedPos","enablePinning","onUnpinClick","mousePos","height","width","ref","tooltipRef","isPinned","containerElement","document","querySelector","undefined","maxHeight","getBoundingClientRect","transform","start","end","container","sx","theme","style","spacing","maxWidth","padding","backgroundColor","palette","designSystem","grey","position","top","left","display","alignItems","paddingBottom","borderRadius","color","marginRight","flexShrink","flexGrow","minWidth","variant","formattedDate","strong","formattedTime","direction","marginLeft","fontSize","verticalAlign","onClick","cursor","borderColor","title","fontWeight","marginBottom","legend","tags","Object","keys","length","flexWrap","gap","marginTop","entries","map","key","value","fontFamily","buildAnnotationSeries","annotations","markAreaData","markLineData","markPointData","forEach","index","opacity","push","xAxis","lineStyle","type","label","show","annotationIndex","itemStyle","isStart","coord","symbol","symbolSize","symbolRotate","symbolOffset","emphasis","disabled","isEnd","isPoint","series","data","silent","markArea","markLine","markPoint"],"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,GAAG,EAAEC,OAAO,EAAEC,MAAM,EAAEC,KAAK,EAAEC,UAAU,QAAQ,gBAAgB;AAExE,SACEC,iBAAiB,EACjBC,cAAc,EACdC,gBAAgB,EAChBC,qBAAqB,EACrBC,yBAAyB,EACzBC,iBAAiB,EACjBC,uBAAuB,EACvBC,gBAAgB,QACX,yBAAyB;AAChC,SAASC,wBAAwB,QAAQ,4BAA4B;AAErE,OAAOC,SAAS,sBAAsB;AACtC,OAAOC,gBAAgB,6BAA6B;AACpD,OAAOC,uBAAuB,sBAAsB;AAapD,OAAO,SAASC,kBAAkB,EAChCC,UAAU,EACVC,WAAW,EACXC,sBAAsB,EACtBC,SAAS,EACTC,gBAAgB,IAAI,EACpBC,YAAY,EACW;IACvB,MAAMC,WAAWZ;IACjB,MAAM,EAAEa,MAAM,EAAEC,KAAK,EAAEC,KAAKC,UAAU,EAAE,GAAGZ;IAE3C,MAAMa,WAAWR,cAAc;IAC/B,IAAI,CAACQ,YAAYL,aAAa,MAAM,OAAO;IAE3C,MAAMM,mBAAmBX,cAAcY,SAASC,aAAa,CAACb,eAAec;IAC7E,MAAMC,YAAYJ,mBAAmBA,iBAAiBK,qBAAqB,GAAGV,MAAM,GAAGQ;IACvF,MAAMG,YAAY/B,kB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jB"}
|
|
1
|
+
{"version":3,"sources":["../../../src/annotations/AnnotationTooltip.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 { Box, Divider, Portal, Stack, Typography } from '@mui/material';\nimport type { CursorCoordinates } from '@perses-dev/components';\nimport {\n assembleTransform,\n getDateAndTime,\n getTooltipStyles,\n PIN_TOOLTIP_HELP_TEXT,\n TOOLTIP_BG_COLOR_FALLBACK,\n TOOLTIP_MAX_WIDTH,\n UNPIN_TOOLTIP_HELP_TEXT,\n useMousePosition,\n} from '@perses-dev/components';\nimport { DEFAULT_ANNOTATION_COLOR } from '@perses-dev/plugin-system';\nimport type { LineSeriesOption, MarkPointComponentOption, YAXisComponentOption } from 'echarts';\nimport Pin from 'mdi-material-ui/Pin';\nimport PinOutline from 'mdi-material-ui/PinOutline';\nimport useResizeObserver from 'use-resize-observer';\n\nimport type { TimeSeriesAnnotation } from '../utils/annotation';\n\n// Hidden Y axis to guarantee annotations being shown\nexport const ANNOTATION_Y_AXIS: YAXisComponentOption = {\n type: 'value',\n show: false,\n min: 0,\n max: 1,\n axisLabel: { show: false },\n};\n\nexport interface AnnotationTooltipProps {\n annotation: TimeSeriesAnnotation;\n containerId?: string;\n formatWithUserTimeZone: (date: Date, formatString: string) => string;\n pinnedPos: CursorCoordinates | null;\n enablePinning?: boolean;\n onUnpinClick?: () => void;\n}\n\nexport function AnnotationTooltip({\n annotation,\n containerId,\n formatWithUserTimeZone,\n pinnedPos,\n enablePinning = true,\n onUnpinClick,\n}: AnnotationTooltipProps): JSX.Element | null {\n const mousePos = useMousePosition();\n const { height, width, ref: tooltipRef } = useResizeObserver<HTMLDivElement>();\n\n const isPinned = pinnedPos !== null;\n if (!isPinned && mousePos === null) return null;\n\n const containerElement = containerId ? document.querySelector(containerId) : undefined;\n const maxHeight = containerElement ? containerElement.getBoundingClientRect().height : undefined;\n const transform = assembleTransform(mousePos, pinnedPos, height ?? 0, width ?? 0, containerElement);\n\n const start = getDateAndTime(annotation.start, formatWithUserTimeZone);\n const end = annotation.end !== undefined ? getDateAndTime(annotation.end, formatWithUserTimeZone) : null;\n\n return (\n <Portal container={containerElement}>\n <Box ref={tooltipRef} sx={(theme) => getTooltipStyles(theme, pinnedPos, maxHeight)} style={{ transform }}>\n <Stack spacing={0.5}>\n <Box\n sx={(theme) => ({\n width: '100%',\n maxWidth: TOOLTIP_MAX_WIDTH,\n padding: theme.spacing(1.5, 2, 0.5, 2),\n backgroundColor: theme.palette.designSystem?.grey[800] ?? TOOLTIP_BG_COLOR_FALLBACK,\n position: 'sticky',\n top: 0,\n left: 0,\n })}\n >\n <Box sx={{ display: 'flex', alignItems: 'center', paddingBottom: 0.5, width: '100%' }}>\n <Box\n sx={{\n width: 8,\n height: 8,\n borderRadius: '50%',\n backgroundColor: annotation.color ?? DEFAULT_ANNOTATION_COLOR,\n marginRight: 1,\n flexShrink: 0,\n }}\n />\n <Box sx={{ flexGrow: 1, minWidth: 0 }}>\n <Typography variant=\"caption\">\n {start.formattedDate} - <strong>{start.formattedTime}</strong>\n </Typography>\n {end && (\n <>\n <Typography variant=\"caption\">{' → '}</Typography>\n <Typography variant=\"caption\">\n {end.formattedDate} - <strong>{end.formattedTime}</strong>\n </Typography>\n </>\n )}\n </Box>\n {enablePinning && (\n <Stack direction=\"row\" alignItems=\"center\" sx={{ marginLeft: 1, flexShrink: 0 }}>\n <Typography sx={{ marginRight: 0.5, fontSize: 11, verticalAlign: 'middle' }}>\n {isPinned ? UNPIN_TOOLTIP_HELP_TEXT : PIN_TOOLTIP_HELP_TEXT}\n </Typography>\n {isPinned ? (\n <Pin\n onClick={() => {\n if (onUnpinClick !== undefined) onUnpinClick();\n }}\n sx={{ fontSize: 16, cursor: 'pointer' }}\n />\n ) : (\n <PinOutline sx={{ fontSize: 16 }} />\n )}\n </Stack>\n )}\n </Box>\n <Divider sx={(theme) => ({ width: '100%', borderColor: theme.palette.grey['500'] })} />\n </Box>\n <Box sx={(theme) => ({ padding: theme.spacing(0.5, 2, 1.5, 2) })}>\n {annotation.title && (\n <Typography variant=\"caption\" sx={{ display: 'block', fontWeight: 'bold', marginBottom: 0.5 }}>\n {annotation.title}\n </Typography>\n )}\n {annotation.legend && (\n <Typography variant=\"caption\" sx={{ display: 'block', marginBottom: 0.5 }}>\n {annotation.legend}\n </Typography>\n )}\n {annotation.tags && Object.keys(annotation.tags).length > 0 && (\n <Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 0.5, marginTop: 0.5 }}>\n {Object.entries(annotation.tags).map(([key, value]) => (\n <Box\n key={key}\n sx={(theme) => ({\n backgroundColor: theme.palette.grey['700'],\n borderRadius: '4px',\n padding: '2px 6px',\n fontSize: '0.7rem',\n fontFamily: 'monospace',\n })}\n >\n {key}: {value}\n </Box>\n ))}\n </Box>\n )}\n </Box>\n </Stack>\n </Box>\n </Portal>\n );\n}\n\n/**\n * Build ECharts series options for rendering annotations as markArea (range),\n * markLine (vertical dashed lines) and markPoint (triangle markers under the X-axis).\n */\nexport function buildAnnotationSeries(\n annotations: TimeSeriesAnnotation[] | undefined,\n annotationYAxisIndex: number,\n): LineSeriesOption[] {\n if (!annotations?.length) return [];\n\n const markAreaData: Array<[{ xAxis: number; itemStyle?: { color: string; opacity: number } }, { xAxis: number }]> =\n [];\n const markLineData: Array<{\n xAxis: number;\n lineStyle?: { color: string; width: number; type: 'dashed' | 'solid' | 'dotted' };\n label?: { show: boolean };\n annotationIndex?: number;\n }> = [];\n const markPointData: Array<\n NonNullable<MarkPointComponentOption['data']>[number] & {\n annotationIndex: number;\n isStart?: boolean;\n isEnd?: boolean;\n isPoint?: boolean;\n }\n > = [];\n\n annotations.forEach((annotation, index) => {\n const color = annotation.color ?? DEFAULT_ANNOTATION_COLOR;\n const opacity = 0.3;\n\n if (annotation.end !== undefined) {\n // Range annotation - use markArea and markLine (silent) + markers at start/end\n markLineData.push({\n xAxis: annotation.start,\n lineStyle: { color, width: 2, type: 'dashed' as const },\n label: { show: false },\n annotationIndex: index,\n });\n\n markLineData.push({\n xAxis: annotation.end,\n lineStyle: { color, width: 2, type: 'dashed' as const },\n label: { show: false },\n annotationIndex: index,\n });\n\n markAreaData.push([\n {\n xAxis: annotation.start,\n itemStyle: { color, opacity },\n },\n { xAxis: annotation.end },\n ]);\n\n // Add start and end markers\n for (const isStart of [true, false]) {\n markPointData.push({\n name: '',\n coord: [isStart ? annotation.start : annotation.end, 0],\n symbol: 'triangle',\n symbolSize: [12, 12],\n symbolRotate: 0,\n symbolOffset: [0, 4], // Position below X-axis\n itemStyle: { color },\n annotationIndex: index,\n emphasis: {\n disabled: true,\n },\n isStart: isStart,\n isEnd: !isStart,\n });\n }\n } else {\n // Point annotation - use markLine (silent) + single marker\n markLineData.push({\n xAxis: annotation.start,\n lineStyle: { color, width: 2, type: 'dashed' as const },\n label: { show: false },\n annotationIndex: index,\n });\n\n // Add point marker\n markPointData.push({\n name: '',\n coord: [annotation.start, 0],\n symbol: 'triangle',\n symbolSize: [12, 10],\n symbolRotate: 0,\n symbolOffset: [0, '120%'], // Position below X-axis\n itemStyle: { color },\n annotationIndex: index,\n isPoint: true,\n });\n }\n });\n\n const series: LineSeriesOption = {\n type: 'line',\n data: [],\n yAxisIndex: annotationYAxisIndex,\n silent: false,\n markArea:\n markAreaData.length > 0\n ? {\n silent: true, // Make area silent, only markers are interactive\n data: markAreaData,\n label: {\n show: false,\n },\n }\n : undefined,\n markLine:\n markLineData.length > 0\n ? {\n silent: true, // Non-interactive: hovering the dashed line keeps the TimeSeries tooltip\n symbol: ['none', 'none'],\n data: markLineData,\n lineStyle: {\n type: 'dashed',\n },\n }\n : undefined,\n markPoint:\n markPointData.length > 0\n ? {\n silent: false, // Markers are interactive\n data: markPointData,\n label: {\n show: false,\n },\n }\n : undefined,\n };\n\n return [series];\n}\n"],"names":["Box","Divider","Portal","Stack","Typography","assembleTransform","getDateAndTime","getTooltipStyles","PIN_TOOLTIP_HELP_TEXT","TOOLTIP_BG_COLOR_FALLBACK","TOOLTIP_MAX_WIDTH","UNPIN_TOOLTIP_HELP_TEXT","useMousePosition","DEFAULT_ANNOTATION_COLOR","Pin","PinOutline","useResizeObserver","ANNOTATION_Y_AXIS","type","show","min","max","axisLabel","AnnotationTooltip","annotation","containerId","formatWithUserTimeZone","pinnedPos","enablePinning","onUnpinClick","mousePos","height","width","ref","tooltipRef","isPinned","containerElement","document","querySelector","undefined","maxHeight","getBoundingClientRect","transform","start","end","container","sx","theme","style","spacing","maxWidth","padding","backgroundColor","palette","designSystem","grey","position","top","left","display","alignItems","paddingBottom","borderRadius","color","marginRight","flexShrink","flexGrow","minWidth","variant","formattedDate","strong","formattedTime","direction","marginLeft","fontSize","verticalAlign","onClick","cursor","borderColor","title","fontWeight","marginBottom","legend","tags","Object","keys","length","flexWrap","gap","marginTop","entries","map","key","value","fontFamily","buildAnnotationSeries","annotations","annotationYAxisIndex","markAreaData","markLineData","markPointData","forEach","index","opacity","push","xAxis","lineStyle","label","annotationIndex","itemStyle","isStart","name","coord","symbol","symbolSize","symbolRotate","symbolOffset","emphasis","disabled","isEnd","isPoint","series","data","yAxisIndex","silent","markArea","markLine","markPoint"],"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,GAAG,EAAEC,OAAO,EAAEC,MAAM,EAAEC,KAAK,EAAEC,UAAU,QAAQ,gBAAgB;AAExE,SACEC,iBAAiB,EACjBC,cAAc,EACdC,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BAAkB;gBACtDyF,OAAO;oBAAExF,MAAM;gBAAM;gBACrByF,iBAAiBN;YACnB;YAEA,mBAAmB;YACnBF,cAAcI,IAAI,CAAC;gBACjBO,MAAM;gBACNC,OAAO;oBAACxF,WAAWmB,KAAK;oBAAE;iBAAE;gBAC5BsE,QAAQ;gBACRC,YAAY;oBAAC;oBAAI;iBAAG;gBACpBC,cAAc;gBACdC,cAAc;oBAAC;oBAAG;iBAAO;gBACzBP,WAAW;oBAAE9C;gBAAM;gBACnB6C,iBAAiBN;gBACjBkB,SAAS;YACX;QACF;IACF;IAEA,MAAMC,SAA2B;QAC/BvG,MAAM;QACNwG,MAAM,EAAE;QACRC,YAAY1B;QACZ2B,QAAQ;QACRC,UACE3B,aAAaZ,MAAM,GAAG,IAClB;YACEsC,QAAQ;YACRF,MAAMxB;YACNS,OAAO;gBACLxF,MAAM;YACR;QACF,IACAoB;QACNuF,UACE3B,aAAab,MAAM,GAAG,IAClB;YACEsC,QAAQ;YACRX,QAAQ;gBAAC;gBAAQ;aAAO;YACxBS,MAAMvB;YACNO,WAAW;gBACTxF,MAAM;YACR;QACF,IACAqB;QACNwF,WACE3B,cAAcd,MAAM,GAAG,IACnB;YACEsC,QAAQ;YACRF,MAAMtB;YACNO,OAAO;gBACLxF,MAAM;YACR;QACF,IACAoB;IACR;IAEA,OAAO;QAACkF;KAAO;AACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorSwatches.d.ts","sourceRoot":"","sources":["../../../src/components/ColorSwatches.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE1C,wBAAgB,aAAa,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAAG,YAAY,CAiBrF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// Copyright The Perses Authors
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
import { Box } from "@mui/material";
|
|
15
|
+
export function ColorSwatches({ colors }) {
|
|
16
|
+
return /*#__PURE__*/ _jsx(Box, {
|
|
17
|
+
sx: {
|
|
18
|
+
display: 'flex',
|
|
19
|
+
gap: '3px',
|
|
20
|
+
flexWrap: 'wrap',
|
|
21
|
+
p: '4px 2px'
|
|
22
|
+
},
|
|
23
|
+
children: colors.map((color, i)=>/*#__PURE__*/ _jsx(Box, {
|
|
24
|
+
sx: {
|
|
25
|
+
width: 14,
|
|
26
|
+
height: 14,
|
|
27
|
+
borderRadius: '2px',
|
|
28
|
+
backgroundColor: color,
|
|
29
|
+
flexShrink: 0
|
|
30
|
+
}
|
|
31
|
+
}, i))
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=ColorSwatches.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/ColorSwatches.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 { Box } from '@mui/material';\nimport type { ReactElement } from 'react';\n\nexport function ColorSwatches({ colors }: { colors: readonly string[] }): ReactElement {\n return (\n <Box sx={{ display: 'flex', gap: '3px', flexWrap: 'wrap', p: '4px 2px' }}>\n {colors.map((color, i) => (\n <Box\n key={i}\n sx={{\n width: 14,\n height: 14,\n borderRadius: '2px',\n backgroundColor: color,\n flexShrink: 0,\n }}\n />\n ))}\n </Box>\n );\n}\n"],"names":["Box","ColorSwatches","colors","sx","display","gap","flexWrap","p","map","color","i","width","height","borderRadius","backgroundColor","flexShrink"],"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,GAAG,QAAQ,gBAAgB;AAGpC,OAAO,SAASC,cAAc,EAAEC,MAAM,EAAiC;IACrE,qBACE,KAACF;QAAIG,IAAI;YAAEC,SAAS;YAAQC,KAAK;YAAOC,UAAU;YAAQC,GAAG;QAAU;kBACpEL,OAAOM,GAAG,CAAC,CAACC,OAAOC,kBAClB,KAACV;gBAECG,IAAI;oBACFQ,OAAO;oBACPC,QAAQ;oBACRC,cAAc;oBACdC,iBAAiBL;oBACjBM,YAAY;gBACd;eAPKL;;AAYf"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { TimeSeriesChartPaletteOptions } from '../time-series-chart-model';
|
|
3
|
+
export interface PaletteSelectorProps {
|
|
4
|
+
value: TimeSeriesChartPaletteOptions | undefined;
|
|
5
|
+
onChange: (palette: TimeSeriesChartPaletteOptions | undefined) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function PaletteSelector({ value, onChange }: PaletteSelectorProps): ReactElement;
|
|
8
|
+
//# sourceMappingURL=PaletteSelector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PaletteSelector.d.ts","sourceRoot":"","sources":["../../../src/components/PaletteSelector.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,YAAY,EAAkB,MAAM,OAAO,CAAC;AAG1D,OAAO,KAAK,EAA0B,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAexG,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,6BAA6B,GAAG,SAAS,CAAC;IACjD,QAAQ,EAAE,CAAC,OAAO,EAAE,6BAA6B,GAAG,SAAS,KAAK,IAAI,CAAC;CACxE;AAED,wBAAgB,eAAe,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,oBAAoB,GAAG,YAAY,CAuEvF"}
|