@perses-dev/stat-chart-plugin 0.12.0-beta.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__mf/js/{StatChart.7df52118.js → StatChart.2e89aa1f.js} +3 -3
- package/__mf/js/async/392.b57d43bb.js +2 -0
- package/__mf/js/async/{911.29a700f7.js → 604.e0d336cb.js} +4 -4
- package/__mf/js/async/648.1c0ebb20.js +22 -0
- package/__mf/js/async/955.8917f69b.js +7 -0
- package/__mf/js/async/{__federation_expose_StatChart.2dcf8b3a.js → __federation_expose_StatChart.668c661b.js} +1 -1
- package/__mf/js/async/lib-router.18b45155.js +2 -0
- package/__mf/js/async/{lib-router.ed92c54d.js.LICENSE.txt → lib-router.18b45155.js.LICENSE.txt} +3 -3
- package/__mf/js/{main.4a371943.js → main.f573f11f.js} +3 -3
- package/lib/StatChart.js +1 -1
- package/lib/StatChart.js.map +1 -1
- package/lib/StatChartBase.js +1 -1
- package/lib/StatChartBase.js.map +1 -1
- package/lib/StatChartOptionsEditorSettings.js +1 -1
- package/lib/StatChartOptionsEditorSettings.js.map +1 -1
- package/lib/StatChartPanel.js +1 -1
- package/lib/StatChartPanel.js.map +1 -1
- package/lib/StatChartValueMappingEditor.js +1 -1
- package/lib/StatChartValueMappingEditor.js.map +1 -1
- package/lib/bootstrap.js +1 -1
- package/lib/bootstrap.js.map +1 -1
- package/lib/cjs/StatChart.js +1 -1
- package/lib/cjs/StatChartBase.js +1 -1
- package/lib/cjs/StatChartOptionsEditorSettings.js +1 -1
- package/lib/cjs/StatChartPanel.js +1 -1
- package/lib/cjs/StatChartValueMappingEditor.js +1 -1
- package/lib/cjs/bootstrap.js +1 -1
- package/lib/cjs/env.d.js +1 -1
- package/lib/cjs/getPluginModule.js +12 -0
- package/lib/cjs/index-federation.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/cjs/setup-tests.js +1 -1
- package/lib/cjs/stat-chart-model.js +1 -1
- package/lib/cjs/utils/calculate-font-size.js +1 -1
- package/lib/cjs/utils/calculate-value.js +1 -1
- package/lib/cjs/utils/data-transform.js +1 -1
- package/lib/cjs/utils/format-stat-chart-value.js +1 -1
- package/lib/cjs/utils/get-color.js +1 -1
- package/lib/env.d.js +1 -1
- package/lib/env.d.js.map +1 -1
- package/lib/getPluginModule.d.ts.map +1 -1
- package/lib/getPluginModule.js +12 -0
- package/lib/getPluginModule.js.map +1 -1
- package/lib/index-federation.js +1 -1
- package/lib/index-federation.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/setup-tests.js +1 -1
- package/lib/setup-tests.js.map +1 -1
- package/lib/stat-chart-model.js +1 -1
- package/lib/stat-chart-model.js.map +1 -1
- package/lib/utils/calculate-font-size.js +1 -1
- package/lib/utils/calculate-font-size.js.map +1 -1
- package/lib/utils/calculate-value.js +1 -1
- package/lib/utils/calculate-value.js.map +1 -1
- package/lib/utils/data-transform.js +1 -1
- package/lib/utils/data-transform.js.map +1 -1
- package/lib/utils/format-stat-chart-value.js +1 -1
- package/lib/utils/format-stat-chart-value.js.map +1 -1
- package/lib/utils/get-color.js +1 -1
- package/lib/utils/get-color.js.map +1 -1
- package/mf-manifest.json +14 -14
- package/mf-stats.json +14 -14
- package/package.json +4 -4
- package/__mf/js/async/252.05fbd2b1.js +0 -22
- package/__mf/js/async/392.a8143615.js +0 -2
- package/__mf/js/async/555.b1ac32bc.js +0 -7
- package/__mf/js/async/lib-router.ed92c54d.js +0 -2
- /package/__mf/js/async/{392.a8143615.js.LICENSE.txt → 392.b57d43bb.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{252.05fbd2b1.js.LICENSE.txt → 648.1c0ebb20.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{555.b1ac32bc.js.LICENSE.txt → 955.8917f69b.js.LICENSE.txt} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/StatChartOptionsEditorSettings.tsx"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../src/StatChartOptionsEditorSettings.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, SwitchProps } from '@mui/material';\nimport {\n FontSizeOption,\n FontSizeSelector,\n FontSizeSelectorProps,\n FormatControls,\n FormatControlsProps,\n OptionsEditorColumn,\n OptionsEditorControl,\n OptionsEditorGrid,\n OptionsEditorGroup,\n SettingsAutocomplete,\n ThresholdsEditor,\n ThresholdsEditorProps,\n} from '@perses-dev/components';\nimport { FormatOptions } from '@perses-dev/core';\nimport {\n CalculationSelector,\n CalculationSelectorProps,\n MetricLabelInput,\n MetricLabelInputProps,\n} from '@perses-dev/plugin-system';\nimport { produce } from 'immer';\nimport merge from 'lodash/merge';\nimport { ReactElement, useCallback, useMemo } from 'react';\nimport {\n COLOR_MODE_LABELS,\n ColorModeLabelItem,\n SHOW_LEGEND_LABELS,\n ShowLegendLabelItem,\n StatChartOptions,\n StatChartOptionsEditorProps,\n} from './stat-chart-model';\n\nconst DEFAULT_FORMAT: FormatOptions = { unit: 'percent-decimal' };\n\nexport function StatChartOptionsEditorSettings(props: StatChartOptionsEditorProps): ReactElement {\n const { onChange, value } = props;\n\n // ensures decimalPlaces defaults to correct value\n const format = merge({}, DEFAULT_FORMAT, value.format);\n\n const handleCalculationChange: CalculationSelectorProps['onChange'] = (metricLabel) => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n draft.calculation = metricLabel;\n })\n );\n };\n\n const handleMetricLabelChange: MetricLabelInputProps['onChange'] = (newCalculation) => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n draft.metricLabel = newCalculation;\n })\n );\n };\n\n const handleShowLegendChange = useCallback(\n (_: unknown, newShowLegend: ShowLegendLabelItem): void => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n draft.legendMode = newShowLegend.id;\n })\n );\n },\n [onChange, value]\n );\n\n const handleUnitChange: FormatControlsProps['onChange'] = (newFormat) => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n draft.format = newFormat;\n })\n );\n };\n\n const handleSparklineChange: SwitchProps['onChange'] = (_: unknown, checked: boolean) => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n // For now, setting to an empty object when checked, so the stat chart\n // uses the default chart color and line styles. In the future, this\n // will likely be configurable in the UI.\n draft.sparkline = checked ? {} : undefined;\n })\n );\n };\n\n const handleThresholdsChange: ThresholdsEditorProps['onChange'] = (thresholds) => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n draft.thresholds = thresholds;\n })\n );\n };\n\n const handleFontSizeChange: FontSizeSelectorProps['onChange'] = (fontSize: FontSizeOption) => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n draft.valueFontSize = fontSize;\n })\n );\n };\n\n const handleColorModeChange = useCallback(\n (_: unknown, newColorMode: ColorModeLabelItem): void => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n draft.colorMode = newColorMode.id;\n })\n );\n },\n [onChange, value]\n );\n\n const selectShowLegend = useMemo((): ReactElement => {\n return (\n <OptionsEditorControl\n label=\"Show\"\n control={\n <SettingsAutocomplete\n onChange={handleShowLegendChange}\n options={SHOW_LEGEND_LABELS}\n disableClearable\n value={\n SHOW_LEGEND_LABELS.find((i) => i.id === value.legendMode) ??\n SHOW_LEGEND_LABELS.find((i) => i.id === 'auto')!\n }\n />\n }\n />\n );\n }, [value.legendMode, handleShowLegendChange]);\n\n const selectColorMode = useMemo((): ReactElement => {\n return (\n <OptionsEditorControl\n label=\"Color mode\"\n control={\n <SettingsAutocomplete\n onChange={handleColorModeChange}\n options={COLOR_MODE_LABELS.map(({ id, label }) => ({ id, label }))}\n disableClearable\n value={\n COLOR_MODE_LABELS.find((i) => i.id === value.colorMode) ??\n COLOR_MODE_LABELS.find((i) => i.id === 'value')!\n }\n />\n }\n />\n );\n }, [value.colorMode, handleColorModeChange]);\n\n return (\n <OptionsEditorGrid>\n <OptionsEditorColumn>\n <OptionsEditorGroup title=\"Legend\">{selectShowLegend}</OptionsEditorGroup>\n <OptionsEditorGroup title=\"Misc\">\n <OptionsEditorControl\n label=\"Sparkline\"\n control={<Switch checked={!!value.sparkline} onChange={handleSparklineChange} />}\n />\n <FormatControls value={format} onChange={handleUnitChange} />\n <CalculationSelector value={value.calculation} onChange={handleCalculationChange} />\n <MetricLabelInput value={value.metricLabel} onChange={handleMetricLabelChange} />\n <FontSizeSelector value={value.valueFontSize} onChange={handleFontSizeChange} />\n {selectColorMode}\n </OptionsEditorGroup>\n </OptionsEditorColumn>\n <OptionsEditorColumn>\n <ThresholdsEditor disablePercentMode thresholds={value.thresholds} onChange={handleThresholdsChange} />\n </OptionsEditorColumn>\n </OptionsEditorGrid>\n );\n}\n"],"names":["Switch","FontSizeSelector","FormatControls","OptionsEditorColumn","OptionsEditorControl","OptionsEditorGrid","OptionsEditorGroup","SettingsAutocomplete","ThresholdsEditor","CalculationSelector","MetricLabelInput","produce","merge","useCallback","useMemo","COLOR_MODE_LABELS","SHOW_LEGEND_LABELS","DEFAULT_FORMAT","unit","StatChartOptionsEditorSettings","props","onChange","value","format","handleCalculationChange","metricLabel","draft","calculation","handleMetricLabelChange","newCalculation","handleShowLegendChange","_","newShowLegend","legendMode","id","handleUnitChange","newFormat","handleSparklineChange","checked","sparkline","undefined","handleThresholdsChange","thresholds","handleFontSizeChange","fontSize","valueFontSize","handleColorModeChange","newColorMode","colorMode","selectShowLegend","label","control","options","disableClearable","find","i","selectColorMode","map","title","disablePercentMode"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;A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;IAE3C,qBACE,MAACzC;;0BACC,MAACF;;kCACC,KAACG;wBAAmBoD,OAAM;kCAAUT;;kCACpC,MAAC3C;wBAAmBoD,OAAM;;0CACxB,KAACtD;gCACC8C,OAAM;gCACNC,uBAAS,KAACnD;oCAAOsC,SAAS,CAAC,CAAChB,MAAMiB,SAAS;oCAAElB,UAAUgB;;;0CAEzD,KAACnC;gCAAeoB,OAAOC;gCAAQF,UAAUc;;0CACzC,KAAC1B;gCAAoBa,OAAOA,MAAMK,WAAW;gCAAEN,UAAUG;;0CACzD,KAACd;gCAAiBY,OAAOA,MAAMG,WAAW;gCAAEJ,UAAUO;;0CACtD,KAAC3B;gCAAiBqB,OAAOA,MAAMuB,aAAa;gCAAExB,UAAUsB;;4BACvDa;;;;;0BAGL,KAACrD;0BACC,cAAA,KAACK;oBAAiBmD,kBAAkB;oBAACjB,YAAYpB,MAAMoB,UAAU;oBAAErB,UAAUoB;;;;;AAIrF"}
|
package/lib/StatChartPanel.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/StatChartPanel.tsx"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../src/StatChartPanel.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 { TitleComponentOption } from 'echarts';\nimport { useChartsTheme, GraphSeries, PersesChartsTheme } from '@perses-dev/components';\nimport { Stack, Typography, SxProps } from '@mui/material';\nimport { FC, useMemo } from 'react';\nimport { applyValueMapping, Labels, createRegexFromString, TimeSeriesData, ValueMapping } from '@perses-dev/core';\nimport { PanelProps, PanelData } from '@perses-dev/plugin-system';\nimport { StatChartOptions } from './stat-chart-model';\nimport { convertSparkline } from './utils/data-transform';\nimport { calculateValue } from './utils/calculate-value';\nimport { getStatChartColor } from './utils/get-color';\nimport { StatChartBase, StatChartData } from './StatChartBase';\n\nconst MIN_WIDTH = 100;\nconst SPACING = 2;\n\nexport type StatChartPanelProps = PanelProps<StatChartOptions, TimeSeriesData>;\n\nexport const StatChartPanel: FC<StatChartPanelProps> = (props) => {\n const { spec, contentDimensions, queryResults } = props;\n\n const { format, sparkline, valueFontSize: valueFontSize, colorMode } = spec;\n const chartsTheme = useChartsTheme();\n const statChartData = useStatChartData(queryResults, spec, chartsTheme);\n\n const isMultiSeries = statChartData.length > 1;\n\n // Handle three-state showLegend: 'on' | 'off' | 'auto' (or undefined for backward compatibility)\n const shouldShowLegend = spec.legendMode === 'on' ? true : spec.legendMode === 'off' ? false : isMultiSeries;\n\n if (!contentDimensions) return null;\n\n // Calculates chart width\n const spacing = SPACING * (statChartData.length - 1);\n let chartWidth = (contentDimensions.width - spacing) / statChartData.length;\n if (isMultiSeries && chartWidth < MIN_WIDTH) {\n chartWidth = MIN_WIDTH;\n }\n\n const noDataTextStyle = (chartsTheme.noDataOption.title as TitleComponentOption).textStyle;\n\n return (\n <Stack\n height={contentDimensions.height}\n width={contentDimensions.width}\n spacing={`${SPACING}px`}\n direction=\"row\"\n justifyContent={isMultiSeries ? 'left' : 'center'}\n alignItems=\"center\"\n sx={{\n overflowX: isMultiSeries ? 'scroll' : 'auto',\n }}\n >\n {statChartData.length ? (\n statChartData.map((series, index) => {\n const sparklineConfig = convertSparkline(chartsTheme, series.color, sparkline);\n\n return (\n <StatChartBase\n key={index}\n width={chartWidth}\n height={contentDimensions.height}\n data={series}\n format={format}\n sparkline={sparklineConfig}\n showSeriesName={shouldShowLegend}\n valueFontSize={valueFontSize}\n colorMode={colorMode}\n />\n );\n })\n ) : (\n <Typography sx={{ ...noDataTextStyle } as SxProps}>No data</Typography>\n )}\n </Stack>\n );\n};\n\nconst useStatChartData = (\n queryResults: Array<PanelData<TimeSeriesData>>,\n spec: StatChartOptions,\n chartsTheme: PersesChartsTheme\n): StatChartData[] => {\n return useMemo(() => {\n const { calculation, mappings, metricLabel } = spec;\n\n const statChartData: StatChartData[] = [];\n for (const result of queryResults) {\n for (const seriesData of result.data.series) {\n const calculatedValue = calculateValue(calculation, seriesData);\n\n // get label metric value\n const labelValue = getLabelValue(metricLabel, seriesData.labels);\n\n // get actual value to display\n const displayValue = getValueOrLabel(calculatedValue, mappings, labelValue);\n\n const color = getStatChartColor(chartsTheme, spec, calculatedValue);\n\n const series: GraphSeries = {\n name: seriesData.formattedName ?? '',\n values: seriesData.values,\n };\n\n statChartData.push({ calculatedValue: displayValue, seriesData: series, color });\n }\n }\n return statChartData;\n }, [queryResults, spec, chartsTheme]);\n};\n\nconst getValueOrLabel = (\n value?: number | null,\n mappings?: ValueMapping[],\n label?: string\n): string | number | undefined | null => {\n if (label) {\n return label;\n }\n if (mappings?.length && value !== undefined && value !== null) {\n return applyValueMapping(value, mappings).value;\n } else {\n return value;\n }\n};\n\nconst getLabelValue = (fieldLabel?: string, labels?: Labels): string | undefined => {\n if (!labels || !fieldLabel) {\n return undefined;\n }\n for (const [key, value] of Object.entries(labels)) {\n const regex = createRegexFromString(fieldLabel);\n if (regex.test(key)) {\n return value;\n }\n }\n return undefined;\n};\n"],"names":["useChartsTheme","Stack","Typography","useMemo","applyValueMapping","createRegexFromString","convertSparkline","calculateValue","getStatChartColor","StatChartBase","MIN_WIDTH","SPACING","StatChartPanel","props","spec","contentDimensions","queryResults","format","sparkline","valueFontSize","colorMode","chartsTheme","statChartData","useStatChartData","isMultiSeries","length","shouldShowLegend","legendMode","spacing","chartWidth","width","noDataTextStyle","noDataOption","title","textStyle","height","direction","justifyContent","alignItems","sx","overflowX","map","series","index","sparklineConfig","color","data","showSeriesName","calculation","mappings","metricLabel","result","seriesData","calculatedValue","labelValue","getLabelValue","labels","displayValue","getValueOrLabel","name","formattedName","values","push","value","label","undefined","fieldLabel","key","Object","entries","regex","test"],"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;;AAGjC,SAASA,cAAc,QAAwC,yBAAyB;AACxF,SAASC,KAAK,EAAEC,UAAU,QAAiB,gBAAgB;AAC3D,SAAaC,OAAO,QAAQ,QAAQ;AACpC,SAASC,iBAAiB,EAAUC,qBAAqB,QAAsC,mBAAmB;AAGlH,SAASC,gBAAgB,QAAQ,yBAAyB;AAC1D,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,iBAAiB,QAAQ,oBAAoB;AACtD,SAASC,aAAa,QAAuB,kBAAkB;AAE/D,MAAMC,YAAY;AAClB,MAAMC,UAAU;AAIhB,OAAO,MAAMC,iBAA0C,CAACC;IACtD,MAAM,EAAEC,IAAI,EAAEC,iBAAiB,EAAEC,YAAY,EAAE,GAAGH;IAElD,MAAM,EAAEI,MAAM,EAAEC,SAAS,EAAEC,eAAeA,aAAa,EAAEC,SAAS,EAAE,GAAGN;IACvE,MAAMO,cAAcrB;IACpB,MAAMsB,gBAAgBC,iBAAiBP,cAAcF,MAAMO;IAE3D,MAAMG,gBAAgBF,cAAcG,MAAM,GAAG;IAE7C,iGAAiG;IACjG,MAAMC,mBAAmBZ,KAAKa,UAAU,KAAK,OAAO,OAAOb,KAAKa,UAAU,KAAK,QAAQ,QAAQH;IAE/F,IAAI,CAACT,mBAAmB,OAAO;IAE/B,yBAAyB;IACzB,MAAMa,UAAUjB,UAAWW,CAAAA,cAAcG,MAAM,GAAG,CAAA;IAClD,IAAII,aAAa,AAACd,CAAAA,kBAAkBe,KAAK,GAAGF,OAAM,IAAKN,cAAcG,MAAM;IAC3E,IAAID,iBAAiBK,aAAanB,WAAW;QAC3CmB,aAAanB;IACf;I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WAAWS,MAAM;gBAC3B;gBAEAvC,cAAcwC,IAAI,CAAC;oBAAET,iBAAiBI;oBAAcL,YAAYV;oBAAQG;gBAAM;YAChF;QACF;QACA,OAAOvB;IACT,GAAG;QAACN;QAAcF;QAAMO;KAAY;AACtC;AAEA,MAAMqC,kBAAkB,CACtBK,OACAd,UACAe;IAEA,IAAIA,OAAO;QACT,OAAOA;IACT;IACA,IAAIf,UAAUxB,UAAUsC,UAAUE,aAAaF,UAAU,MAAM;QAC7D,OAAO3D,kBAAkB2D,OAAOd,UAAUc,KAAK;IACjD,OAAO;QACL,OAAOA;IACT;AACF;AAEA,MAAMR,gBAAgB,CAACW,YAAqBV;IAC1C,IAAI,CAACA,UAAU,CAACU,YAAY;QAC1B,OAAOD;IACT;IACA,KAAK,MAAM,CAACE,KAAKJ,MAAM,IAAIK,OAAOC,OAAO,CAACb,QAAS;QACjD,MAAMc,QAAQjE,sBAAsB6D;QACpC,IAAII,MAAMC,IAAI,CAACJ,MAAM;YACnB,OAAOJ;QACT;IACF;IACA,OAAOE;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/StatChartValueMappingEditor.tsx"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../src/StatChartValueMappingEditor.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 { OptionsEditorProps } from '@perses-dev/plugin-system';\nimport { ValueMapping } from '@perses-dev/core';\nimport { ValueMappingsEditor } from '@perses-dev/components';\nimport { FC } from 'react';\nimport { StatChartOptions } from './stat-chart-model';\n\nexport type StatChartValueMappingEditorProps = OptionsEditorProps<StatChartOptions>;\n\nexport const StatChartValueMappingEditor: FC<StatChartValueMappingEditorProps> = ({ onChange, value }) => {\n function handleValueMappingChange(mappings: ValueMapping[]): void {\n onChange({ ...value, mappings });\n }\n\n return <ValueMappingsEditor mappings={value.mappings ?? []} onChange={handleValueMappingChange} />;\n};\n"],"names":["ValueMappingsEditor","StatChartValueMappingEditor","onChange","value","handleValueMappingChange","mappings"],"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;;AAIjC,SAASA,mBAAmB,QAAQ,yBAAyB;AAM7D,OAAO,MAAMC,8BAAoE,CAAC,EAAEC,QAAQ,EAAEC,KAAK,EAAE;IACnG,SAASC,yBAAyBC,QAAwB;QACxDH,SAAS;YAAE,GAAGC,KAAK;YAAEE;QAAS;IAChC;IAEA,qBAAO,KAACL;QAAoBK,UAAUF,MAAME,QAAQ,IAAI,EAAE;QAAEH,UAAUE;;AACxE,EAAE"}
|
package/lib/bootstrap.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright The Perses Authors
|
|
3
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
// you may not use this file except in compliance with the License.
|
|
5
5
|
// You may obtain a copy of the License at
|
package/lib/bootstrap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/bootstrap.tsx"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../src/bootstrap.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 React from 'react';\nimport ReactDOM from 'react-dom/client';\n\nconst root = ReactDOM.createRoot(document.getElementById('root')!);\nroot.render(<React.StrictMode></React.StrictMode>);\n"],"names":["React","ReactDOM","root","createRoot","document","getElementById","render","StrictMode"],"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,OAAOA,WAAW,QAAQ;AAC1B,OAAOC,cAAc,mBAAmB;AAExC,MAAMC,OAAOD,SAASE,UAAU,CAACC,SAASC,cAAc,CAAC;AACzDH,KAAKI,MAAM,eAAC,KAACN,MAAMO,UAAU"}
|
package/lib/cjs/StatChart.js
CHANGED
package/lib/cjs/StatChartBase.js
CHANGED
package/lib/cjs/bootstrap.js
CHANGED
package/lib/cjs/env.d.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the \"License\");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an \"AS IS\" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
1
13
|
"use strict";
|
|
2
14
|
Object.defineProperty(exports, "__esModule", {
|
|
3
15
|
value: true
|
|
@@ -40,7 +40,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
40
40
|
}
|
|
41
41
|
return newObj;
|
|
42
42
|
}
|
|
43
|
-
// Copyright
|
|
43
|
+
// Copyright The Perses Authors
|
|
44
44
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
45
45
|
// you may not use this file except in compliance with the License.
|
|
46
46
|
// You may obtain a copy of the License at
|
package/lib/cjs/index.js
CHANGED
package/lib/cjs/setup-tests.js
CHANGED
package/lib/env.d.js
CHANGED
package/lib/env.d.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/env.d.ts"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../src/env.d.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\n/// <reference types=\"@rsbuild/core/types\" />\n"],"names":[],"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,6CAA6C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPluginModule.d.ts","sourceRoot":"","sources":["../../src/getPluginModule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getPluginModule.d.ts","sourceRoot":"","sources":["../../src/getPluginModule.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,oBAAoB,EAAoB,MAAM,2BAA2B,CAAC;AAGnF;;GAEG;AACH,wBAAgB,eAAe,IAAI,oBAAoB,CAUtD"}
|
package/lib/getPluginModule.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the \"License\");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an \"AS IS\" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
1
13
|
import packageJson from '../package.json';
|
|
2
14
|
/**
|
|
3
15
|
* Returns the plugin module information from package.json
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getPluginModule.ts"],"sourcesContent":["
|
|
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;AAGjC,OAAOA,iBAAiB,kBAAkB;AAE1C;;CAEC,GACD,OAAO,SAASC;IACd,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAGJ;IAClC,OAAO;QACLK,MAAM;QACNC,UAAU;YACRJ;YACAC;QACF;QACAI,MAAMH;IACR;AACF"}
|
package/lib/index-federation.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index-federation.ts"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../src/index-federation.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('./bootstrap');\n"],"names":[],"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,MAAM,CAAC"}
|
package/lib/index.js
CHANGED
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../src/index.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\nexport { getPluginModule } from './getPluginModule';\nexport * from './stat-chart-model';\nexport * from './StatChart';\nexport * from './StatChartOptionsEditorSettings';\nexport * from './StatChartPanel';\nexport * from './StatChartValueMappingEditor';\nexport * from './StatChartBase';\n"],"names":["getPluginModule"],"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,eAAe,QAAQ,oBAAoB;AACpD,cAAc,qBAAqB;AACnC,cAAc,cAAc;AAC5B,cAAc,mCAAmC;AACjD,cAAc,mBAAmB;AACjC,cAAc,gCAAgC;AAC9C,cAAc,kBAAkB"}
|
package/lib/setup-tests.js
CHANGED
package/lib/setup-tests.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/setup-tests.ts"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../src/setup-tests.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 '@testing-library/jest-dom';\n\n// Always mock e-charts during tests since we don't have a proper canvas in jsdom\njest.mock('echarts/core');\n"],"names":["jest","mock"],"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,OAAO,4BAA4B;AAEnC,iFAAiF;AACjFA,KAAKC,IAAI,CAAC"}
|
package/lib/stat-chart-model.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/stat-chart-model.ts"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../src/stat-chart-model.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 { FontSizeOption } from '@perses-dev/components';\nimport { CalculationType, Definition, FormatOptions, ThresholdOptions, ValueMapping } from '@perses-dev/core';\nimport { OptionsEditorProps } from '@perses-dev/plugin-system';\n\n/**\n * The schema for a StatChart panel.\n */\nexport interface StatChartDefinition extends Definition<StatChartOptions> {\n kind: 'StatChart';\n}\n\nexport type ColorMode = 'none' | 'value' | 'background_solid';\n\nexport type ColorModeLabelItem = {\n id: ColorMode;\n label: string;\n};\n\nexport const COLOR_MODE_LABELS: ColorModeLabelItem[] = [\n { id: 'none', label: 'None' },\n { id: 'value', label: 'Text' },\n { id: 'background_solid', label: 'Background' },\n];\n\nexport type legendMode = 'auto' | 'on' | 'off';\n\nexport type ShowLegendLabelItem = {\n id: legendMode;\n label: string;\n description?: string;\n};\n\nexport const SHOW_LEGEND_LABELS: ShowLegendLabelItem[] = [\n { id: 'auto', label: 'Auto', description: 'Show legend for multi-series, hide legend for single series' },\n { id: 'on', label: 'On', description: 'Always show legend' },\n { id: 'off', label: 'Off', description: 'Always hide legend' },\n];\n\nexport interface StatChartOptions {\n calculation: CalculationType;\n format: FormatOptions;\n metricLabel?: string;\n thresholds?: ThresholdOptions;\n sparkline?: StatChartSparklineOptions;\n valueFontSize?: FontSizeOption;\n mappings?: ValueMapping[];\n colorMode?: ColorMode;\n legendMode?: legendMode;\n}\n\nexport interface StatChartSparklineOptions {\n color?: string;\n width?: number;\n}\n\nexport type StatChartOptionsEditorProps = OptionsEditorProps<StatChartOptions>;\n\nexport function createInitialStatChartOptions(): StatChartOptions {\n return {\n calculation: 'last-number',\n format: {\n unit: 'decimal',\n },\n sparkline: {},\n legendMode: 'auto',\n };\n}\n"],"names":["COLOR_MODE_LABELS","id","label","SHOW_LEGEND_LABELS","description","createInitialStatChartOptions","calculation","format","unit","sparkline","legendMode"],"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;AAoBjC,OAAO,MAAMA,oBAA0C;IACrD;QAAEC,IAAI;QAAQC,OAAO;IAAO;IAC5B;QAAED,IAAI;QAASC,OAAO;IAAO;IAC7B;QAAED,IAAI;QAAoBC,OAAO;IAAa;CAC/C,CAAC;AAUF,OAAO,MAAMC,qBAA4C;IACvD;QAAEF,IAAI;QAAQC,OAAO;QAAQE,aAAa;IAA8D;IACxG;QAAEH,IAAI;QAAMC,OAAO;QAAME,aAAa;IAAqB;IAC3D;QAAEH,IAAI;QAAOC,OAAO;QAAOE,aAAa;IAAqB;CAC9D,CAAC;AAqBF,OAAO,SAASC;IACd,OAAO;QACLC,aAAa;QACbC,QAAQ;YACNC,MAAM;QACR;QACAC,WAAW,CAAC;QACZC,YAAY;IACd;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/calculate-font-size.ts"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/calculate-font-size.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 { FontSizeOption, useChartsTheme } from '@perses-dev/components';\n\ninterface CalculateFontSize {\n text: string;\n fontWeight: number;\n width: number;\n height: number;\n lineHeight: number;\n maxSize?: number;\n fontSizeOverride?: FontSizeOption;\n}\n\nlet canvasContext: CanvasRenderingContext2D | null;\n\nfunction getGlobalCanvasContext(): CanvasRenderingContext2D {\n if (!canvasContext) {\n canvasContext = document.createElement('canvas').getContext('2d');\n if (canvasContext === null) {\n throw new Error('Canvas context is null.');\n }\n }\n return canvasContext;\n}\n\n/**\n * Find the optimal font size given available space\n */\nexport function useOptimalFontSize({\n text,\n fontWeight,\n width,\n height,\n lineHeight,\n maxSize,\n fontSizeOverride,\n}: CalculateFontSize): number {\n const ctx = getGlobalCanvasContext();\n const { echartsTheme } = useChartsTheme();\n\n // if user has selected a font size in the settings, use it instead of calculating the optimal size\n if (fontSizeOverride !== undefined) {\n return Number(fontSizeOverride);\n }\n\n const textStyle = echartsTheme.textStyle;\n const fontSize = Number(textStyle?.fontSize) ?? 12;\n const fontFamily = textStyle?.fontFamily ?? 'Lato';\n\n // set the font on the canvas context\n const fontStyle = `${fontWeight} ${fontSize}px ${fontFamily}`;\n ctx.font = fontStyle;\n // measure the width of the text with the given font style\n const textMetrics: TextMetrics = ctx.measureText(text);\n\n // check how much bigger we can make the font while staying within the width and height\n const fontSizeBasedOnWidth = (width / textMetrics.width) * fontSize;\n const fontSizeBasedOnHeight = height / lineHeight;\n\n // return the smaller font size\n const finalFontSize = Math.min(fontSizeBasedOnHeight, fontSizeBasedOnWidth);\n return maxSize ? Math.min(finalFontSize, maxSize) : finalFontSize;\n}\n"],"names":["useChartsTheme","canvasContext","getGlobalCanvasContext","document","createElement","getContext","Error","useOptimalFontSize","text","fontWeight","width","height","lineHeight","maxSize","fontSizeOverride","ctx","echartsTheme","undefined","Number","textStyle","fontSize","fontFamily","fontStyle","font","textMetrics","measureText","fontSizeBasedOnWidth","fontSizeBasedOnHeight","finalFontSize","Math","min"],"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,SAAyBA,cAAc,QAAQ,yBAAyB;AAYxE,IAAIC;AAEJ,SAASC;IACP,IAAI,CAACD,eAAe;QAClBA,gBAAgBE,SAASC,aAAa,CAAC,UAAUC,UAAU,CAAC;QAC5D,IAAIJ,kBAAkB,MAAM;YAC1B,MAAM,IAAIK,MAAM;QAClB;IACF;IACA,OAAOL;AACT;AAEA;;CAEC,GACD,OAAO,SAASM,mBAAmB,EACjCC,IAAI,EACJC,UAAU,EACVC,KAAK,EACLC,MAAM,EACNC,UAAU,EACVC,OAAO,EACPC,gBAAgB,EACE;IAClB,MAAMC,MAAMb;IACZ,MAAM,EAAEc,YAAY,EAAE,GAAGhB;IAEzB,mGAAmG;IACnG,IAAIc,qBAAqBG,WAAW;QAClC,OAAOC,OAAOJ;IAChB;IAEA,MAAMK,YAAYH,aAAaG,SAAS;IACxC,MAAMC,WAAWF,OAAOC,WAAWC,aAAa;IAChD,MAAMC,aAAaF,WAAWE,cAAc;IAE5C,qCAAqC;IACrC,MAAMC,YAAY,GAAGb,WAAW,CAAC,EAAEW,SAAS,GAAG,EAAEC,YAAY;IAC7DN,IAAIQ,IAAI,GAAGD;IACX,0DAA0D;IAC1D,MAAME,cAA2BT,IAAIU,WAAW,CAACjB;IAEjD,uFAAuF;IACvF,MAAMkB,uBAAuB,AAAChB,QAAQc,YAAYd,KAAK,GAAIU;IAC3D,MAAMO,wBAAwBhB,SAASC;IAEvC,+BAA+B;IAC/B,MAAMgB,gBAAgBC,KAAKC,GAAG,CAACH,uBAAuBD;IACtD,OAAOb,UAAUgB,KAAKC,GAAG,CAACF,eAAef,WAAWe;AACtD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/calculate-value.ts"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/calculate-value.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 { CalculationsMap, CalculationType, DEFAULT_CALCULATION, TimeSeries } from '@perses-dev/core';\n\nexport const calculateValue = (\n calculation: CalculationType,\n seriesData: TimeSeries\n): ReturnType<(typeof CalculationsMap)[CalculationType]> => {\n if (CalculationsMap[calculation] === undefined) {\n console.warn(`Invalid StatChart panel calculation ${calculation}, fallback to ${DEFAULT_CALCULATION}`);\n }\n const calculate = CalculationsMap[calculation] ?? CalculationsMap[DEFAULT_CALCULATION];\n return calculate(seriesData.values);\n};\n"],"names":["CalculationsMap","DEFAULT_CALCULATION","calculateValue","calculation","seriesData","undefined","console","warn","calculate","values"],"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,eAAe,EAAmBC,mBAAmB,QAAoB,mBAAmB;AAErG,OAAO,MAAMC,iBAAiB,CAC5BC,aACAC;IAEA,IAAIJ,eAAe,CAACG,YAAY,KAAKE,WAAW;QAC9CC,QAAQC,IAAI,CAAC,CAAC,oCAAoC,EAAEJ,YAAY,cAAc,EAAEF,qBAAqB;IACvG;IACA,MAAMO,YAAYR,eAAe,CAACG,YAAY,IAAIH,eAAe,CAACC,oBAAoB;IACtF,OAAOO,UAAUJ,WAAWK,MAAM;AACpC,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/data-transform.ts"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/data-transform.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 { PersesChartsTheme } from '@perses-dev/components';\nimport { LineSeriesOption } from 'echarts/charts';\nimport { StatChartSparklineOptions } from '../stat-chart-model';\n\nexport function convertSparkline(\n chartsTheme: PersesChartsTheme,\n color: string,\n sparkline?: StatChartSparklineOptions\n): LineSeriesOption | undefined {\n if (sparkline === undefined) return;\n\n return {\n lineStyle: {\n width: sparkline.width ?? chartsTheme.sparkline.width,\n color,\n opacity: 1,\n },\n areaStyle: {\n color,\n opacity: 0.4,\n },\n };\n}\n"],"names":["convertSparkline","chartsTheme","color","sparkline","undefined","lineStyle","width","opacity","areaStyle"],"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;AAMjC,OAAO,SAASA,iBACdC,WAA8B,EAC9BC,KAAa,EACbC,SAAqC;IAErC,IAAIA,cAAcC,WAAW;IAE7B,OAAO;QACLC,WAAW;YACTC,OAAOH,UAAUG,KAAK,IAAIL,YAAYE,SAAS,CAACG,KAAK;YACrDJ;YACAK,SAAS;QACX;QACAC,WAAW;YACTN;YACAK,SAAS;QACX;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/format-stat-chart-value.ts"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/format-stat-chart-value.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 { FormatOptions, formatValue } from '@perses-dev/core';\n\nexport const formatStatChartValue = (value?: string | number | null, format?: FormatOptions): string => {\n if (value === null) {\n return 'null';\n } else if (typeof value === 'number') {\n return formatValue(value, format);\n } else if (value === undefined) {\n return '';\n } else {\n return value;\n }\n};\n"],"names":["formatValue","formatStatChartValue","value","format","undefined"],"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,SAAwBA,WAAW,QAAQ,mBAAmB;AAE9D,OAAO,MAAMC,uBAAuB,CAACC,OAAgCC;IACnE,IAAID,UAAU,MAAM;QAClB,OAAO;IACT,OAAO,IAAI,OAAOA,UAAU,UAAU;QACpC,OAAOF,YAAYE,OAAOC;IAC5B,OAAO,IAAID,UAAUE,WAAW;QAC9B,OAAO;IACT,OAAO;QACL,OAAOF;IACT;AACF,EAAE"}
|
package/lib/utils/get-color.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/get-color.ts"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/get-color.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 { PersesChartsTheme } from '@perses-dev/components';\nimport { applyValueMapping, ThresholdOptions, ValueMapping } from '@perses-dev/core';\nimport { StatChartOptions } from '../stat-chart-model';\n\ntype StatChartValue = number | string | null;\n\nexport function getStatChartColor(\n chartsTheme: PersesChartsTheme,\n spec?: StatChartOptions,\n value?: StatChartValue\n): string {\n const { mappings, thresholds } = spec ?? {};\n\n // Determine the default color from thresholds or theme\n const defaultColor = thresholds?.defaultColor ?? chartsTheme.thresholds.defaultColor;\n\n if (value === undefined || value === null || value === '' || (!thresholds?.steps && !mappings)) {\n return defaultColor;\n }\n\n // Check mappings first\n if (mappings?.length) {\n const colorFromMappings = getColorFromMappings(value, mappings);\n if (colorFromMappings) {\n return colorFromMappings;\n }\n }\n\n // Check thresholds next\n if (thresholds) {\n const colorFromThresholds = getColorFromThresholds(value, thresholds, chartsTheme, defaultColor);\n if (colorFromThresholds) {\n return colorFromThresholds;\n }\n }\n\n // Fallback to default color\n return defaultColor;\n}\n\nfunction getColorFromMappings(value: StatChartValue, mappings: ValueMapping[]): string | null {\n if (mappings?.length && value !== undefined && value !== null) {\n const { color } = applyValueMapping(value, mappings);\n return color || null;\n }\n return null;\n}\n\nfunction getColorFromThresholds(\n value: StatChartValue,\n thresholds: ThresholdOptions,\n chartsTheme: PersesChartsTheme,\n defaultColor: string\n): string | null {\n if (thresholds?.steps && typeof value === 'number') {\n const matchingColors = thresholds.steps\n .map((step, index) => {\n if (value >= step.value) {\n return step.color ?? chartsTheme.thresholds.palette[index] ?? defaultColor;\n }\n return null;\n })\n .filter((color): color is string => color !== null);\n\n return matchingColors[matchingColors.length - 1] ?? null;\n }\n return null;\n}\n"],"names":["applyValueMapping","getStatChartColor","chartsTheme","spec","value","mappings","thresholds","defaultColor","undefined","steps","length","colorFromMappings","getColorFromMappings","colorFromThresholds","getColorFromThresholds","color","matchingColors","map","step","index","palette","filter"],"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;AAGjC,SAASA,iBAAiB,QAAwC,mBAAmB;AAKrF,OAAO,SAASC,kBACdC,WAA8B,EAC9BC,IAAuB,EACvBC,KAAsB;IAEtB,MAAM,EAAEC,QAAQ,EAAEC,UAAU,EAAE,GAAGH,QAAQ,CAAC;IAE1C,uDAAuD;IACvD,MAAMI,eAAeD,YAAYC,gBAAgBL,YAAYI,UAAU,CAACC,YAAY;IAEpF,IAAIH,UAAUI,aAAaJ,UAAU,QAAQA,UAAU,MAAO,CAACE,YAAYG,SAAS,CAACJ,UAAW;QAC9F,OAAOE;IACT;IAE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