@perses-dev/timeseries-chart-plugin 0.13.0 → 0.14.0-beta.2
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.b9caac04.js +7 -0
- package/__mf/js/async/121.fde1320e.js +2 -0
- package/__mf/js/async/{527.f97d1b86.js → 182.9e1e293f.js} +9 -9
- package/__mf/js/async/192.66c6659d.js +1 -0
- package/__mf/js/async/2.166bda4f.js +1 -0
- package/__mf/js/async/235.76fd7af2.js +1 -0
- package/__mf/js/async/274.e4ed32f7.js +2 -0
- package/__mf/js/async/319.8e262f9c.js +1 -0
- package/__mf/js/async/356.52455d93.js +1 -0
- package/__mf/js/async/384.f40367cc.js +1 -0
- package/__mf/js/async/392.8cb3dcaa.js +2 -0
- package/__mf/js/async/463.f5dc7759.js +7 -0
- package/__mf/js/async/{694.0fb9ee5a.js.LICENSE.txt → 463.f5dc7759.js.LICENSE.txt} +41 -1
- package/__mf/js/async/465.add3260a.js +1 -0
- package/__mf/js/async/470.beedcbcc.js +2 -0
- package/__mf/js/async/522.806db24f.js +22 -0
- package/__mf/js/async/525.8b92c616.js +37 -0
- package/__mf/js/async/587.828c454a.js +1 -0
- package/__mf/js/async/597.0c5bd6dd.js +2 -0
- package/__mf/js/async/612.b2f31132.js +3 -0
- package/__mf/js/async/616.804d525d.js +1 -0
- package/__mf/js/async/663.892b9ad5.js +1 -0
- package/__mf/js/async/700.25c7e5dd.js +1 -0
- package/__mf/js/async/724.f74ffa12.js +1 -0
- package/__mf/js/async/730.058dea58.js +2 -0
- package/__mf/js/async/865.cb917066.js +2 -0
- package/__mf/js/async/941.3bb54150.js +2 -0
- package/__mf/js/async/955.52ca0671.js +1 -0
- package/__mf/js/async/968.2dd830b3.js +1 -0
- package/__mf/js/async/__federation_expose_TimeSeriesChart.4ddb01e0.js +1 -0
- package/__mf/js/async/lib-router.ecb51f08.js +2 -0
- package/__mf/js/main.f55169be.js +7 -0
- package/lib/GeneralSettingsEditor.d.ts +2 -2
- package/lib/GeneralSettingsEditor.d.ts.map +1 -1
- package/lib/GeneralSettingsEditor.js +7 -7
- package/lib/GeneralSettingsEditor.js.map +1 -1
- package/lib/QuerySettingsEditor.d.ts +2 -2
- package/lib/QuerySettingsEditor.d.ts.map +1 -1
- package/lib/QuerySettingsEditor.js +11 -11
- package/lib/QuerySettingsEditor.js.map +1 -1
- package/lib/TimeSeriesChart.d.ts +3 -3
- package/lib/TimeSeriesChart.d.ts.map +1 -1
- package/lib/TimeSeriesChart.js +6 -5
- package/lib/TimeSeriesChart.js.map +1 -1
- package/lib/TimeSeriesChartBase.d.ts +4 -4
- package/lib/TimeSeriesChartBase.d.ts.map +1 -1
- package/lib/TimeSeriesChartBase.js +12 -12
- package/lib/TimeSeriesChartBase.js.map +1 -1
- package/lib/TimeSeriesChartPanel.d.ts +4 -4
- package/lib/TimeSeriesChartPanel.d.ts.map +1 -1
- package/lib/TimeSeriesChartPanel.js +12 -12
- package/lib/TimeSeriesChartPanel.js.map +1 -1
- package/lib/TimeSeriesExportAction.d.ts +1 -1
- package/lib/TimeSeriesExportAction.d.ts.map +1 -1
- package/lib/TimeSeriesExportAction.js +5 -5
- package/lib/TimeSeriesExportAction.js.map +1 -1
- package/lib/VisualOptionsEditor.d.ts +2 -2
- package/lib/VisualOptionsEditor.d.ts.map +1 -1
- package/lib/VisualOptionsEditor.js +4 -4
- package/lib/VisualOptionsEditor.js.map +1 -1
- package/lib/YAxisOptionsEditor.d.ts +2 -2
- package/lib/YAxisOptionsEditor.d.ts.map +1 -1
- package/lib/YAxisOptionsEditor.js +3 -3
- package/lib/YAxisOptionsEditor.js.map +1 -1
- package/lib/annotations/AnnotationTooltip.d.ts +2 -2
- package/lib/annotations/AnnotationTooltip.d.ts.map +1 -1
- package/lib/annotations/AnnotationTooltip.js +6 -6
- package/lib/annotations/AnnotationTooltip.js.map +1 -1
- package/lib/bootstrap.js +2 -2
- package/lib/getPluginModule.d.ts +1 -1
- package/lib/getPluginModule.d.ts.map +1 -1
- package/lib/getPluginModule.js +3 -1
- package/lib/getPluginModule.js.map +1 -1
- package/lib/index-federation.js +1 -1
- package/lib/index.js +9 -9
- package/lib/index.js.map +1 -1
- package/lib/setup-tests.d.ts +1 -1
- package/lib/setup-tests.d.ts.map +1 -1
- package/lib/setup-tests.js +2 -2
- package/lib/setup-tests.js.map +1 -1
- package/lib/test/mock-query-results.d.ts +1 -1
- package/lib/test/mock-query-results.d.ts.map +1 -1
- package/lib/test/mock-query-results.js.map +1 -1
- package/lib/time-series-chart-model.d.ts +3 -3
- package/lib/time-series-chart-model.d.ts.map +1 -1
- package/lib/time-series-chart-model.js.map +1 -1
- package/lib/utils/annotation.d.ts +2 -2
- package/lib/utils/annotation.d.ts.map +1 -1
- package/lib/utils/annotation.js.map +1 -1
- package/lib/utils/data-transform.d.ts +5 -5
- package/lib/utils/data-transform.d.ts.map +1 -1
- package/lib/utils/data-transform.js +3 -3
- package/lib/utils/data-transform.js.map +1 -1
- package/lib/utils/palette-gen.d.ts +1 -1
- package/lib/utils/palette-gen.d.ts.map +1 -1
- package/lib/utils/palette-gen.js +1 -1
- package/lib/utils/palette-gen.js.map +1 -1
- package/lib/utils/palette.js +1 -1
- package/lib/utils/palette.js.map +1 -1
- package/lib/utils/timezone-formatter.js +1 -1
- package/mf-manifest.json +37 -81
- package/mf-stats.json +39 -91
- package/package.json +11 -11
- package/__mf/js/TimeSeriesChart.42841bce.js +0 -7
- package/__mf/js/async/121.c3c0e54f.js +0 -2
- package/__mf/js/async/177.2fef2962.js +0 -1
- package/__mf/js/async/187.f5e8932b.js +0 -1
- package/__mf/js/async/192.c3dd56d5.js +0 -1
- package/__mf/js/async/2.60fa4a40.js +0 -1
- package/__mf/js/async/208.b9f374ad.js +0 -7
- package/__mf/js/async/208.b9f374ad.js.LICENSE.txt +0 -39
- package/__mf/js/async/235.d23c8ef0.js +0 -1
- package/__mf/js/async/274.72dfa9c8.js +0 -2
- package/__mf/js/async/356.8170c96d.js +0 -1
- package/__mf/js/async/392.b9ba5bf2.js +0 -2
- package/__mf/js/async/470.e09f33b7.js +0 -2
- package/__mf/js/async/491.85194549.js +0 -1
- package/__mf/js/async/518.2ac1df43.js +0 -38
- package/__mf/js/async/52.0d78de2b.js +0 -1
- package/__mf/js/async/546.5fecffa4.js +0 -3
- package/__mf/js/async/568.45da2c30.js +0 -1
- package/__mf/js/async/587.c9460696.js +0 -1
- package/__mf/js/async/588.0a1aa144.js +0 -1
- package/__mf/js/async/603.3b771310.js +0 -2
- package/__mf/js/async/616.79484ac8.js +0 -1
- package/__mf/js/async/655.2f794f77.js +0 -1
- package/__mf/js/async/694.0fb9ee5a.js +0 -2
- package/__mf/js/async/702.785cd635.js +0 -2
- package/__mf/js/async/71.8c6cf914.js +0 -1
- package/__mf/js/async/724.c45dcf5b.js +0 -1
- package/__mf/js/async/873.04a201bf.js +0 -1
- package/__mf/js/async/941.b89f8595.js +0 -2
- package/__mf/js/async/955.176fe200.js +0 -1
- package/__mf/js/async/968.2a9fb1a0.js +0 -1
- package/__mf/js/async/978.a9865b23.js +0 -1
- package/__mf/js/async/984.83bd5c6d.js +0 -22
- package/__mf/js/async/__federation_expose_TimeSeriesChart.0ab11cd4.js +0 -1
- package/__mf/js/async/lib-router.319c02cd.js +0 -2
- package/__mf/js/main.691eecd6.js +0 -7
- package/lib/cjs/GeneralSettingsEditor.js +0 -103
- package/lib/cjs/QuerySettingsEditor.js +0 -666
- package/lib/cjs/TimeSeriesChart.js +0 -50
- package/lib/cjs/TimeSeriesChartBase.js +0 -488
- package/lib/cjs/TimeSeriesChartPanel.js +0 -456
- package/lib/cjs/TimeSeriesExportAction.js +0 -124
- package/lib/cjs/VisualOptionsEditor.js +0 -161
- package/lib/cjs/YAxisOptionsEditor.js +0 -118
- package/lib/cjs/annotations/AnnotationTooltip.js +0 -370
- package/lib/cjs/bootstrap.js +0 -26
- package/lib/cjs/env.d.js +0 -14
- package/lib/cjs/getPluginModule.js +0 -39
- package/lib/cjs/index-federation.js +0 -55
- package/lib/cjs/index.js +0 -44
- package/lib/cjs/setup-tests.js +0 -19
- package/lib/cjs/test/mock-query-results.js +0 -403
- package/lib/cjs/time-series-chart-model.js +0 -225
- package/lib/cjs/utils/annotation.js +0 -37
- package/lib/cjs/utils/data-transform.js +0 -243
- package/lib/cjs/utils/palette-gen.js +0 -75
- package/lib/cjs/utils/palette.js +0 -83
- package/lib/cjs/utils/timezone-formatter.js +0 -48
- /package/__mf/css/async/{208.85c2cbf6.css → 463.85c2cbf6.css} +0 -0
- /package/__mf/js/async/{121.c3c0e54f.js.LICENSE.txt → 121.fde1320e.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{527.f97d1b86.js.LICENSE.txt → 182.9e1e293f.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{274.72dfa9c8.js.LICENSE.txt → 274.e4ed32f7.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{392.b9ba5bf2.js.LICENSE.txt → 392.8cb3dcaa.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{470.e09f33b7.js.LICENSE.txt → 470.beedcbcc.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{984.83bd5c6d.js.LICENSE.txt → 522.806db24f.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{603.3b771310.js.LICENSE.txt → 597.0c5bd6dd.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{702.785cd635.js.LICENSE.txt → 865.cb917066.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{941.b89f8595.js.LICENSE.txt → 941.3bb54150.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{lib-router.319c02cd.js.LICENSE.txt → lib-router.ecb51f08.js.LICENSE.txt} +0 -0
|
@@ -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 { ReactElement, useMemo, useRef, useState } from 'react';\nimport { Box, useTheme } from '@mui/material';\nimport type { GridComponentOption } from 'echarts';\nimport merge from 'lodash/merge';\nimport {\n LEGEND_VALUE_CONFIG,\n PanelProps,\n useTimeRange,\n validateLegendSpec,\n legendValues,\n getCalculations,\n CalculationType,\n} from '@perses-dev/plugin-system';\nimport {\n ChartInstance,\n YAxisLabel,\n ZoomEventData,\n useChartsTheme,\n SelectedLegendItemState,\n ContentWithLegend,\n TableColumnConfig,\n LegendItem,\n LegendProps,\n useId,\n TooltipConfig,\n DEFAULT_TOOLTIP_CONFIG,\n TimeChartSeriesMapping,\n getFormattedMultipleYAxes,\n DEFAULT_LEGEND,\n StepOptions,\n formatValue,\n getTimeSeriesValues,\n} from '@perses-dev/components';\nimport { TimeSeries, TimeSeriesData, TimeSeriesValueTuple } from '@perses-dev/spec';\nimport { useAnnotationsWithData } from '@perses-dev/dashboards';\nimport {\n TimeSeriesChartOptions,\n DEFAULT_FORMAT,\n DEFAULT_VISUAL,\n THRESHOLD_PLOT_INTERVAL,\n QuerySettingsOptions,\n} from './time-series-chart-model';\nimport {\n getTimeSeries,\n getCommonTimeScaleForQueries,\n convertPanelYAxis,\n getThresholdSeries,\n convertPercentThreshold,\n} from './utils/data-transform';\nimport { getSeriesColor } from './utils/palette-gen';\nimport { TimeSeriesChartBase } from './TimeSeriesChartBase';\nimport { convertAnnotationToTimeSeriesAnnotation, TimeSeriesAnnotation } from './utils/annotation';\n\nexport type TimeSeriesChartProps = PanelProps<TimeSeriesChartOptions, TimeSeriesData>;\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\nexport function TimeSeriesChartPanel(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, seriesFormatMap } = useMemo(() => {\n const baseUnit = format?.unit ?? 'decimal';\n const additionalFormats: Array<typeof format> = [];\n const formatToYAxisIndex = new Map<string, number>();\n const seriesFormatMap = new Map<string, typeof format>();\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, seriesFormatMap };\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 = useAnnotationsWithData();\n\n const annotations: TimeSeriesAnnotation[] = useMemo(\n () => convertAnnotationToTimeSeriesAnnotation(annotationsWithData),\n [annotationsWithData]\n );\n\n // Populate series data based on query results\n const {\n timeScale,\n timeChartData,\n timeSeriesMapping,\n legendItems,\n seriesFormatMap: computedSeriesFormatMap,\n maxValuesByFormat,\n } = useMemo(() => {\n const timeScale = getCommonTimeScaleForQueries(queryResults);\n if (timeScale === undefined) {\n return {\n timeChartData: [],\n timeSeriesMapping: [],\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\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 // Mapping of each set of query results to be ECharts option compatible\n // TODO: Look into performance optimizations and moving parts of mapping to the lower level chart\n for (let queryIndex = 0; queryIndex < queryResults.length; queryIndex++) {\n const result = queryResults[queryIndex];\n\n // Retrieve querySettings for this query, if exists.\n // queries & querySettings indices do not necessarily match, so we have to check the tail value of the $ref attribute\n let querySettings: QuerySettingsOptions | undefined;\n for (const item of querySettingsList ?? []) {\n if (item.queryIndex === queryIndex) {\n querySettings = item;\n // We don't break the loop here just in case there are multiple querySettings defined for the\n // same queryIndex, because in that case we want the last one to take precedence.\n }\n }\n\n if (result) {\n for (let i = 0; i < result.data.series.length; i++) {\n const timeSeries: TimeSeries | undefined = result.data.series[i];\n if (timeSeries === undefined) {\n return { timeChartData: [], timeSeriesMapping: [], legendItems: [] };\n }\n\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: (queryResults[queryIndex]?.data?.series?.length ?? 0) > 1,\n });\n\n // We add a unique id for the chart to disambiguate items across charts\n // when there are multiple on the page.\n const seriesId = chartId + timeSeries.name + seriesIndex;\n\n const legendCalculations = legend?.values\n ? getCalculations(timeSeries.values, legend.values as CalculationType[])\n : undefined;\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 )\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 seriesMax = Math.max(...timeSeries.values.map((v) => Math.abs(v[1] ?? 0)));\n const currentMax = maxValuesByFormat.get(unitKey) ?? 0;\n if (seriesMax > currentMax) {\n maxValuesByFormat.set(unitKey, seriesMax);\n }\n }\n }\n\n // When negativeY is set on this query, negate the rendered values so the\n // series renders below the X axis. The original (positive) values are\n // preserved in `timeSeries.values` (used for legend calculations) and in\n // `queryResults` (used for CSV export).\n const baseValues: TimeSeriesValueTuple[] = getTimeSeriesValues(timeSeries, timeScale);\n const renderedValues: TimeSeriesValueTuple[] = querySettings?.negativeY\n ? baseValues.map((tuple: TimeSeriesValueTuple): TimeSeriesValueTuple => {\n const [t, v] = tuple;\n return [t, v === null ? null : -v];\n })\n : baseValues;\n\n timeChartData.push({\n name: formattedSeriesName,\n values: renderedValues,\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: legendCalculations,\n });\n }\n\n // Used for repeating colors in Categorical palette\n seriesIndex++;\n }\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 queryResults,\n thresholds,\n selectedLegendItems,\n legend,\n visual,\n querySettingsList,\n yAxis?.max,\n yAxis?.min,\n categoricalPalette,\n chartId,\n chartsTheme.thresholds,\n muiTheme.palette.primary.main,\n formatToYAxisIndex,\n seriesFormatMap,\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 if (adjustedContentDimensions === undefined) {\n return null;\n }\n\n const handleDataZoom = (event: ZoomEventData): void => {\n // TODO: add ECharts transition animation on zoom\n setTimeRange({ start: new Date(event.start), end: new Date(event.end) });\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 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"],"names":["useMemo","useRef","useState","Box","useTheme","merge","LEGEND_VALUE_CONFIG","useTimeRange","validateLegendSpec","legendValues","getCalculations","YAxisLabel","useChartsTheme","ContentWithLegend","useId","DEFAULT_TOOLTIP_CONFIG","getFormattedMultipleYAxes","DEFAULT_LEGEND","formatValue","getTimeSeriesValues","useAnnotationsWithData","DEFAULT_FORMAT","DEFAULT_VISUAL","THRESHOLD_PLOT_INTERVAL","getTimeSeries","getCommonTimeScaleForQueries","convertPanelYAxis","getThresholdSeries","convertPercentThreshold","getSeriesColor","TimeSeriesChartBase","convertAnnotationToTimeSeriesAnnotation","TimeSeriesChartPanel","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","seriesFormatMap","baseUnit","unit","Map","set","qs","unitKey","has","length","push","selectedLegendItems","setSelectedLegendItems","legendSorting","setLegendSorting","setTimeRange","annotationsWithData","annotations","timeScale","timeChartData","timeSeriesMapping","legendItems","computedSeriesFormatMap","maxValuesByFormat","seriesIndex","queryIndex","result","item","i","data","series","timeSeries","formattedSeriesName","formattedName","name","seriesColor","muiPrimaryColor","palette","primary","main","seriesName","queryHasMultipleResults","seriesId","legendCalculations","values","isSelectAll","isSelected","showTimeSeries","datasetIndex","queryFormat","yAxisIndex","get","seriesMax","Math","max","map","v","abs","currentMax","baseValues","renderedValues","negativeY","tuple","t","id","label","steps","thresholdsColors","defaultThresholdColor","defaultColor","forEach","step","index","stepPaletteColor","thresholdLineColor","stepOption","value","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"],"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,SAAuBA,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAChE,SAASC,GAAG,EAAEC,QAAQ,QAAQ,gBAAgB;AAE9C,OAAOC,WAAW,eAAe;AACjC,SACEC,mBAAmB,EAEnBC,YAAY,EACZC,kBAAkB,EAClBC,YAAY,EACZC,eAAe,QAEV,4BAA4B;AACnC,SAEEC,UAAU,EAEVC,cAAc,EAEdC,iBAAiB,EAIjBC,KAAK,EAELC,sBAAsB,EAEtBC,yBAAyB,EACzBC,cAAc,EAEdC,WAAW,EACXC,mBAAmB,QACd,yBAAyB;AAEhC,SAASC,sBAAsB,QAAQ,yBAAyB;AAChE,SAEEC,cAAc,EACdC,cAAc,EACdC,uBAAuB,QAElB,4BAA4B;AACnC,SACEC,aAAa,EACbC,4BAA4B,EAC5BC,iBAAiB,EACjBC,kBAAkB,EAClBC,uBAAuB,QAClB,yBAAyB;AAChC,SAASC,cAAc,QAAQ,sBAAsB;AACrD,SAASC,mBAAmB,QAAQ,wBAAwB;AAC5D,SAASC,uCAAuC,QAA8B,qBAAqB;AAInG,8EA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H,aAAaA;4BACbC,WAAWA;4BACX5C,OAAO8G,iBAAiBtF;4BACxBF,QAAQA;4BACRK,iBAAiBqB;4BACjBwH,MAAMvC;4BACNW,cAAcA;4BACdO,eAAeA;4BACfsB,WAAU;4BACVC,YAAYnC;4BACZ,sFAAsF;4BACtF,mDAAmD;4BACnDoC,eAAe,CAAC9H,cAAcV,MAAM,IAAIY,eAAeA,YAAYZ,MAAM,GAAG,IAAI,UAAU;;;;YAIlG;;;AAIR"}
|
|
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 { TimeSeries, TimeSeriesData, TimeSeriesValueTuple } from '@perses-dev/spec';\nimport type { GridComponentOption } from 'echarts';\nimport merge from 'lodash/merge';\nimport type { ReactElement } from 'react';\nimport { useMemo, useRef, useState } from 'react';\n\nimport type { TimeSeriesChartOptions, QuerySettingsOptions } 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 {\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// 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\nexport function TimeSeriesChartPanel(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, seriesFormatMap } = useMemo(() => {\n const baseUnit = format?.unit ?? 'decimal';\n const additionalFormats: Array<typeof format> = [];\n const formatToYAxisIndex = new Map<string, number>();\n const seriesFormatMap = new Map<string, typeof format>();\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, seriesFormatMap };\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 // Populate series data based on query results\n const {\n timeScale,\n timeChartData,\n timeSeriesMapping,\n legendItems,\n seriesFormatMap: computedSeriesFormatMap,\n maxValuesByFormat,\n } = useMemo(() => {\n const timeScale = getCommonTimeScaleForQueries(queryResults);\n if (timeScale === undefined) {\n return {\n timeChartData: [],\n timeSeriesMapping: [],\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\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 // Mapping of each set of query results to be ECharts option compatible\n // TODO: Look into performance optimizations and moving parts of mapping to the lower level chart\n for (let queryIndex = 0; queryIndex < queryResults.length; queryIndex++) {\n const result = queryResults[queryIndex];\n\n // Retrieve querySettings for this query, if exists.\n // queries & querySettings indices do not necessarily match, so we have to check the tail value of the $ref attribute\n let querySettings: QuerySettingsOptions | undefined;\n for (const item of querySettingsList ?? []) {\n if (item.queryIndex === queryIndex) {\n querySettings = item;\n // We don't break the loop here just in case there are multiple querySettings defined for the\n // same queryIndex, because in that case we want the last one to take precedence.\n }\n }\n\n if (result) {\n for (let i = 0; i < result.data.series.length; i++) {\n const timeSeries: TimeSeries | undefined = result.data.series[i];\n if (timeSeries === undefined) {\n return { timeChartData: [], timeSeriesMapping: [], legendItems: [] };\n }\n\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: (queryResults[queryIndex]?.data?.series?.length ?? 0) > 1,\n });\n\n // We add a unique id for the chart to disambiguate items across charts\n // when there are multiple on the page.\n const seriesId = chartId + timeSeries.name + seriesIndex;\n\n const legendCalculations = legend?.values\n ? getCalculations(timeSeries.values, legend.values as CalculationType[])\n : undefined;\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 ),\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 seriesMax = Math.max(...timeSeries.values.map((v) => Math.abs(v[1] ?? 0)));\n const currentMax = maxValuesByFormat.get(unitKey) ?? 0;\n if (seriesMax > currentMax) {\n maxValuesByFormat.set(unitKey, seriesMax);\n }\n }\n }\n\n // When negativeY is set on this query, negate the rendered values so the\n // series renders below the X axis. The original (positive) values are\n // preserved in `timeSeries.values` (used for legend calculations) and in\n // `queryResults` (used for CSV export).\n const baseValues: TimeSeriesValueTuple[] = getTimeSeriesValues(timeSeries, timeScale);\n const renderedValues: TimeSeriesValueTuple[] = querySettings?.negativeY\n ? baseValues.map((tuple: TimeSeriesValueTuple): TimeSeriesValueTuple => {\n const [t, v] = tuple;\n return [t, v === null ? null : -v];\n })\n : baseValues;\n\n timeChartData.push({\n name: formattedSeriesName,\n values: renderedValues,\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: legendCalculations,\n });\n }\n\n // Used for repeating colors in Categorical palette\n seriesIndex++;\n }\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 queryResults,\n thresholds,\n selectedLegendItems,\n legend,\n visual,\n querySettingsList,\n yAxis?.max,\n yAxis?.min,\n categoricalPalette,\n chartId,\n chartsTheme.thresholds,\n muiTheme.palette.primary.main,\n formatToYAxisIndex,\n seriesFormatMap,\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 if (adjustedContentDimensions === undefined) {\n return null;\n }\n\n const handleDataZoom = (event: ZoomEventData): void => {\n // TODO: add ECharts transition animation on zoom\n setTimeRange({ start: new Date(event.start), end: new Date(event.end) });\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 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"],"names":["Box","useTheme","YAxisLabel","useChartsTheme","ContentWithLegend","useId","DEFAULT_TOOLTIP_CONFIG","getFormattedMultipleYAxes","DEFAULT_LEGEND","formatValue","getTimeSeriesValues","usePanelAnnotationsWithData","LEGEND_VALUE_CONFIG","useTimeRange","validateLegendSpec","legendValues","getCalculations","merge","useMemo","useRef","useState","DEFAULT_FORMAT","DEFAULT_VISUAL","THRESHOLD_PLOT_INTERVAL","TimeSeriesChartBase","convertAnnotationToTimeSeriesAnnotation","getTimeSeries","getCommonTimeScaleForQueries","convertPanelYAxis","getThresholdSeries","convertPercentThreshold","getSeriesColor","TimeSeriesChartPanel","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","seriesFormatMap","baseUnit","unit","Map","set","qs","unitKey","has","length","push","selectedLegendItems","setSelectedLegendItems","legendSorting","setLegendSorting","setTimeRange","annotationsWithData","definition","annotations","timeScale","timeChartData","timeSeriesMapping","legendItems","computedSeriesFormatMap","maxValuesByFormat","seriesIndex","queryIndex","result","item","i","data","series","timeSeries","formattedSeriesName","formattedName","name","seriesColor","muiPrimaryColor","palette","primary","main","seriesName","queryHasMultipleResults","seriesId","legendCalculations","values","isSelectAll","isSelected","showTimeSeries","datasetIndex","queryFormat","yAxisIndex","get","seriesMax","Math","max","map","v","abs","currentMax","baseValues","renderedValues","negativeY","tuple","t","id","label","steps","thresholdsColors","defaultThresholdColor","defaultColor","forEach","step","index","stepPaletteColor","thresholdLineColor","stepOption","value","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"],"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,EACt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;gBACfuH,uBAAuBtH;gBACvBuH,YAAY;oBACVzC,SAASF;oBACT4C,SAASvH;oBACTwH,iBAAiBvH;gBACnB;gBACAwH,iBAAiB,CAACC,GAAG,EAAEtE,EAAE,EAAE;oBACzBlF,SAASyJ,OAAO,EAAEC,gBAAgB;wBAAEtG,MAAM8B;oBAAG;gBAC/C;gBACAyE,gBAAgB;oBACd3J,SAASyJ,OAAO,EAAEG;gBACpB;YACF;sBAGD,CAAC,EAAElJ,MAAM,EAAED,KAAK,EAAE;gBACjB,qBACE,MAACtD;oBAAI0M,OAAO;wBAAEnJ;wBAAQD;oBAAM;;wBACzBlB,SAASA,MAAMmI,IAAI,IAAInI,MAAM4F,KAAK,kBAAI,KAAC9H;4BAAW+F,MAAM7D,MAAM4F,KAAK;4BAAEzE,QAAQA;;sCAC9E,KAAC/B;4BACCmL,KAAK9J;4BACLU,QAAQA;4BACRqC,MAAMV;4BACN0H,eAAezH;4BACfH,aAAaA;4BACbC,WAAWA;4BACX7C,OAAO+G,iBAAiBvF;4BACxBF,QAAQA;4BACRK,iBAAiBsB;4BACjBwH,MAAMvC;4BACNW,cAAcA;4BACdO,eAAeA;4BACfsB,WAAU;4BACVC,YAAYnC;4BACZ,sFAAsF;4BACtF,mDAAmD;4BACnDoC,eAAe,CAAC9H,cAAcX,MAAM,IAAIa,eAAeA,YAAYb,MAAM,GAAG,IAAI,UAAU;;;;YAIlG;;;AAIR"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { TimeSeriesChartProps } from './TimeSeriesChartPanel';
|
|
2
|
+
import type { TimeSeriesChartProps } from './TimeSeriesChartPanel';
|
|
3
3
|
export declare const TimeSeriesExportAction: React.FC<TimeSeriesChartProps>;
|
|
4
4
|
//# sourceMappingURL=TimeSeriesExportAction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeSeriesExportAction.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesExportAction.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TimeSeriesExportAction.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesExportAction.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAA+B,MAAM,OAAO,CAAC;AAEpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAEnE,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA6CjE,CAAC"}
|
|
@@ -11,11 +11,11 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
import { IconButton } from
|
|
15
|
-
import { InfoTooltip } from
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
14
|
+
import { IconButton } from "@mui/material";
|
|
15
|
+
import { InfoTooltip } from "@perses-dev/components";
|
|
16
|
+
import { exportDataAsCSV, extractExportableData, isExportableData, sanitizeFilename } from "@perses-dev/plugin-system";
|
|
17
|
+
import DownloadIcon from "mdi-material-ui/Download";
|
|
18
|
+
import React, { useCallback, useMemo } from "react";
|
|
19
19
|
export const TimeSeriesExportAction = ({ queryResults, definition })=>{
|
|
20
20
|
const exportableData = useMemo(()=>{
|
|
21
21
|
return extractExportableData(queryResults);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/TimeSeriesExportAction.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 { IconButton } from '@mui/material';\nimport { InfoTooltip } from '@perses-dev/components';\nimport DownloadIcon from 'mdi-material-ui/Download';\nimport React, { useCallback, useMemo } from 'react';\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/TimeSeriesExportAction.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 { IconButton } from '@mui/material';\nimport { InfoTooltip } from '@perses-dev/components';\nimport { exportDataAsCSV, extractExportableData, isExportableData, sanitizeFilename } from '@perses-dev/plugin-system';\nimport DownloadIcon from 'mdi-material-ui/Download';\nimport React, { useCallback, useMemo } from 'react';\n\nimport type { TimeSeriesChartProps } from './TimeSeriesChartPanel';\n\nexport const TimeSeriesExportAction: React.FC<TimeSeriesChartProps> = ({ queryResults, definition }) => {\n const exportableData = useMemo(() => {\n return extractExportableData(queryResults);\n }, [queryResults]);\n\n const canExport = useMemo(() => {\n return isExportableData(exportableData);\n }, [exportableData]);\n\n const handleExport = useCallback(() => {\n if (!exportableData || !canExport) return;\n\n try {\n const title = definition?.spec?.display?.name || 'Time Series Data';\n\n const csvBlob = exportDataAsCSV({\n data: exportableData,\n });\n\n const baseFilename = sanitizeFilename(title);\n const filename = `${baseFilename}_data.csv`;\n\n const link = document.createElement('a');\n link.href = URL.createObjectURL(csvBlob);\n link.download = filename;\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n URL.revokeObjectURL(link.href);\n } catch (error) {\n console.error('Time series export failed:', error);\n }\n }, [exportableData, canExport, definition]);\n\n if (!canExport) {\n return null;\n }\n\n return (\n <InfoTooltip description=\"Export as CSV\">\n <IconButton size=\"small\" onClick={handleExport} aria-label=\"Export time series data as CSV\">\n <DownloadIcon fontSize=\"inherit\" />\n </IconButton>\n </InfoTooltip>\n );\n};\n"],"names":["IconButton","InfoTooltip","exportDataAsCSV","extractExportableData","isExportableData","sanitizeFilename","DownloadIcon","React","useCallback","useMemo","TimeSeriesExportAction","queryResults","definition","exportableData","canExport","handleExport","title","spec","display","name","csvBlob","data","baseFilename","filename","link","document","createElement","href","URL","createObjectURL","download","body","appendChild","click","removeChild","revokeObjectURL","error","console","description","size","onClick","aria-label","fontSize"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,UAAU,QAAQ,gBAAgB;AAC3C,SAASC,WAAW,QAAQ,yBAAyB;AACrD,SAASC,eAAe,EAAEC,qBAAqB,EAAEC,gBAAgB,EAAEC,gBAAgB,QAAQ,4BAA4B;AACvH,OAAOC,kBAAkB,2BAA2B;AACpD,OAAOC,SAASC,WAAW,EAAEC,OAAO,QAAQ,QAAQ;AAIpD,OAAO,MAAMC,yBAAyD,CAAC,EAAEC,YAAY,EAAEC,UAAU,EAAE;IACjG,MAAMC,iBAAiBJ,QAAQ;QAC7B,OAAON,sBAAsBQ;IAC/B,GAAG;QAACA;KAAa;IAEjB,MAAMG,YAAYL,QAAQ;QACxB,OAAOL,iBAAiBS;IAC1B,GAAG;QAACA;KAAe;IAEnB,MAAME,eAAeP,YAAY;QAC/B,IAAI,CAACK,kBAAkB,CAACC,WAAW;QAEnC,IAAI;YACF,MAAME,QAAQJ,YAAYK,MAAMC,SAASC,QAAQ;YAEjD,MAAMC,UAAUlB,gBAAgB;gBAC9BmB,MAAMR;YACR;YAEA,MAAMS,eAAejB,iBAAiBW;YACtC,MAAMO,WAAW,GAAGD,aAAa,SAAS,CAAC;YAE3C,MAAME,OAAOC,SAASC,aAAa,CAAC;YACpCF,KAAKG,IAAI,GAAGC,IAAIC,eAAe,CAACT;YAChCI,KAAKM,QAAQ,GAAGP;YAChBE,SAASM,IAAI,CAACC,WAAW,CAACR;YAC1BA,KAAKS,KAAK;YACVR,SAASM,IAAI,CAACG,WAAW,CAACV;YAC1BI,IAAIO,eAAe,CAACX,KAAKG,IAAI;QAC/B,EAAE,OAAOS,OAAO;YACdC,QAAQD,KAAK,CAAC,8BAA8BA;QAC9C;IACF,GAAG;QAACvB;QAAgBC;QAAWF;KAAW;IAE1C,IAAI,CAACE,WAAW;QACd,OAAO;IACT;IAEA,qBACE,KAACb;QAAYqC,aAAY;kBACvB,cAAA,KAACtC;YAAWuC,MAAK;YAAQC,SAASzB;YAAc0B,cAAW;sBACzD,cAAA,KAACnC;gBAAaoC,UAAS;;;;AAI/B,EAAE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import { TimeSeriesChartVisualOptions } from './time-series-chart-model';
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { TimeSeriesChartVisualOptions } from './time-series-chart-model';
|
|
3
3
|
export interface VisualOptionsEditorProps {
|
|
4
4
|
value: TimeSeriesChartVisualOptions;
|
|
5
5
|
onChange: (visual: TimeSeriesChartVisualOptions) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VisualOptionsEditor.d.ts","sourceRoot":"","sources":["../../src/VisualOptionsEditor.tsx"],"names":[],"mappings":"AAgBA,OAAO,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;AAE1C,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,CAsJ/F"}
|
|
@@ -11,10 +11,10 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
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
|
|
14
|
+
import { Slider, Switch, ToggleButton, ToggleButtonGroup } from "@mui/material";
|
|
15
|
+
import { OptionsEditorControl, OptionsEditorGroup, SettingsAutocomplete } from "@perses-dev/components";
|
|
16
|
+
import { produce } from "immer";
|
|
17
|
+
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
18
|
export function VisualOptionsEditor({ value, onChange }) {
|
|
19
19
|
const handleLineWidthChange = (_, sliderValue)=>{
|
|
20
20
|
const newValue = Array.isArray(sliderValue) ? sliderValue[0] : sliderValue;
|
|
@@ -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 { produce } from 'immer';\nimport { Slider, Switch, ToggleButton, ToggleButtonGroup } from '@mui/material';\nimport { OptionsEditorControl, OptionsEditorGroup, SettingsAutocomplete } from '@perses-dev/components';\nimport { ReactElement } from 'react';\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 StackOptions,\n STACK_OPTIONS,\n LINE_STYLE_CONFIG,\n VISUAL_CONFIG,\n TimeSeriesChartVisualOptions,\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":["produce","Slider","Switch","ToggleButton","ToggleButtonGroup","OptionsEditorControl","OptionsEditorGroup","SettingsAutocomplete","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;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MuC,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,KAAC7D;oCAA8BiB,OAAO2C;oCAAYZ,cAAY,GAAGY,WAAW,WAAW,CAAC;8CACrFC,OAAOzB,KAAK;mCADIwB;;;kCAO3B,KAAC1D;wBACCkC,OAAOtB,cAAciB,WAAW,CAACK,KAAK;wBACtCC,uBACE,KAACvC;4BACCmD,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,KAAC5B;wBACCkC,OAAOtB,cAAcgD,YAAY,CAAC1B,KAAK;wBACvCC,uBACE,KAACtC;4BACCgE,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 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,oBA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wB;;;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,5 +1,5 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import { TimeSeriesChartYAxisOptions } from './time-series-chart-model';
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { TimeSeriesChartYAxisOptions } from './time-series-chart-model';
|
|
3
3
|
export interface YAxisOptionsEditorProps {
|
|
4
4
|
value: TimeSeriesChartYAxisOptions;
|
|
5
5
|
onChange: (yAxis: TimeSeriesChartYAxisOptions) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YAxisOptionsEditor.d.ts","sourceRoot":"","sources":["../../src/YAxisOptionsEditor.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"YAxisOptionsEditor.d.ts","sourceRoot":"","sources":["../../src/YAxisOptionsEditor.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAS7E,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,2BAA2B,CAAC;IACnC,QAAQ,EAAE,CAAC,KAAK,EAAE,2BAA2B,KAAK,IAAI,CAAC;CACxD;AAED,wBAAgB,kBAAkB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,uBAAuB,GAAG,YAAY,CAuG7F"}
|
|
@@ -11,9 +11,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
import { Switch, TextField } from
|
|
15
|
-
import { OptionsEditorControl, OptionsEditorGroup, FormatControls, SettingsAutocomplete } from
|
|
16
|
-
import { DEFAULT_FORMAT, DEFAULT_Y_AXIS, Y_AXIS_CONFIG, LOG_BASE_CONFIG, LOG_BASE_OPTIONS } from
|
|
14
|
+
import { Switch, TextField } from "@mui/material";
|
|
15
|
+
import { OptionsEditorControl, OptionsEditorGroup, FormatControls, SettingsAutocomplete } from "@perses-dev/components";
|
|
16
|
+
import { DEFAULT_FORMAT, DEFAULT_Y_AXIS, Y_AXIS_CONFIG, LOG_BASE_CONFIG, LOG_BASE_OPTIONS } from "./time-series-chart-model.js";
|
|
17
17
|
export function YAxisOptionsEditor({ value, onChange }) {
|
|
18
18
|
const logBase = value.logBase ? LOG_BASE_CONFIG[value.logBase] : undefined;
|
|
19
19
|
return /*#__PURE__*/ _jsxs(OptionsEditorGroup, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/YAxisOptionsEditor.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 { Switch, TextField } from '@mui/material';\
|
|
1
|
+
{"version":3,"sources":["../../src/YAxisOptionsEditor.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 { Switch, TextField } from '@mui/material';\nimport { OptionsEditorControl, OptionsEditorGroup, FormatControls, SettingsAutocomplete } from '@perses-dev/components';\nimport type { ReactElement } from 'react';\n\nimport type { TimeSeriesChartYAxisOptions } from './time-series-chart-model';\nimport {\n DEFAULT_FORMAT,\n DEFAULT_Y_AXIS,\n Y_AXIS_CONFIG,\n LOG_BASE_CONFIG,\n LOG_BASE_OPTIONS,\n} from './time-series-chart-model';\n\nexport interface YAxisOptionsEditorProps {\n value: TimeSeriesChartYAxisOptions;\n onChange: (yAxis: TimeSeriesChartYAxisOptions) => void;\n}\n\nexport function YAxisOptionsEditor({ value, onChange }: YAxisOptionsEditorProps): ReactElement {\n const logBase = value.logBase ? LOG_BASE_CONFIG[value.logBase] : undefined;\n\n return (\n <OptionsEditorGroup title=\"Y Axis\">\n <OptionsEditorControl\n label=\"Show\"\n control={\n <Switch\n checked={value.show ?? DEFAULT_Y_AXIS.show}\n onChange={(e): void => {\n onChange({\n ...value,\n show: e.target.checked,\n });\n }}\n />\n }\n />\n <FormatControls\n value={value.format ?? DEFAULT_FORMAT}\n onChange={(newFormat): void =>\n onChange({\n ...value,\n format: newFormat,\n })\n }\n />\n <OptionsEditorControl\n label={Y_AXIS_CONFIG.logBase.label}\n control={\n <SettingsAutocomplete\n value={{\n ...logBase,\n id: logBase?.label ?? 'None',\n }}\n options={LOG_BASE_OPTIONS}\n onChange={(__, newValue) => {\n const updatedValue: TimeSeriesChartYAxisOptions = {\n ...value,\n logBase: newValue.log ?? undefined,\n };\n onChange(updatedValue);\n }}\n disabled={value === undefined}\n disableClearable\n ></SettingsAutocomplete>\n }\n />\n <OptionsEditorControl\n label={Y_AXIS_CONFIG.label.label}\n control={\n <TextField\n value={value.label ?? ''}\n inputProps={{ 'aria-label': 'enter y axis label' }}\n onChange={(e) =>\n onChange({\n ...value,\n label: e.target.value,\n })\n }\n placeholder=\"Default\"\n />\n }\n />\n <OptionsEditorControl\n label={Y_AXIS_CONFIG.min.label}\n control={\n <TextField\n type=\"number\"\n value={value.min ?? ''}\n onChange={(e) => {\n // ensure empty value resets to undef to allow chart to calculate min\n const newValue = e.target.value ? Number(e.target.value) : undefined;\n onChange({\n ...value,\n min: newValue,\n });\n }}\n placeholder=\"Default\"\n />\n }\n />\n <OptionsEditorControl\n label={Y_AXIS_CONFIG.max.label}\n control={\n <TextField\n type=\"number\"\n value={value.max ?? ''}\n onChange={(e) => {\n // ensure empty value resets to undef to allow chart to calculate max\n const newValue = e.target.value ? Number(e.target.value) : undefined;\n onChange({\n ...value,\n max: newValue,\n });\n }}\n placeholder=\"Default\"\n />\n }\n />\n </OptionsEditorGroup>\n );\n}\n"],"names":["Switch","TextField","OptionsEditorControl","OptionsEditorGroup","FormatControls","SettingsAutocomplete","DEFAULT_FORMAT","DEFAULT_Y_AXIS","Y_AXIS_CONFIG","LOG_BASE_CONFIG","LOG_BASE_OPTIONS","YAxisOptionsEditor","value","onChange","logBase","undefined","title","label","control","checked","show","e","target","format","newFormat","id","options","__","newValue","updatedValue","log","disabled","disableClearable","inputProps","placeholder","min","type","Number","max"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,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IAAI;oBACtBgB,YAAY;wBAAE,cAAc;oBAAqB;oBACjDpB,UAAU,CAACQ,IACTR,SAAS;4BACP,GAAGD,KAAK;4BACRK,OAAOI,EAAEC,MAAM,CAACV,KAAK;wBACvB;oBAEFsB,aAAY;;;0BAIlB,KAAChC;gBACCe,OAAOT,cAAc2B,GAAG,CAAClB,KAAK;gBAC9BC,uBACE,KAACjB;oBACCmC,MAAK;oBACLxB,OAAOA,MAAMuB,GAAG,IAAI;oBACpBtB,UAAU,CAACQ;wBACT,qEAAqE;wBACrE,MAAMO,WAAWP,EAAEC,MAAM,CAACV,KAAK,GAAGyB,OAAOhB,EAAEC,MAAM,CAACV,KAAK,IAAIG;wBAC3DF,SAAS;4BACP,GAAGD,KAAK;4BACRuB,KAAKP;wBACP;oBACF;oBACAM,aAAY;;;0BAIlB,KAAChC;gBACCe,OAAOT,cAAc8B,GAAG,CAACrB,KAAK;gBAC9BC,uBACE,KAACjB;oBACCmC,MAAK;oBACLxB,OAAOA,MAAM0B,GAAG,IAAI;oBACpBzB,UAAU,CAACQ;wBACT,qEAAqE;wBACrE,MAAMO,WAAWP,EAAEC,MAAM,CAACV,KAAK,GAAGyB,OAAOhB,EAAEC,MAAM,CAACV,KAAK,IAAIG;wBAC3DF,SAAS;4BACP,GAAGD,KAAK;4BACR0B,KAAKV;wBACP;oBACF;oBACAM,aAAY;;;;;AAMxB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { CursorCoordinates } from '@perses-dev/components';
|
|
1
2
|
import type { LineSeriesOption } from 'echarts';
|
|
2
|
-
import {
|
|
3
|
-
import { TimeSeriesAnnotation } from '../utils/annotation';
|
|
3
|
+
import type { TimeSeriesAnnotation } from '../utils/annotation';
|
|
4
4
|
export interface AnnotationTooltipProps {
|
|
5
5
|
annotation: TimeSeriesAnnotation;
|
|
6
6
|
containerId?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnnotationTooltip.d.ts","sourceRoot":"","sources":["../../../src/annotations/AnnotationTooltip.tsx"],"names":[],"mappings":"
|
|
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;AAKhD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEhE,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,CAAC,WAAW,EAAE,oBAAoB,EAAE,GAAG,SAAS,GAAG,gBAAgB,EAAE,CAwHzG"}
|
|
@@ -11,12 +11,12 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
import { Box, Divider, Portal, Stack, Typography } from
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
14
|
+
import { Box, Divider, Portal, Stack, Typography } from "@mui/material";
|
|
15
|
+
import { assembleTransform, getDateAndTime, getTooltipStyles, PIN_TOOLTIP_HELP_TEXT, TOOLTIP_BG_COLOR_FALLBACK, TOOLTIP_MAX_WIDTH, UNPIN_TOOLTIP_HELP_TEXT, useMousePosition } from "@perses-dev/components";
|
|
16
|
+
import { DEFAULT_ANNOTATION_COLOR } from "@perses-dev/plugin-system";
|
|
17
|
+
import Pin from "mdi-material-ui/Pin";
|
|
18
|
+
import PinOutline from "mdi-material-ui/PinOutline";
|
|
19
|
+
import useResizeObserver from "use-resize-observer";
|
|
20
20
|
export function AnnotationTooltip({ annotation, containerId, formatWithUserTimeZone, pinnedPos, enablePinning = true, onUnpinClick }) {
|
|
21
21
|
const mousePos = useMousePosition();
|
|
22
22
|
const { height, width, ref: tooltipRef } = useResizeObserver();
|
|
@@ -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 Pin from 'mdi-material-ui/Pin';\nimport PinOutline from 'mdi-material-ui/PinOutline';\nimport useResizeObserver from 'use-resize-observer';\nimport type { LineSeriesOption } from 'echarts';\nimport {\n assembleTransform,\n CursorCoordinates,\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 { 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","Pin","PinOutline","useResizeObserver","assembleTransform","getDateAndTime","getTooltipStyles","PIN_TOOLTIP_HELP_TEXT","TOOLTIP_BG_COLOR_FALLBACK","TOOLTIP_MAX_WIDTH","UNPIN_TOOLTIP_HELP_TEXT","useMousePosition","DEFAULT_ANNOTATION_COLOR","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,sEAAs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;oBAAE1C;oBAAO/B,OAAO;oBAAG0E,MAAM;gBAAkB;gBACtDC,OAAO;oBAAEC,MAAM;gBAAM;gBACrBC,iBAAiBR;YACnB;YAEA,mBAAmB;YACnBF,cAAcI,IAAI,CAAC;gBACjBS,OAAO;oBAACxF,WAAWmB,KAAK;oBAAE;iBAAE;gBAC5BsE,QAAQ;gBACRC,YAAY;oBAAC;oBAAI;iBAAG;gBACpBC,cAAc;gBACdC,cAAc;oBAAC;oBAAG;iBAAO;gBACzBN,WAAW;oBAAE/C;gBAAM;gBACnB8C,iBAAiBR;gBACjBmB,SAAS;YACX;QACF;IACF;IAEA,MAAMC,SAA2B;QAC/Bf,MAAM;QACNgB,MAAM,EAAE;QACRC,QAAQ;QACRC,UACE3B,aAAaX,MAAM,GAAG,IAClB;YACEqC,QAAQ;YACRD,MAAMzB;YACNU,OAAO;gBACLC,MAAM;YACR;QACF,IACArE;QACNsF,UACE3B,aAAaZ,MAAM,GAAG,IAClB;YACEqC,QAAQ;YACRV,QAAQ;gBAAC;gBAAQ;aAAO;YACxBS,MAAMxB;YACNO,WAAW;gBACTC,MAAM;YACR;QACF,IACAnE;QACNuF,WACE3B,cAAcb,MAAM,GAAG,IACnB;YACEqC,QAAQ;YACRD,MAAMvB;YACNQ,OAAO;gBACLC,MAAM;YACR;QACF,IACArE;IACR;IAEA,OAAO;QAACkF;KAAO;AACjB"}
|
|
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,kBAAkBmB,UAAUH,WAAWI,UAAU,GAAGC,SAAS,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 +11,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
import React from
|
|
15
|
-
import ReactDOM from
|
|
14
|
+
import React from "react";
|
|
15
|
+
import ReactDOM from "react-dom/client";
|
|
16
16
|
const root = ReactDOM.createRoot(document.getElementById('root'));
|
|
17
17
|
root.render(/*#__PURE__*/ _jsx(React.StrictMode, {}));
|
|
18
18
|
|
package/lib/getPluginModule.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPluginModule.d.ts","sourceRoot":"","sources":["../../src/getPluginModule.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,oBAAoB,EAAoB,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"getPluginModule.d.ts","sourceRoot":"","sources":["../../src/getPluginModule.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,oBAAoB,EAAoB,MAAM,2BAA2B,CAAC;AAIxF;;GAEG;AACH,wBAAgB,eAAe,IAAI,oBAAoB,CAUtD"}
|
package/lib/getPluginModule.js
CHANGED
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
import packageJson from
|
|
13
|
+
import packageJson from "../package.json" with {
|
|
14
|
+
type: 'json'
|
|
15
|
+
};
|
|
14
16
|
/**
|
|
15
17
|
* Returns the plugin module information from package.json
|
|
16
18
|
*/ export function getPluginModule() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getPluginModule.ts"],"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 { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system';\nimport packageJson from '../package.json';\n\n/**\n * Returns the plugin module information from package.json\n */\nexport function getPluginModule(): PluginModuleResource {\n const { name, version, perses } = packageJson;\n return {\n kind: 'PluginModule',\n metadata: {\n name,\n version,\n },\n spec: perses as PluginModuleSpec,\n };\n}\n"],"names":["packageJson","getPluginModule","name","version","perses","kind","metadata","spec"],"mappings":"AAAA,+BAA+B;AAC/B,oEAAoE;AACpE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,sEAAsE;AACtE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;
|
|
1
|
+
{"version":3,"sources":["../../src/getPluginModule.ts"],"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 type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system';\n\nimport packageJson from '../package.json' with { type: 'json' };\n\n/**\n * Returns the plugin module information from package.json\n */\nexport function getPluginModule(): PluginModuleResource {\n const { name, version, perses } = packageJson;\n return {\n kind: 'PluginModule',\n metadata: {\n name,\n version,\n },\n spec: perses as PluginModuleSpec,\n };\n}\n"],"names":["packageJson","type","getPluginModule","name","version","perses","kind","metadata","spec"],"mappings":"AAAA,+BAA+B;AAC/B,oEAAoE;AACpE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,sEAAsE;AACtE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,OAAOA,iBAAiB,uBAAuB;IAAEC,MAAM;AAAO,EAAE;AAEhE;;CAEC,GACD,OAAO,SAASC;IACd,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAGL;IAClC,OAAO;QACLM,MAAM;QACNC,UAAU;YACRJ;YACAC;QACF;QACAI,MAAMH;IACR;AACF"}
|