@perses-dev/pie-chart-plugin 0.14.0 → 0.15.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/{PieChart.a102eecb.js → PieChart.5c25af4b.js} +4 -4
- package/__mf/js/async/121.3f985aad.js +2 -0
- package/__mf/js/async/192.e77db572.js +1 -0
- package/__mf/js/async/2.0d6a1680.js +1 -0
- package/__mf/js/async/235.2bb8ba2f.js +1 -0
- package/__mf/js/async/237.418111c6.js +2 -0
- package/__mf/js/async/274.0fa32f07.js +2 -0
- package/__mf/js/async/356.b5aee61d.js +1 -0
- package/__mf/js/async/376.d72b6d45.js +110 -0
- package/__mf/js/async/392.311100c7.js +2 -0
- package/__mf/js/async/407.2557a182.js +4 -0
- package/__mf/js/async/407.2557a182.js.LICENSE.txt +9 -0
- package/__mf/js/async/469.a5d124bd.js +1 -0
- package/__mf/js/async/470.7f042d46.js +2 -0
- package/__mf/js/async/496.ea85fb9d.js +1 -0
- package/__mf/js/async/554.ffbb20fd.js +2 -0
- package/__mf/js/async/587.fceb5f76.js +1 -0
- package/__mf/js/async/588.a2bbd130.js +1 -0
- package/__mf/js/async/603.312da395.js +1 -0
- package/__mf/js/async/616.cebd9b21.js +1 -0
- package/__mf/js/async/66.77308b27.js +1 -0
- package/__mf/js/async/71.87ecdff0.js +1 -0
- package/__mf/js/async/77.9d431bfa.js +1 -0
- package/__mf/js/async/788.cf73b628.js +43 -0
- package/__mf/js/async/{576.9e075806.js.LICENSE.txt → 788.cf73b628.js.LICENSE.txt} +41 -1
- package/__mf/js/async/873.48c1c973.js +1 -0
- package/__mf/js/async/941.1d0acff2.js +2 -0
- package/__mf/js/async/968.69813416.js +1 -0
- package/__mf/js/async/978.d64118ad.js +1 -0
- package/__mf/js/async/__federation_expose_PieChart.2e3c97fd.js +4 -0
- package/__mf/js/async/lib-router.64f2eab9.js +2 -0
- package/__mf/js/{main.bb1593b7.js → main.fa92d32d.js} +2 -2
- package/lib/PieChart.d.ts +3 -3
- package/lib/PieChart.d.ts.map +1 -1
- package/lib/PieChart.js +3 -3
- package/lib/PieChart.js.map +1 -1
- package/lib/PieChartBase.d.ts +2 -2
- package/lib/PieChartBase.d.ts.map +1 -1
- package/lib/PieChartBase.js +8 -8
- package/lib/PieChartBase.js.map +1 -1
- package/lib/PieChartOptionsEditorSettings.d.ts +2 -2
- package/lib/PieChartOptionsEditorSettings.d.ts.map +1 -1
- package/lib/PieChartOptionsEditorSettings.js +13 -10
- package/lib/PieChartOptionsEditorSettings.js.map +1 -1
- package/lib/PieChartPanel.d.ts +4 -4
- package/lib/PieChartPanel.d.ts.map +1 -1
- package/lib/PieChartPanel.js +9 -9
- package/lib/PieChartPanel.js.map +1 -1
- package/lib/bootstrap.js +2 -2
- package/lib/colors.js +3 -3
- package/lib/colors.js.map +1 -1
- 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 +6 -6
- package/lib/index.js.map +1 -1
- package/lib/pie-chart-model.d.ts +3 -3
- package/lib/pie-chart-model.d.ts.map +1 -1
- package/lib/pie-chart-model.js +1 -1
- package/lib/pie-chart-model.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/utils.d.ts +3 -3
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +5 -5
- package/lib/utils.js.map +1 -1
- package/mf-manifest.json +36 -33
- package/mf-stats.json +36 -33
- package/package.json +10 -10
- package/__mf/js/async/121.61df50b5.js +0 -2
- package/__mf/js/async/177.7624b91a.js +0 -1
- package/__mf/js/async/187.65618c74.js +0 -7
- package/__mf/js/async/187.65618c74.js.LICENSE.txt +0 -39
- package/__mf/js/async/192.d45ba757.js +0 -1
- package/__mf/js/async/2.651ba6ec.js +0 -1
- package/__mf/js/async/235.495df342.js +0 -1
- package/__mf/js/async/274.5c1e13d7.js +0 -2
- package/__mf/js/async/356.5cd094ae.js +0 -1
- package/__mf/js/async/376.196cec5c.js +0 -110
- package/__mf/js/async/392.281005cf.js +0 -2
- package/__mf/js/async/469.ea0276a5.js +0 -1
- package/__mf/js/async/470.0b301928.js +0 -2
- package/__mf/js/async/546.b800e1ff.js +0 -24
- package/__mf/js/async/546.b800e1ff.js.LICENSE.txt +0 -19
- package/__mf/js/async/554.507b3545.js +0 -2
- package/__mf/js/async/558.9bb26cf7.js +0 -1
- package/__mf/js/async/576.9e075806.js +0 -39
- package/__mf/js/async/587.a59f7544.js +0 -1
- package/__mf/js/async/603.224eeb96.js +0 -1
- package/__mf/js/async/616.702bde53.js +0 -1
- package/__mf/js/async/66.13296185.js +0 -1
- package/__mf/js/async/663.d4632bd2.js +0 -1
- package/__mf/js/async/873.8941a36f.js +0 -1
- package/__mf/js/async/941.b972dd8a.js +0 -2
- package/__mf/js/async/968.6009cb29.js +0 -1
- package/__mf/js/async/__federation_expose_PieChart.9cd45fce.js +0 -4
- package/__mf/js/async/lib-router.c182f4dd.js +0 -2
- package/lib/cjs/PieChart.js +0 -38
- package/lib/cjs/PieChartBase.js +0 -100
- package/lib/cjs/PieChartOptionsEditorSettings.js +0 -247
- package/lib/cjs/PieChartPanel.js +0 -155
- package/lib/cjs/bootstrap.js +0 -26
- package/lib/cjs/colors.js +0 -207
- 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 -41
- package/lib/cjs/pie-chart-model.js +0 -53
- package/lib/cjs/setup-tests.js +0 -19
- package/lib/cjs/utils.js +0 -163
- /package/__mf/css/async/{187.85c2cbf6.css → 788.85c2cbf6.css} +0 -0
- /package/__mf/js/async/{121.61df50b5.js.LICENSE.txt → 121.3f985aad.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{274.5c1e13d7.js.LICENSE.txt → 274.0fa32f07.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{376.196cec5c.js.LICENSE.txt → 376.d72b6d45.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{392.281005cf.js.LICENSE.txt → 392.311100c7.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{470.0b301928.js.LICENSE.txt → 470.7f042d46.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{554.507b3545.js.LICENSE.txt → 554.ffbb20fd.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{941.b972dd8a.js.LICENSE.txt → 941.1d0acff2.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{lib-router.c182f4dd.js.LICENSE.txt → lib-router.64f2eab9.js.LICENSE.txt} +0 -0
package/lib/PieChartBase.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { FormatOptions, ModeOption } from '@perses-dev/components';
|
|
2
|
+
import type { ReactElement } from 'react';
|
|
3
3
|
export interface PieChartData {
|
|
4
4
|
id?: string;
|
|
5
5
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PieChartBase.d.ts","sourceRoot":"","sources":["../../src/PieChartBase.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PieChartBase.d.ts","sourceRoot":"","sources":["../../src/PieChartBase.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAMxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAa1C,MAAM,WAAW,YAAY;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE;QACV,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IAC5B,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,YAAY,CA4DnE"}
|
package/lib/PieChartBase.js
CHANGED
|
@@ -11,14 +11,14 @@ 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 {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import { getLabelFormatter, getTooltipFormatter } from
|
|
21
|
-
|
|
14
|
+
import { Box, useTheme } from "@mui/material";
|
|
15
|
+
import { EChart, useChartsTheme } from "@perses-dev/components";
|
|
16
|
+
import { PieChart as EChartsPieChart } from "echarts/charts";
|
|
17
|
+
import { DatasetComponent, GridComponent, LegendComponent, TitleComponent, TooltipComponent } from "echarts/components";
|
|
18
|
+
import { use as registerECharts } from "echarts/core";
|
|
19
|
+
import { CanvasRenderer } from "echarts/renderers";
|
|
20
|
+
import { getLabelFormatter, getTooltipFormatter } from "./utils.js";
|
|
21
|
+
registerECharts([
|
|
22
22
|
EChartsPieChart,
|
|
23
23
|
GridComponent,
|
|
24
24
|
DatasetComponent,
|
package/lib/PieChartBase.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/PieChartBase.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 {
|
|
1
|
+
{"version":3,"sources":["../../src/PieChartBase.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 { FormatOptions, ModeOption } from '@perses-dev/components';\nimport { EChart, useChartsTheme } from '@perses-dev/components';\nimport { PieChart as EChartsPieChart } from 'echarts/charts';\nimport { DatasetComponent, GridComponent, LegendComponent, TitleComponent, TooltipComponent } from 'echarts/components';\nimport { use as registerECharts } from 'echarts/core';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport type { ReactElement } from 'react';\n\nimport { getLabelFormatter, getTooltipFormatter } from './utils';\n\nregisterECharts([\n EChartsPieChart,\n GridComponent,\n DatasetComponent,\n TitleComponent,\n TooltipComponent,\n LegendComponent,\n CanvasRenderer,\n]);\nexport interface PieChartData {\n id?: string;\n name: string;\n value: number | null;\n itemStyle?: {\n color: string;\n };\n}\n\nexport interface PieChartBaseProps {\n width: number;\n height: number;\n data: PieChartData[] | null;\n mode?: ModeOption;\n showLabels?: boolean;\n formatOptions?: FormatOptions;\n}\n\nexport function PieChartBase(props: PieChartBaseProps): ReactElement {\n const { width, height, data, mode, formatOptions, showLabels } = props;\n const chartsTheme = useChartsTheme();\n const muiTheme = useTheme();\n\n const option = {\n tooltip: {\n trigger: 'item',\n formatter: getTooltipFormatter(formatOptions),\n appendTo: document.body,\n confine: false,\n },\n series: [\n {\n type: 'pie',\n radius: '90%',\n label: {\n show: Boolean(showLabels),\n position: 'inner',\n fontSize: 14,\n formatter: getLabelFormatter(mode, formatOptions),\n overflow: 'truncate',\n fontWeight: 'bold',\n },\n center: ['50%', '50%'],\n data: data,\n emphasis: {\n itemStyle: {\n shadowBlur: 10,\n shadowOffsetX: 0,\n shadowColor: 'rgba(0, 0, 0, 0.5)',\n },\n },\n itemStyle: {\n borderRadius: 5,\n borderColor: muiTheme.palette.background.default,\n borderWidth: 2,\n },\n },\n ],\n };\n\n return (\n <Box\n style={{\n width: width,\n height: height,\n }}\n sx={{ overflow: 'auto' }}\n >\n <EChart\n sx={{\n width: '100%',\n height: '100%',\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n />\n </Box>\n );\n}\n"],"names":["Box","useTheme","EChart","useChartsTheme","PieChart","EChartsPieChart","DatasetComponent","GridComponent","LegendComponent","TitleComponent","TooltipComponent","use","registerECharts","CanvasRenderer","getLabelFormatter","getTooltipFormatter","PieChartBase","props","width","height","data","mode","formatOptions","showLabels","chartsTheme","muiTheme","option","tooltip","trigger","formatter","appendTo","document","body","confine","series","type","radius","label","show","Boolean","position","fontSize","overflow","fontWeight","center","emphasis","itemStyle","shadowBlur","shadowOffsetX","shadowColor","borderRadius","borderColor","palette","background","default","borderWidth","style","sx","theme","echartsTheme"],"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;AAE9C,SAASC,MAAM,EAAEC,cAAc,QAAQ,yBAAyB;AAChE,SAASC,YAAYC,eAAe,QAAQ,iBAAiB;AAC7D,SA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4 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import { PieChartOptionsEditorProps } from './pie-chart-model';
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { PieChartOptionsEditorProps } from './pie-chart-model';
|
|
3
3
|
export declare function PieChartOptionsEditorSettings(props: PieChartOptionsEditorProps): ReactElement;
|
|
4
4
|
//# sourceMappingURL=PieChartOptionsEditorSettings.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PieChartOptionsEditorSettings.d.ts","sourceRoot":"","sources":["../../src/PieChartOptionsEditorSettings.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PieChartOptionsEditorSettings.d.ts","sourceRoot":"","sources":["../../src/PieChartOptionsEditorSettings.tsx"],"names":[],"mappings":"AAyCA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,KAAK,EAAmB,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAGrF,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,0BAA0B,GAAG,YAAY,CAsL7F"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
1
|
// Copyright The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -11,14 +10,15 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import {
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { Button, FormControl, InputLabel, MenuItem, Select, Stack, Switch, Typography } from "@mui/material";
|
|
15
|
+
import { FormatControls, OptionsColorPicker, OptionsEditorGroup, OptionsEditorGrid, OptionsEditorColumn, SortSelector, ModeSelector, OptionsEditorControl, useChartsTheme, isPercentUnit, isUnitWithShortValues } from "@perses-dev/components";
|
|
16
|
+
import { CalculationSelector, LegendOptionsEditor } from "@perses-dev/plugin-system";
|
|
17
|
+
import { produce } from "immer";
|
|
18
|
+
import merge from "lodash/merge";
|
|
19
|
+
import omit from "lodash/omit";
|
|
20
|
+
import { useMemo } from "react";
|
|
21
|
+
import { DEFAULT_FORMAT } from "./pie-chart-model.js";
|
|
22
22
|
export function PieChartOptionsEditorSettings(props) {
|
|
23
23
|
const { onChange, value } = props;
|
|
24
24
|
const handleCalculationChange = (newCalculation)=>{
|
|
@@ -76,7 +76,10 @@ export function PieChartOptionsEditorSettings(props) {
|
|
|
76
76
|
'shortValues'
|
|
77
77
|
]), value.format);
|
|
78
78
|
const colorScheme = useMemo(()=>{
|
|
79
|
-
|
|
79
|
+
if (!Array.isArray(colorPalette)) {
|
|
80
|
+
return 'default';
|
|
81
|
+
}
|
|
82
|
+
return colorPalette.length === 1 ? 'gradient' : 'theme';
|
|
80
83
|
}, [
|
|
81
84
|
colorPalette
|
|
82
85
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/PieChartOptionsEditorSettings.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 merge from 'lodash/merge';\nimport omit from 'lodash/omit';\nimport {\n CalculationSelector,\n CalculationSelectorProps,\n CalculationType,\n LegendOptionsEditor,\n LegendOptionsEditorProps,\n} from '@perses-dev/plugin-system';\nimport { produce } from 'immer';\nimport {\n FormatControls,\n FormatControlsProps,\n OptionsColorPicker,\n OptionsEditorGroup,\n OptionsEditorGrid,\n OptionsEditorColumn,\n SortSelector,\n SortSelectorProps,\n ModeSelector,\n ModeSelectorProps,\n ModeOption,\n SortOption,\n OptionsEditorControl,\n useChartsTheme,\n FormatOptions,\n isPercentUnit,\n isUnitWithShortValues,\n} from '@perses-dev/components';\nimport {\n Button,\n FormControl,\n InputLabel,\n MenuItem,\n Select,\n Stack,\n Switch,\n SwitchProps,\n Typography,\n} from '@mui/material';\nimport { ReactElement, useMemo } from 'react';\nimport { PieChartOptions, PieChartOptionsEditorProps, DEFAULT_FORMAT } from './pie-chart-model';\n\nexport function PieChartOptionsEditorSettings(props: PieChartOptionsEditorProps): ReactElement {\n const { onChange, value } = props;\n\n const handleCalculationChange: CalculationSelectorProps['onChange'] = (newCalculation: CalculationType) => {\n onChange(\n produce(value, (draft: PieChartOptions) => {\n draft.calculation = newCalculation;\n })\n );\n };\n\n const handleLegendChange: LegendOptionsEditorProps['onChange'] = (newLegend) => {\n onChange(\n produce(value, (draft: PieChartOptions) => {\n draft.legend = newLegend;\n })\n );\n };\n\n const handleUnitChange: FormatControlsProps['onChange'] = (newFormat: FormatOptions) => {\n onChange(\n produce(value, (draft: PieChartOptions) => {\n draft.format = newFormat;\n })\n );\n };\n\n const handleSortChange: SortSelectorProps['onChange'] = (newSort: SortOption) => {\n onChange(\n produce(value, (draft: PieChartOptions) => {\n draft.sort = newSort;\n })\n );\n };\n\n const handleModeChange: ModeSelectorProps['onChange'] = (newMode: ModeOption) => {\n onChange(\n produce(value, (draft: PieChartOptions) => {\n draft.mode = newMode;\n })\n );\n };\n\n const handleShowLabelsChange: SwitchProps['onChange'] = (_: unknown, checked: boolean) => {\n onChange(\n produce(value, (draft: PieChartOptions) => {\n draft.showLabels = checked;\n })\n );\n };\n\n const chartsTheme = useChartsTheme();\n const themePalette = chartsTheme.echartsTheme.color;\n\n const colorPalette: string[] | undefined = useMemo(() => {\n return value.colorPalette || undefined;\n }, [value.colorPalette]);\n\n const handleColorChange = (color?: string[]): void => {\n onChange(\n produce(value, (draft: PieChartOptions) => {\n if (Array.isArray(color)) {\n draft.colorPalette = color;\n } else if (typeof color === 'string') {\n draft.colorPalette = [color];\n } else {\n draft.colorPalette = undefined;\n }\n })\n );\n };\n\n // ensures decimalPlaces defaults to correct value\n const format = merge(\n {},\n !value.format || isUnitWithShortValues(value.format) ? DEFAULT_FORMAT : omit(DEFAULT_FORMAT, ['shortValues']),\n value.format\n );\n\n type ColorScheme = 'default' | 'theme' | 'gradient';\n\n const colorScheme: ColorScheme = useMemo(() => {\n return Array.isArray(colorPalette) ? (colorPalette.length === 1 ? 'gradient' : 'theme') : 'default';\n }, [colorPalette]);\n\n const handleColorSchemeChange = (scheme: ColorScheme): void => {\n if (scheme === 'theme') {\n handleColorChange(themePalette as string[]);\n } else if (scheme === 'default') {\n handleColorChange();\n } else {\n // gradient: keep existing single color if present (user-chosen via OptionsColorPicker)\n if (Array.isArray(colorPalette) && colorPalette.length === 1) {\n return;\n }\n // initialize with a sensible default so the color picker shows a color\n handleColorChange(['#ff0000']);\n }\n };\n\n const colorHelpText = useMemo(() => {\n if (colorPalette === undefined) {\n return 'Colors will be automatically assigned using metrics name hash.';\n }\n if (Array.isArray(colorPalette) && colorPalette.length > 1) {\n return 'Colors will be automatically assigned using the current theme color palette.';\n }\n if (Array.isArray(colorPalette) && colorPalette.length === 1) {\n return 'All series will use a gradient based on the selected color.';\n }\n return undefined;\n }, [colorPalette]);\n\n return (\n <OptionsEditorGrid>\n <OptionsEditorColumn>\n <LegendOptionsEditor calculation=\"comparison\" value={value.legend} onChange={handleLegendChange} />\n <OptionsEditorGroup title=\"Misc\">\n <OptionsEditorControl\n label=\"Show Labels\"\n control={<Switch checked={Boolean(value.showLabels)} onChange={handleShowLabelsChange} />}\n />\n <FormatControls value={format} onChange={handleUnitChange} disabled={value.mode === 'percentage'} />\n <CalculationSelector value={value.calculation} onChange={handleCalculationChange} />\n <SortSelector value={value.sort} onChange={handleSortChange} />\n <ModeSelector value={value.mode} onChange={handleModeChange} disablePercentageMode={isPercentUnit(format)} />\n </OptionsEditorGroup>\n </OptionsEditorColumn>\n <OptionsEditorColumn>\n <OptionsEditorGroup title=\"Colors\">\n <Stack spacing={2}>\n <Stack direction=\"row\" spacing={2} alignItems=\"center\">\n <FormControl size=\"small\" sx={{ minWidth: 150 }}>\n <InputLabel>Color Scheme</InputLabel>\n <Select\n value={colorScheme}\n label=\"Color Scheme\"\n onChange={(e) => handleColorSchemeChange(e.target.value as ColorScheme)}\n >\n <MenuItem value=\"default\">Default</MenuItem>\n <MenuItem value=\"theme\">Theme</MenuItem>\n <MenuItem value=\"gradient\">Gradient</MenuItem>\n </Select>\n </FormControl>\n {Array.isArray(colorPalette) && colorPalette.length === 1 && (\n <OptionsColorPicker\n label=\"Color\"\n color={colorPalette?.[0] ?? (themePalette as string[])[0] ?? '#ff0000'}\n onColorChange={(c: string) => handleColorChange([c])}\n />\n )}\n </Stack>\n {colorHelpText && (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {colorHelpText}\n </Typography>\n )}\n </Stack>\n </OptionsEditorGroup>\n <OptionsEditorGroup title=\"Reset Settings\">\n <Button\n variant=\"outlined\"\n color=\"secondary\"\n onClick={() => {\n onChange(\n produce(value, (draft: PieChartOptions) => {\n // reset button removes all optional panel options\n draft.legend = undefined;\n draft.colorPalette = undefined;\n })\n );\n }}\n >\n Reset To Defaults\n </Button>\n </OptionsEditorGroup>\n </OptionsEditorColumn>\n </OptionsEditorGrid>\n );\n}\n"],"names":["merge","omit","CalculationSelector","LegendOptionsEditor","produce","FormatControls","OptionsColorPicker","OptionsEditorGroup","OptionsEditorGrid","OptionsEditorColumn","SortSelector","ModeSelector","OptionsEditorControl","useChartsTheme","isPercentUnit","isUnitWithShortValues","Button","FormControl","InputLabel","MenuItem","Select","Stack","Switch","Typography","useMemo","DEFAULT_FORMAT","PieChartOptionsEditorSettings","props","onChange","value","handleCalculationChange","newCalculation","draft","calculation","handleLegendChange","newLegend","legend","handleUnitChange","newFormat","format","handleSortChange","newSort","sort","handleModeChange","newMode","mode","handleShowLabelsChange","_","checked","showLabels","chartsTheme","themePalette","echartsTheme","color","colorPalette","undefined","handleColorChange","Array","isArray","colorScheme","length","handleColorSchemeChange","scheme","colorHelpText","title","label","control","Boolean","disabled","disablePercentageMode","spacing","direction","alignItems","size","sx","minWidth","e","target","onColorChange","c","variant","onClick"],"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,eAAe;AACjC,OAAOC,UAAU,cAAc;AAC/B,SACEC,mBAAmB,EAGnBC,mBAAmB,QAEd,4BAA4B;AACnC,SAASC,OAAO,QAAQ,QAAQ;AAChC,SACEC,cAAc,EAEdC,kBAAkB,EAClBC,kBAAkB,EAClBC,iBAAiB,EACjBC,mBAAmB,EACnBC,YAAY,EAEZC,YAAY,EAIZC,oBAAoB,EACpBC,cAAc,EAEdC,aAAa,EACbC,qBAAqB,QAChB,yBAAyB;AAChC,SACEC,MAAM,EACNC,WAAW,EACXC,UAAU,EACVC,QAAQ,EACRC,MAAM,EACNC,KAAK,EACLC,MAAM,EAENC,UAAU,QACL,gBAAgB;AACvB,SAAuBC,OAAO,QAAQ,QAAQ;AAC9C,SAAsDC,cAAc,QAAQ,oBAAoB;AAEhG,OAAO,SAASC,8BAA8BC,KAAiC;IAC7E,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAE,GAAGF;IAE5B,MAAMG,0BAAgE,CAACC;QACrEH,SACExB,QAAQyB,OAAO,CAAC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,KAACF;wBAAmByD,OAAM;kCACxB,cAAA,MAAC3C;4BAAMiD,SAAS;;8CACd,MAACjD;oCAAMkD,WAAU;oCAAMD,SAAS;oCAAGE,YAAW;;sDAC5C,MAACvD;4CAAYwD,MAAK;4CAAQC,IAAI;gDAAEC,UAAU;4CAAI;;8DAC5C,KAACzD;8DAAW;;8DACZ,MAACE;oDACCS,OAAO8B;oDACPM,OAAM;oDACNrC,UAAU,CAACgD,IAAMf,wBAAwBe,EAAEC,MAAM,CAAChD,KAAK;;sEAEvD,KAACV;4DAASU,OAAM;sEAAU;;sEAC1B,KAACV;4DAASU,OAAM;sEAAQ;;sEACxB,KAACV;4DAASU,OAAM;sEAAW;;;;;;wCAG9B4B,MAAMC,OAAO,CAACJ,iBAAiBA,aAAaM,MAAM,KAAK,mBACtD,KAACtD;4CACC2D,OAAM;4CACNZ,OAAOC,cAAc,CAAC,EAAE,IAAI,AAACH,YAAyB,CAAC,EAAE,IAAI;4CAC7D2B,eAAe,CAACC,IAAcvB,kBAAkB;oDAACuB;iDAAE;;;;gCAIxDhB,+BACC,KAACxC;oCAAWyD,SAAQ;oCAAQ3B,OAAM;8CAC/BU;;;;;kCAKT,KAACxD;wBAAmByD,OAAM;kCACxB,cAAA,KAAChD;4BACCgE,SAAQ;4BACR3B,OAAM;4BACN4B,SAAS;gCACPrD,SACExB,QAAQyB,OAAO,CAACG;oCACd,kDAAkD;oCAClDA,MAAMI,MAAM,GAAGmB;oCACfvB,MAAMsB,YAAY,GAAGC;gCACvB;4BAEJ;sCACD;;;;;;;AAOX"}
|
|
1
|
+
{"version":3,"sources":["../../src/PieChartOptionsEditorSettings.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 type { SwitchProps } from '@mui/material';\nimport { Button, FormControl, InputLabel, MenuItem, Select, Stack, Switch, Typography } from '@mui/material';\nimport type {\n FormatControlsProps,\n SortSelectorProps,\n ModeSelectorProps,\n ModeOption,\n SortOption,\n FormatOptions,\n} from '@perses-dev/components';\nimport {\n FormatControls,\n OptionsColorPicker,\n OptionsEditorGroup,\n OptionsEditorGrid,\n OptionsEditorColumn,\n SortSelector,\n ModeSelector,\n OptionsEditorControl,\n useChartsTheme,\n isPercentUnit,\n isUnitWithShortValues,\n} from '@perses-dev/components';\nimport type { CalculationSelectorProps, CalculationType, LegendOptionsEditorProps } from '@perses-dev/plugin-system';\nimport { CalculationSelector, LegendOptionsEditor } from '@perses-dev/plugin-system';\nimport { produce } from 'immer';\nimport merge from 'lodash/merge';\nimport omit from 'lodash/omit';\nimport type { ReactElement } from 'react';\nimport { useMemo } from 'react';\n\nimport type { PieChartOptions, PieChartOptionsEditorProps } from './pie-chart-model';\nimport { DEFAULT_FORMAT } from './pie-chart-model';\n\nexport function PieChartOptionsEditorSettings(props: PieChartOptionsEditorProps): ReactElement {\n const { onChange, value } = props;\n\n const handleCalculationChange: CalculationSelectorProps['onChange'] = (newCalculation: CalculationType) => {\n onChange(\n produce(value, (draft: PieChartOptions) => {\n draft.calculation = newCalculation;\n }),\n );\n };\n\n const handleLegendChange: LegendOptionsEditorProps['onChange'] = (newLegend) => {\n onChange(\n produce(value, (draft: PieChartOptions) => {\n draft.legend = newLegend;\n }),\n );\n };\n\n const handleUnitChange: FormatControlsProps['onChange'] = (newFormat: FormatOptions) => {\n onChange(\n produce(value, (draft: PieChartOptions) => {\n draft.format = newFormat;\n }),\n );\n };\n\n const handleSortChange: SortSelectorProps['onChange'] = (newSort: SortOption) => {\n onChange(\n produce(value, (draft: PieChartOptions) => {\n draft.sort = newSort;\n }),\n );\n };\n\n const handleModeChange: ModeSelectorProps['onChange'] = (newMode: ModeOption) => {\n onChange(\n produce(value, (draft: PieChartOptions) => {\n draft.mode = newMode;\n }),\n );\n };\n\n const handleShowLabelsChange: SwitchProps['onChange'] = (_: unknown, checked: boolean) => {\n onChange(\n produce(value, (draft: PieChartOptions) => {\n draft.showLabels = checked;\n }),\n );\n };\n\n const chartsTheme = useChartsTheme();\n const themePalette = chartsTheme.echartsTheme.color;\n\n const colorPalette: string[] | undefined = useMemo(() => {\n return value.colorPalette || undefined;\n }, [value.colorPalette]);\n\n const handleColorChange = (color?: string[]): void => {\n onChange(\n produce(value, (draft: PieChartOptions) => {\n if (Array.isArray(color)) {\n draft.colorPalette = color;\n } else if (typeof color === 'string') {\n draft.colorPalette = [color];\n } else {\n draft.colorPalette = undefined;\n }\n }),\n );\n };\n\n // ensures decimalPlaces defaults to correct value\n const format = merge(\n {},\n !value.format || isUnitWithShortValues(value.format) ? DEFAULT_FORMAT : omit(DEFAULT_FORMAT, ['shortValues']),\n value.format,\n );\n\n type ColorScheme = 'default' | 'theme' | 'gradient';\n\n const colorScheme: ColorScheme = useMemo(() => {\n if (!Array.isArray(colorPalette)) {\n return 'default';\n }\n return colorPalette.length === 1 ? 'gradient' : 'theme';\n }, [colorPalette]);\n\n const handleColorSchemeChange = (scheme: ColorScheme): void => {\n if (scheme === 'theme') {\n handleColorChange(themePalette as string[]);\n } else if (scheme === 'default') {\n handleColorChange();\n } else {\n // gradient: keep existing single color if present (user-chosen via OptionsColorPicker)\n if (Array.isArray(colorPalette) && colorPalette.length === 1) {\n return;\n }\n // initialize with a sensible default so the color picker shows a color\n handleColorChange(['#ff0000']);\n }\n };\n\n const colorHelpText = useMemo(() => {\n if (colorPalette === undefined) {\n return 'Colors will be automatically assigned using metrics name hash.';\n }\n if (Array.isArray(colorPalette) && colorPalette.length > 1) {\n return 'Colors will be automatically assigned using the current theme color palette.';\n }\n if (Array.isArray(colorPalette) && colorPalette.length === 1) {\n return 'All series will use a gradient based on the selected color.';\n }\n return undefined;\n }, [colorPalette]);\n\n return (\n <OptionsEditorGrid>\n <OptionsEditorColumn>\n <LegendOptionsEditor calculation=\"comparison\" value={value.legend} onChange={handleLegendChange} />\n <OptionsEditorGroup title=\"Misc\">\n <OptionsEditorControl\n label=\"Show Labels\"\n control={<Switch checked={Boolean(value.showLabels)} onChange={handleShowLabelsChange} />}\n />\n <FormatControls value={format} onChange={handleUnitChange} disabled={value.mode === 'percentage'} />\n <CalculationSelector value={value.calculation} onChange={handleCalculationChange} />\n <SortSelector value={value.sort} onChange={handleSortChange} />\n <ModeSelector value={value.mode} onChange={handleModeChange} disablePercentageMode={isPercentUnit(format)} />\n </OptionsEditorGroup>\n </OptionsEditorColumn>\n <OptionsEditorColumn>\n <OptionsEditorGroup title=\"Colors\">\n <Stack spacing={2}>\n <Stack direction=\"row\" spacing={2} alignItems=\"center\">\n <FormControl size=\"small\" sx={{ minWidth: 150 }}>\n <InputLabel>Color Scheme</InputLabel>\n <Select\n value={colorScheme}\n label=\"Color Scheme\"\n onChange={(e) => handleColorSchemeChange(e.target.value as ColorScheme)}\n >\n <MenuItem value=\"default\">Default</MenuItem>\n <MenuItem value=\"theme\">Theme</MenuItem>\n <MenuItem value=\"gradient\">Gradient</MenuItem>\n </Select>\n </FormControl>\n {Array.isArray(colorPalette) && colorPalette.length === 1 && (\n <OptionsColorPicker\n label=\"Color\"\n color={colorPalette?.[0] ?? (themePalette as string[])[0] ?? '#ff0000'}\n onColorChange={(c: string) => handleColorChange([c])}\n />\n )}\n </Stack>\n {colorHelpText && (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {colorHelpText}\n </Typography>\n )}\n </Stack>\n </OptionsEditorGroup>\n <OptionsEditorGroup title=\"Reset Settings\">\n <Button\n variant=\"outlined\"\n color=\"secondary\"\n onClick={() => {\n onChange(\n produce(value, (draft: PieChartOptions) => {\n // reset button removes all optional panel options\n draft.legend = undefined;\n draft.colorPalette = undefined;\n }),\n );\n }}\n >\n Reset To Defaults\n </Button>\n </OptionsEditorGroup>\n </OptionsEditorColumn>\n </OptionsEditorGrid>\n );\n}\n"],"names":["Button","FormControl","InputLabel","MenuItem","Select","Stack","Switch","Typography","FormatControls","OptionsColorPicker","OptionsEditorGroup","OptionsEditorGrid","OptionsEditorColumn","SortSelector","ModeSelector","OptionsEditorControl","useChartsTheme","isPercentUnit","isUnitWithShortValues","CalculationSelector","LegendOptionsEditor","produce","merge","omit","useMemo","DEFAULT_FORMAT","PieChartOptionsEditorSettings","props","onChange","value","handleCalculationChange","newCalculation","draft","calculation","handleLegendChange","newLegend","legend","handleUnitChange","newFormat","format","handleSortChange","newSort","sort","handleModeChange","newMode","mode","handleShowLabelsChange","_","checked","showLabels","chartsTheme","themePalette","echartsTheme","color","colorPalette","undefined","handleColorChange","Array","isArray","colorScheme","length","handleColorSchemeChange","scheme","colorHelpText","title","label","control","Boolean","disabled","disablePercentageMode","spacing","direction","alignItems","size","sx","minWidth","e","target","onColorChange","c","variant","onClick"],"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,MAAM,EAAEC,WAAW,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,KAAK,EAAEC,MAAM,EAAEC,UAAU,QAAQ,gBAAgB;AAS7G,SACEC,cAAc,EACdC,kBAAkB,EAClBC,kBAAkB,EAClBC,iBAAiB,EACjBC,mBAAmB,EACnBC,YAAY,EACZC,YAAY,EACZC,oBAAoB,EACpBC,cAAc,EACdC,aAAa,EACbC,qBAAqB,QAChB,yBAAyB;AAEhC,SAASC,mBAAmB,EAAEC,mBAAmB,QAAQ,4BAA4B;AACrF,SAASC,OAAO,QAAQ,QAAQ;AAChC,OAAOC,WAAW,eAAe;AACjC,OAAOC,UAAU,cAAc;AAE/B,SAASC,OAAO,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|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { PanelProps } from '@perses-dev/plugin-system';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { PieChartOptions } from './pie-chart-model';
|
|
1
|
+
import type { PanelProps } from '@perses-dev/plugin-system';
|
|
2
|
+
import type { TimeSeriesData } from '@perses-dev/spec';
|
|
3
|
+
import type { ReactElement } from 'react';
|
|
4
|
+
import type { PieChartOptions } from './pie-chart-model';
|
|
5
5
|
export type PieChartPanelProps = PanelProps<PieChartOptions, TimeSeriesData>;
|
|
6
6
|
export declare function PieChartPanel(props: PieChartPanelProps): ReactElement | null;
|
|
7
7
|
//# sourceMappingURL=PieChartPanel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PieChartPanel.d.ts","sourceRoot":"","sources":["../../src/PieChartPanel.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PieChartPanel.d.ts","sourceRoot":"","sources":["../../src/PieChartPanel.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAmB,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAI1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAMzD,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;AAE7E,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,YAAY,GAAG,IAAI,CA4H5E"}
|
package/lib/PieChartPanel.js
CHANGED
|
@@ -11,16 +11,16 @@ 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 { Box } from
|
|
15
|
-
import { ContentWithLegend, DEFAULT_LEGEND, useChartsTheme, useId } from
|
|
16
|
-
import { CalculationsMap, validateLegendSpec } from
|
|
17
|
-
import merge from
|
|
18
|
-
import { useMemo, useRef, useState } from
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
14
|
+
import { Box } from "@mui/material";
|
|
15
|
+
import { ContentWithLegend, DEFAULT_LEGEND, useChartsTheme, useId } from "@perses-dev/components";
|
|
16
|
+
import { CalculationsMap, validateLegendSpec } from "@perses-dev/plugin-system";
|
|
17
|
+
import merge from "lodash/merge";
|
|
18
|
+
import { useMemo, useRef, useState } from "react";
|
|
19
|
+
import { getSeriesColor } from "./colors.js";
|
|
20
|
+
import { PieChartBase } from "./PieChartBase.js";
|
|
21
|
+
import { PieChartListLegendMapper, PieChartTableLegendMapper, sortSeriesData } from "./utils.js";
|
|
22
22
|
export function PieChartPanel(props) {
|
|
23
|
-
const { spec: { calculation, sort, mode, format: formatOptions, legend: pieChartLegend, colorPalette
|
|
23
|
+
const { spec: { calculation, sort, mode, format: formatOptions, legend: pieChartLegend, colorPalette }, contentDimensions, queryResults } = props;
|
|
24
24
|
const chartsTheme = useChartsTheme();
|
|
25
25
|
const chartId = useId('time-series-panel');
|
|
26
26
|
const seriesNames = queryResults.flatMap((result)=>result?.data.series?.map((series)=>series.name) || []);
|
package/lib/PieChartPanel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/PieChartPanel.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box } from '@mui/material';\nimport {\n ChartInstance,\n ContentWithLegend,\n DEFAULT_LEGEND,\n LegendProps,\n SelectedLegendItemState,\n useChartsTheme,\n useId,\n} from '@perses-dev/components';\nimport { CalculationsMap, CalculationType, PanelProps, validateLegendSpec } from '@perses-dev/plugin-system';\nimport merge from 'lodash/merge';\nimport { ReactElement, useMemo, useRef, useState } from 'react';\nimport { TimeSeriesData } from '@perses-dev/spec';\nimport { PieChartOptions } from './pie-chart-model';\nimport { PieChartLegendMapper, PieChartListLegendMapper, PieChartTableLegendMapper, sortSeriesData } from './utils';\nimport { getSeriesColor } from './colors';\nimport { PieChartBase, PieChartData } from './PieChartBase';\n\nexport type PieChartPanelProps = PanelProps<PieChartOptions, TimeSeriesData>;\n\nexport function PieChartPanel(props: PieChartPanelProps): ReactElement | null {\n const {\n spec: { calculation, sort, mode, format: formatOptions, legend: pieChartLegend, colorPalette: colorPalette },\n contentDimensions,\n queryResults,\n } = props;\n const chartsTheme = useChartsTheme();\n const chartId = useId('time-series-panel');\n const seriesNames = queryResults.flatMap((result) => result?.data.series?.map((series) => series.name) || []);\n\n // Memoize the color list so it only regenerates when color/palette/series count changes\n const colorList = useMemo(() => {\n return getSeriesColor(seriesNames, colorPalette);\n }, [colorPalette, seriesNames]);\n\n const pieChartData = useMemo((): Array<Required<PieChartData>> => {\n const calculate = CalculationsMap[calculation as CalculationType];\n const pieChartData: Array<Required<PieChartData>> = [];\n queryResults.forEach((result, queryIndex) => {\n const series = result?.data.series ?? [];\n\n series.forEach((seriesData, seriesIndex) => {\n const seriesId = `${chartId}${seriesData.name}${seriesIndex}${queryIndex}`;\n const seriesColor = colorList[queryIndex * series.length + seriesIndex] ?? '#ff0000';\n\n const seriesItem = {\n id: seriesId,\n value: calculate(seriesData.values) ?? null,\n name: seriesData.formattedName ?? '',\n itemStyle: {\n color: seriesColor,\n },\n };\n\n pieChartData.push(seriesItem);\n });\n });\n\n return sortSeriesData(pieChartData, sort);\n }, [calculation, chartId, colorList, queryResults, sort]);\n\n const { legendItems, legendColumns } = useMemo(() => {\n const pieChartLegendMapper: PieChartLegendMapper =\n pieChartLegend?.mode === 'table' ? new PieChartTableLegendMapper() : new PieChartListLegendMapper();\n const values = pieChartLegend?.values;\n const legendItems = pieChartLegendMapper.mapToLegendItems(pieChartData, values);\n const legendColumns = pieChartLegendMapper.mapToLegendColumns(values, formatOptions);\n return {\n legendItems,\n legendColumns,\n };\n }, [formatOptions, pieChartData, pieChartLegend?.mode, pieChartLegend?.values]);\n\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 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 const [selectedLegendItems, setSelectedLegendItems] = useState<SelectedLegendItemState>('ALL');\n\n const [legendSorting, setLegendSorting] = useState<NonNullable<LegendProps['tableProps']>['sorting']>();\n\n const chartRef = useRef<ChartInstance>(null);\n\n // ensures there are fallbacks for unset properties since most\n // users should not need to customize visual display\n\n if (!contentDimensions) return null;\n\n return (\n <Box sx={{ padding: `${contentPadding}px` }}>\n <ContentWithLegend\n width={adjustedContentDimensions?.width ?? 400}\n height={adjustedContentDimensions?.height ?? 1000}\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 <PieChartBase\n data={pieChartData}\n width={width}\n height={height}\n mode={mode}\n formatOptions={formatOptions}\n showLabels={Boolean(props.spec.showLabels)}\n />\n </Box>\n );\n }}\n </ContentWithLegend>\n </Box>\n );\n}\n"],"names":["Box","ContentWithLegend","DEFAULT_LEGEND","useChartsTheme","useId","CalculationsMap","validateLegendSpec","merge","useMemo","useRef","useState","PieChartListLegendMapper","PieChartTableLegendMapper","sortSeriesData","getSeriesColor","PieChartBase","PieChartPanel","props","spec","calculation","sort","mode","format","formatOptions","legend","pieChartLegend","colorPalette","contentDimensions","queryResults","chartsTheme","chartId","seriesNames","flatMap","result","data","series","map","name","colorList","pieChartData","calculate","forEach","queryIndex","seriesData","seriesIndex","seriesId","seriesColor","length","seriesItem","id","value","values","formattedName","itemStyle","color","push","legendItems","legendColumns","pieChartLegendMapper","mapToLegendItems","mapToLegendColumns","contentPadding","container","padding","default","adjustedContentDimensions","width","height","undefined","selectedLegendItems","setSelectedLegendItems","legendSorting","setLegendSorting","chartRef","sx","minChildrenHeight","legendSize","size","legendProps","options","selectedItems","onSelectedItemsChange","tableProps","columns","sorting","onSortingChange","onItemMouseOver","e","current","highlightSeries","onItemMouseOut","clearHighlightedSeries","style","showLabels","Boolean"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,GAAG,QAAQ,gBAAgB;AACpC,SAEEC,iBAAiB,EACjBC,cAAc,EAGdC,cAAc,EACdC,KAAK,QACA,yBAAyB;AAChC,SAASC,eAAe,EAA+BC,kBAAkB,QAAQ,4BAA4B;AAC7G,OAAOC,WAAW,eAAe;AACjC,SAAuBC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAGhE,SAA+BC,wBA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AmB;YACnBC,YAAYpD,QAAQqD;YACpBC,aACEtD,UAAU;gBACRuD,SAASvD;gBACTU,MAAMsB;gBACNwB,eAAeX;gBACfY,uBAAuBX;gBACvBY,YAAY;oBACVC,SAAS1B;oBACT2B,SAASb;oBACTc,iBAAiBb;gBACnB;gBACAc,iBAAiB,CAACC,GAAG,EAAEtC,EAAE,EAAE;oBACzBwB,SAASe,OAAO,EAAEC,gBAAgB;wBAAEpD,MAAMY;oBAAG;gBAC/C;gBACAyC,gBAAgB;oBACdjB,SAASe,OAAO,EAAEG;gBACpB;YACF;sBAGD,CAAC,EAAExB,MAAM,EAAED,KAAK,EAAE;gBACjB,qBACE,KAAClE;oBAAI4F,OAAO;wBAAEzB;wBAAQD;oBAAM;8BAC1B,cAAA,KAACnD;wBACCmB,MAAMK;wBACN2B,OAAOA;wBACPC,QAAQA;wBACR9C,MAAMA;wBACNE,eAAeA;wBACfsE,YAAYC,QAAQ7E,MAAMC,IAAI,CAAC2E,UAAU;;;YAIjD;;;AAIR"}
|
|
1
|
+
{"version":3,"sources":["../../src/PieChartPanel.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box } from '@mui/material';\nimport type { ChartInstance, LegendProps, SelectedLegendItemState } from '@perses-dev/components';\nimport { ContentWithLegend, DEFAULT_LEGEND, useChartsTheme, useId } from '@perses-dev/components';\nimport type { CalculationType, PanelProps } from '@perses-dev/plugin-system';\nimport { CalculationsMap, validateLegendSpec } from '@perses-dev/plugin-system';\nimport type { TimeSeriesData } from '@perses-dev/spec';\nimport merge from 'lodash/merge';\nimport type { ReactElement } from 'react';\nimport { useMemo, useRef, useState } from 'react';\n\nimport { getSeriesColor } from './colors';\nimport type { PieChartOptions } from './pie-chart-model';\nimport type { PieChartData } from './PieChartBase';\nimport { PieChartBase } from './PieChartBase';\nimport type { PieChartLegendMapper } from './utils';\nimport { PieChartListLegendMapper, PieChartTableLegendMapper, sortSeriesData } from './utils';\n\nexport type PieChartPanelProps = PanelProps<PieChartOptions, TimeSeriesData>;\n\nexport function PieChartPanel(props: PieChartPanelProps): ReactElement | null {\n const {\n spec: { calculation, sort, mode, format: formatOptions, legend: pieChartLegend, colorPalette },\n contentDimensions,\n queryResults,\n } = props;\n const chartsTheme = useChartsTheme();\n const chartId = useId('time-series-panel');\n const seriesNames = queryResults.flatMap((result) => result?.data.series?.map((series) => series.name) || []);\n\n // Memoize the color list so it only regenerates when color/palette/series count changes\n const colorList = useMemo(() => {\n return getSeriesColor(seriesNames, colorPalette);\n }, [colorPalette, seriesNames]);\n\n const pieChartData = useMemo((): Array<Required<PieChartData>> => {\n const calculate = CalculationsMap[calculation as CalculationType];\n const pieChartData: Array<Required<PieChartData>> = [];\n queryResults.forEach((result, queryIndex) => {\n const series = result?.data.series ?? [];\n\n series.forEach((seriesData, seriesIndex) => {\n const seriesId = `${chartId}${seriesData.name}${seriesIndex}${queryIndex}`;\n const seriesColor = colorList[queryIndex * series.length + seriesIndex] ?? '#ff0000';\n\n const seriesItem = {\n id: seriesId,\n value: calculate(seriesData.values) ?? null,\n name: seriesData.formattedName ?? '',\n itemStyle: {\n color: seriesColor,\n },\n };\n\n pieChartData.push(seriesItem);\n });\n });\n\n return sortSeriesData(pieChartData, sort);\n }, [calculation, chartId, colorList, queryResults, sort]);\n\n const { legendItems, legendColumns } = useMemo(() => {\n const pieChartLegendMapper: PieChartLegendMapper =\n pieChartLegend?.mode === 'table' ? new PieChartTableLegendMapper() : new PieChartListLegendMapper();\n const values = pieChartLegend?.values;\n const legendItems = pieChartLegendMapper.mapToLegendItems(pieChartData, values);\n const legendColumns = pieChartLegendMapper.mapToLegendColumns(values, formatOptions);\n return {\n legendItems,\n legendColumns,\n };\n }, [formatOptions, pieChartData, pieChartLegend?.mode, pieChartLegend?.values]);\n\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 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 const [selectedLegendItems, setSelectedLegendItems] = useState<SelectedLegendItemState>('ALL');\n\n const [legendSorting, setLegendSorting] = useState<NonNullable<LegendProps['tableProps']>['sorting']>();\n\n const chartRef = useRef<ChartInstance>(null);\n\n // ensures there are fallbacks for unset properties since most\n // users should not need to customize visual display\n\n if (!contentDimensions) return null;\n\n return (\n <Box sx={{ padding: `${contentPadding}px` }}>\n <ContentWithLegend\n width={adjustedContentDimensions?.width ?? 400}\n height={adjustedContentDimensions?.height ?? 1000}\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 <PieChartBase\n data={pieChartData}\n width={width}\n height={height}\n mode={mode}\n formatOptions={formatOptions}\n showLabels={Boolean(props.spec.showLabels)}\n />\n </Box>\n );\n }}\n </ContentWithLegend>\n </Box>\n );\n}\n"],"names":["Box","ContentWithLegend","DEFAULT_LEGEND","useChartsTheme","useId","CalculationsMap","validateLegendSpec","merge","useMemo","useRef","useState","getSeriesColor","PieChartBase","PieChartListLegendMapper","PieChartTableLegendMapper","sortSeriesData","PieChartPanel","props","spec","calculation","sort","mode","format","formatOptions","legend","pieChartLegend","colorPalette","contentDimensions","queryResults","chartsTheme","chartId","seriesNames","flatMap","result","data","series","map","name","colorList","pieChartData","calculate","forEach","queryIndex","seriesData","seriesIndex","seriesId","seriesColor","length","seriesItem","id","value","values","formattedName","itemStyle","color","push","legendItems","legendColumns","pieChartLegendMapper","mapToLegendItems","mapToLegendColumns","contentPadding","container","padding","default","adjustedContentDimensions","width","height","undefined","selectedLegendItems","setSelectedLegendItems","legendSorting","setLegendSorting","chartRef","sx","minChildrenHeight","legendSize","size","legendProps","options","selectedItems","onSelectedItemsChange","tableProps","columns","sorting","onSortingChange","onItemMouseOver","e","current","highlightSeries","onItemMouseOut","clearHighlightedSeries","style","showLabels","Boolean"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,GAAG,QAAQ,gBAAgB;AAEpC,SAASC,iBAAiB,EAAEC,cAAc,EAAEC,cAAc,EAAEC,KAAK,QAAQ,yBAAyB;AAElG,SAASC,eAAe,EAAEC,kBAAkB,QAAQ,4BAA4B;AAEhF,OAAOC,WAAW,eAAe;AAEjC,SAASC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAElD,SAASC,cAAc,QAAQ,cAAW;AAG1C,SAASC,YAAY,QAAQ,oBAAiB;AAE9C,SAASC,wBAAwB,EAAEC,yBAAyB,EAAEC,cAAc,QAAQ,aAAU;AAI9F,OAAO,SAASC,cAAcC,KAAyB;IACrD,MAAM,EACJC,MAAM,EAAEC,WAAW,EAAEC,IAAI,EAAE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AAEtC,EAAE,EAAE;oBACzBwB,SAASe,OAAO,EAAEC,gBAAgB;wBAAEpD,MAAMY;oBAAG;gBAC/C;gBACAyC,gBAAgB;oBACdjB,SAASe,OAAO,EAAEG;gBACpB;YACF;sBAGD,CAAC,EAAExB,MAAM,EAAED,KAAK,EAAE;gBACjB,qBACE,KAAClE;oBAAI4F,OAAO;wBAAEzB;wBAAQD;oBAAM;8BAC1B,cAAA,KAACtD;wBACCsB,MAAMK;wBACN2B,OAAOA;wBACPC,QAAQA;wBACR9C,MAAMA;wBACNE,eAAeA;wBACfsE,YAAYC,QAAQ7E,MAAMC,IAAI,CAAC2E,UAAU;;;YAIjD;;;AAIR"}
|
package/lib/bootstrap.js
CHANGED
|
@@ -11,8 +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/colors.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
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 ColorHash from
|
|
13
|
+
import ColorHash from "color-hash";
|
|
14
14
|
// Valid hue values are 0 to 360 and can be adjusted to control the generated colors.
|
|
15
15
|
// More info: https://github.com/zenozeng/color-hash#custom-hue
|
|
16
16
|
// Picked min of 20 and max of 360 to exclude common threshold colors (red).
|
|
@@ -105,7 +105,7 @@ const redColorGenerator = new ColorHash({
|
|
|
105
105
|
colors.push(generateGradientColor(baseColor, gradientFactor));
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
return colors.
|
|
108
|
+
return colors.toSorted((a, b)=>{
|
|
109
109
|
const seedA = stringToSeed(seriesNames[colors.indexOf(a)] || 'fallback');
|
|
110
110
|
const seedB = stringToSeed(seriesNames[colors.indexOf(b)] || 'fallback');
|
|
111
111
|
return seedA - seedB;
|
|
@@ -117,7 +117,7 @@ const redColorGenerator = new ColorHash({
|
|
|
117
117
|
colors.push(color);
|
|
118
118
|
}
|
|
119
119
|
if (totalSeries > colorPalette.length) {
|
|
120
|
-
return colors.
|
|
120
|
+
return colors.toSorted((a, b)=>{
|
|
121
121
|
const seedA = stringToSeed(seriesNames[colors.indexOf(a)] || 'fallback');
|
|
122
122
|
const seedB = stringToSeed(seriesNames[colors.indexOf(b)] || 'fallback');
|
|
123
123
|
return seedA - seedB;
|
package/lib/colors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/colors.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 ColorHash from 'color-hash';\n\n// Valid hue values are 0 to 360 and can be adjusted to control the generated colors.\n// More info: https://github.com/zenozeng/color-hash#custom-hue\n// Picked min of 20 and max of 360 to exclude common threshold colors (red).\n// Items with \"error\" in them will always be generated as red.\nconst ERROR_HUE_CUTOFF = 20;\nconst colorGenerator = new ColorHash({ hue: { min: ERROR_HUE_CUTOFF, max: 360 } });\nconst redColorGenerator = new ColorHash({ hue: { min: 0, max: ERROR_HUE_CUTOFF } });\n\nexport interface SeriesColorProps {\n categoricalPalette: string[];\n muiPrimaryColor: string;\n seriesName: string;\n}\n\n// Color utility functions\n/**\n * Converts a number to a 2-digit hex string\n */\nfunction toHex(n: number): string {\n const hex = n.toString(16);\n return hex.length === 1 ? '0' + hex : hex;\n}\n\n/**\n * Converts a hex color string to RGB values\n */\nfunction hexToRgb(hex: string): { r: number; g: number; b: number } {\n const cleanHex = hex.replace('#', '');\n return {\n r: parseInt(cleanHex.substring(0, 2), 16),\n g: parseInt(cleanHex.substring(2, 4), 16),\n b: parseInt(cleanHex.substring(4, 6), 16),\n };\n}\n\n/**\n * Returns a deterministic number between 0 and 1 for a given string\n */\nfunction stringToSeed(str: string): number {\n let hash = 0;\n for (let i = 0; i < str.length; i++) {\n const char = str.charCodeAt(i);\n hash = (hash << 5) - hash + char;\n hash = hash & hash; // Convert to 32-bit integer\n }\n // Convert to positive number and normalize to 0-1 range\n return Math.abs(hash) / 2147483647;\n}\n\n/**\n * Helper function to generate gradient colors for series within a query\n */\nexport function generateGradientColor(baseColor: string, factor: number): string {\n // Convert hex color to RGB\n const { r, g, b } = hexToRgb(baseColor);\n\n const newR = Math.round(r * factor);\n const newG = Math.round(g * factor);\n const newB = Math.round(b * factor);\n\n return `#${toHex(newR)}${toHex(newG)}${toHex(newB)}`;\n}\n\n/**\n * Generates a list of color strings for a given number of series using a categorical palette.\n * When the number of series exceeds the palette size, it cycles through the palette\n * and applies gradients to create visual distinction.\n * @param totalSeries - The total number of series that need colors\n * @param colorPalette - Array of color strings to use as the base palette\n * @returns Array of color strings, one for each series\n */\nexport function getSeriesColor(seriesNames: string[], colorPalette?: string[]): string[] {\n const totalSeries = seriesNames.length;\n\n if (totalSeries <= 0) {\n return [];\n }\n\n const colors: string[] = [];\n\n // undefined palette - default\n if (colorPalette === undefined) {\n for (let nameIndex = 0; nameIndex < seriesNames.length; nameIndex++) {\n const seriesColor = getDefaultSeriesColor({\n categoricalPalette: ['#ff0000'],\n muiPrimaryColor: '#ff0000',\n seriesName: seriesNames[nameIndex] || '',\n });\n colors.push(seriesColor);\n }\n return colors;\n }\n\n // single color palette - generate gradients from that color\n if (colorPalette.length === 1) {\n const baseColor = colorPalette[0] ?? '#ff0000';\n for (let i = 0; i < totalSeries; i++) {\n if (i === 0) {\n colors.push(baseColor);\n } else {\n const gradientFactor = 1 * ((totalSeries - i) / totalSeries);\n colors.push(generateGradientColor(baseColor, gradientFactor));\n }\n }\n return colors.sort((a, b) => {\n const seedA = stringToSeed(seriesNames[colors.indexOf(a)] || 'fallback');\n const seedB = stringToSeed(seriesNames[colors.indexOf(b)] || 'fallback');\n return seedA - seedB;\n });\n }\n\n // multi color palette - loops through colors and adds gradient when palette is exhausted\n for (let i = 0; i < totalSeries; i++) {\n const color = getColor(colorPalette, i);\n colors.push(color);\n }\n\n if (totalSeries > colorPalette.length) {\n return colors.sort((a, b) => {\n const seedA = stringToSeed(seriesNames[colors.indexOf(a)] || 'fallback');\n const seedB = stringToSeed(seriesNames[colors.indexOf(b)] || 'fallback');\n return seedA - seedB;\n });\n }\n return colors;\n}\n\n/**\n * Default classical qualitative palette that cycles through the colors array by index.\n * When colors start repeating (after exhausting the palette), applies gradients for distinction.\n */\nexport function getColor(palette: string[], seriesIndex: number): string {\n // Handle undefined or empty palette\n if (!palette || palette.length === 0) {\n return '#ff0000';\n }\n\n const paletteTotalColors = palette.length;\n const paletteIndex = seriesIndex % paletteTotalColors;\n const baseColor = palette[paletteIndex] ?? '#ff0000';\n\n // If we haven't exhausted the palette yet, use the original color\n if (seriesIndex < paletteTotalColors) {\n return baseColor;\n }\n\n // Calculate which \"cycle\" we're in (0 = first repeat, 1 = second repeat, etc.)\n const cycleNumber = Math.floor(seriesIndex / paletteTotalColors);\n\n // Apply gradient based on cycle number to create visual distinction\n const gradientFactor = Math.min(1 - cycleNumber * 0.2, 1);\n return generateGradientColor(baseColor, gradientFactor);\n}\n\nfunction computeConsistentColor(name: string, error: boolean): string {\n const [hue, saturation, lightness] = error ? redColorGenerator.hsl(name) : colorGenerator.hsl(name);\n const saturationPercent = `${(saturation * 100).toFixed(0)}%`;\n const lightnessPercent = `${(lightness * 100).toFixed(0)}%`;\n return `hsla(${hue.toFixed(2)},${saturationPercent},${lightnessPercent},0.9)`;\n}\n\n// To check whether a color has already been generated for a given string.\n// TODO: Predefined color aliases will be defined here\nconst colorLookup: Record<string, string> = {};\n\n/**\n * Return a consistent color for (name, error) tuple\n */\nexport function getConsistentColor(name: string, error: boolean): string {\n const key = `${name}_____${error}`;\n let value = colorLookup[key];\n if (!value) {\n value = computeConsistentColor(name, error);\n colorLookup[key] = value;\n }\n return value;\n}\n\n/*\n * Generate a consistent series name color (if series name includes 'error', it will have a red hue).\n */\nexport function getConsistentSeriesNameColor(inputString: string): string {\n return getConsistentColor(inputString, inputString.toLowerCase().includes('error'));\n}\n\n/**\n * Get line color as well as color for tooltip and legend, account for whether palette is 'categorical' or 'auto' aka generative\n */\nexport function getDefaultSeriesColor(props: SeriesColorProps): string {\n const { categoricalPalette, muiPrimaryColor, seriesName } = props;\n\n // Fallback is unlikely to set unless echarts theme palette in charts theme provider is undefined.\n const fallbackColor =\n Array.isArray(categoricalPalette) && categoricalPalette[0]\n ? (categoricalPalette[0] as string) // Needed since echarts color property isn't always an array.\n : muiPrimaryColor;\n\n return getAutoPaletteColor(seriesName, fallbackColor);\n}\n\n/**\n * Get color from generative color palette, this approaches uses series name as the seed and\n * allows for consistent colors across panels (when all panels use this approach).\n */\nexport function getAutoPaletteColor(name: string, fallbackColor: string): string {\n // corresponds to 'Auto' in palette.kind for generative color palette\n const generatedColor = getConsistentSeriesNameColor(name);\n return generatedColor ?? fallbackColor;\n}\n"],"names":["ColorHash","ERROR_HUE_CUTOFF","colorGenerator","hue","min","max","redColorGenerator","toHex","n","hex","toString","length","hexToRgb","cleanHex","replace","r","parseInt","substring","g","b","stringToSeed","str","hash","i","char","charCodeAt","Math","abs","generateGradientColor","baseColor","factor","newR","round","newG","newB","getSeriesColor","seriesNames","colorPalette","totalSeries","colors","undefined","nameIndex","seriesColor","getDefaultSeriesColor","categoricalPalette","muiPrimaryColor","seriesName","push","gradientFactor","sort","a","seedA","indexOf","seedB","color","getColor","palette","seriesIndex","paletteTotalColors","paletteIndex","cycleNumber","floor","computeConsistentColor","name","error","saturation","lightness","hsl","saturationPercent","toFixed","lightnessPercent","colorLookup","getConsistentColor","key","value","getConsistentSeriesNameColor","inputString","toLowerCase","includes","props","fallbackColor","Array","isArray","getAutoPaletteColor","generatedColor"],"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,eAAe,aAAa;AAEnC,qFAAqF;AACrF,+DAA+D;AAC/D,4EAA4E;AAC5E,8DAA8D;AAC9D,MAAMC,mBAAmB;AACzB,MAAMC,iBAAiB,IAAIF,UAAU;IAAEG,KAAK;QAAEC,KAAKH;QAAkBI,KAAK;IAAI;AAAE;AAChF,MAAMC,oBAAoB,IAAIN,UAAU;IAAEG,KAAK;QAAEC,KAAK;QAAGC,KAAKJ;IAAiB;AAAE;AAQjF,0BAA0B;AAC1B;;CAEC,GACD,SAASM,MAAMC,CAAS;IACtB,MAAMC,MAAMD,EAAEE,QAAQ,CAAC;IACvB,OAAOD,IAAIE,MAAM,KAAK,IAAI,MAAMF,MAAMA;AACxC;AAEA;;CAEC,GACD,SAASG,SAASH,GAAW;IAC3B,MAAMI,WAAWJ,IAAIK,OAAO,CAAC,KAAK;IAClC,OAAO;QACLC,GAAGC,SAASH,SAASI,SAAS,CAAC,GAAG,IAAI;QACtCC,GAAGF,SAASH,SAASI,SAAS,CAAC,GAAG,IAAI;QACtCE,GAAGH,SAASH,SAASI,SAAS,CAAC,GAAG,IAAI;IACxC;AACF;AAEA;;CAEC,GACD,SAASG,aAAaC,GAAW;IAC/B,IAAIC,OAAO;IACX,IAAK,IAAIC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,uBAAuBA,kBAAkB,CAAC,EAAE,GACrDA,kBAAkB,CAAC,EAAE,CAAY,6DAA6D;OAC/FC;IAEN,OAAOsC,oBAAoBrC,YAAYkC;AACzC;AAEA;;;CAGC,GACD,OAAO,SAASG,oBAAoBpB,IAAY,EAAEiB,aAAqB;IACrE,qEAAqE;IACrE,MAAMI,iBAAiBT,6BAA6BZ;IACpD,OAAOqB,kBAAkBJ;AAC3B"}
|
|
1
|
+
{"version":3,"sources":["../../src/colors.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 ColorHash from 'color-hash';\n\n// Valid hue values are 0 to 360 and can be adjusted to control the generated colors.\n// More info: https://github.com/zenozeng/color-hash#custom-hue\n// Picked min of 20 and max of 360 to exclude common threshold colors (red).\n// Items with \"error\" in them will always be generated as red.\nconst ERROR_HUE_CUTOFF = 20;\nconst colorGenerator = new ColorHash({ hue: { min: ERROR_HUE_CUTOFF, max: 360 } });\nconst redColorGenerator = new ColorHash({ hue: { min: 0, max: ERROR_HUE_CUTOFF } });\n\nexport interface SeriesColorProps {\n categoricalPalette: string[];\n muiPrimaryColor: string;\n seriesName: string;\n}\n\n// Color utility functions\n/**\n * Converts a number to a 2-digit hex string\n */\nfunction toHex(n: number): string {\n const hex = n.toString(16);\n return hex.length === 1 ? '0' + hex : hex;\n}\n\n/**\n * Converts a hex color string to RGB values\n */\nfunction hexToRgb(hex: string): { r: number; g: number; b: number } {\n const cleanHex = hex.replace('#', '');\n return {\n r: parseInt(cleanHex.substring(0, 2), 16),\n g: parseInt(cleanHex.substring(2, 4), 16),\n b: parseInt(cleanHex.substring(4, 6), 16),\n };\n}\n\n/**\n * Returns a deterministic number between 0 and 1 for a given string\n */\nfunction stringToSeed(str: string): number {\n let hash = 0;\n for (let i = 0; i < str.length; i++) {\n const char = str.charCodeAt(i);\n hash = (hash << 5) - hash + char;\n hash = hash & hash; // Convert to 32-bit integer\n }\n // Convert to positive number and normalize to 0-1 range\n return Math.abs(hash) / 2147483647;\n}\n\n/**\n * Helper function to generate gradient colors for series within a query\n */\nexport function generateGradientColor(baseColor: string, factor: number): string {\n // Convert hex color to RGB\n const { r, g, b } = hexToRgb(baseColor);\n\n const newR = Math.round(r * factor);\n const newG = Math.round(g * factor);\n const newB = Math.round(b * factor);\n\n return `#${toHex(newR)}${toHex(newG)}${toHex(newB)}`;\n}\n\n/**\n * Generates a list of color strings for a given number of series using a categorical palette.\n * When the number of series exceeds the palette size, it cycles through the palette\n * and applies gradients to create visual distinction.\n * @param totalSeries - The total number of series that need colors\n * @param colorPalette - Array of color strings to use as the base palette\n * @returns Array of color strings, one for each series\n */\nexport function getSeriesColor(seriesNames: string[], colorPalette?: string[]): string[] {\n const totalSeries = seriesNames.length;\n\n if (totalSeries <= 0) {\n return [];\n }\n\n const colors: string[] = [];\n\n // undefined palette - default\n if (colorPalette === undefined) {\n for (let nameIndex = 0; nameIndex < seriesNames.length; nameIndex++) {\n const seriesColor = getDefaultSeriesColor({\n categoricalPalette: ['#ff0000'],\n muiPrimaryColor: '#ff0000',\n seriesName: seriesNames[nameIndex] || '',\n });\n colors.push(seriesColor);\n }\n return colors;\n }\n\n // single color palette - generate gradients from that color\n if (colorPalette.length === 1) {\n const baseColor = colorPalette[0] ?? '#ff0000';\n for (let i = 0; i < totalSeries; i++) {\n if (i === 0) {\n colors.push(baseColor);\n } else {\n const gradientFactor = 1 * ((totalSeries - i) / totalSeries);\n colors.push(generateGradientColor(baseColor, gradientFactor));\n }\n }\n return colors.toSorted((a, b) => {\n const seedA = stringToSeed(seriesNames[colors.indexOf(a)] || 'fallback');\n const seedB = stringToSeed(seriesNames[colors.indexOf(b)] || 'fallback');\n return seedA - seedB;\n });\n }\n\n // multi color palette - loops through colors and adds gradient when palette is exhausted\n for (let i = 0; i < totalSeries; i++) {\n const color = getColor(colorPalette, i);\n colors.push(color);\n }\n\n if (totalSeries > colorPalette.length) {\n return colors.toSorted((a, b) => {\n const seedA = stringToSeed(seriesNames[colors.indexOf(a)] || 'fallback');\n const seedB = stringToSeed(seriesNames[colors.indexOf(b)] || 'fallback');\n return seedA - seedB;\n });\n }\n return colors;\n}\n\n/**\n * Default classical qualitative palette that cycles through the colors array by index.\n * When colors start repeating (after exhausting the palette), applies gradients for distinction.\n */\nexport function getColor(palette: string[], seriesIndex: number): string {\n // Handle undefined or empty palette\n if (!palette || palette.length === 0) {\n return '#ff0000';\n }\n\n const paletteTotalColors = palette.length;\n const paletteIndex = seriesIndex % paletteTotalColors;\n const baseColor = palette[paletteIndex] ?? '#ff0000';\n\n // If we haven't exhausted the palette yet, use the original color\n if (seriesIndex < paletteTotalColors) {\n return baseColor;\n }\n\n // Calculate which \"cycle\" we're in (0 = first repeat, 1 = second repeat, etc.)\n const cycleNumber = Math.floor(seriesIndex / paletteTotalColors);\n\n // Apply gradient based on cycle number to create visual distinction\n const gradientFactor = Math.min(1 - cycleNumber * 0.2, 1);\n return generateGradientColor(baseColor, gradientFactor);\n}\n\nfunction computeConsistentColor(name: string, error: boolean): string {\n const [hue, saturation, lightness] = error ? redColorGenerator.hsl(name) : colorGenerator.hsl(name);\n const saturationPercent = `${(saturation * 100).toFixed(0)}%`;\n const lightnessPercent = `${(lightness * 100).toFixed(0)}%`;\n return `hsla(${hue.toFixed(2)},${saturationPercent},${lightnessPercent},0.9)`;\n}\n\n// To check whether a color has already been generated for a given string.\n// TODO: Predefined color aliases will be defined here\nconst colorLookup: Record<string, string> = {};\n\n/**\n * Return a consistent color for (name, error) tuple\n */\nexport function getConsistentColor(name: string, error: boolean): string {\n const key = `${name}_____${error}`;\n let value = colorLookup[key];\n if (!value) {\n value = computeConsistentColor(name, error);\n colorLookup[key] = value;\n }\n return value;\n}\n\n/*\n * Generate a consistent series name color (if series name includes 'error', it will have a red hue).\n */\nexport function getConsistentSeriesNameColor(inputString: string): string {\n return getConsistentColor(inputString, inputString.toLowerCase().includes('error'));\n}\n\n/**\n * Get line color as well as color for tooltip and legend, account for whether palette is 'categorical' or 'auto' aka generative\n */\nexport function getDefaultSeriesColor(props: SeriesColorProps): string {\n const { categoricalPalette, muiPrimaryColor, seriesName } = props;\n\n // Fallback is unlikely to set unless echarts theme palette in charts theme provider is undefined.\n const fallbackColor =\n Array.isArray(categoricalPalette) && categoricalPalette[0]\n ? (categoricalPalette[0] as string) // Needed since echarts color property isn't always an array.\n : muiPrimaryColor;\n\n return getAutoPaletteColor(seriesName, fallbackColor);\n}\n\n/**\n * Get color from generative color palette, this approaches uses series name as the seed and\n * allows for consistent colors across panels (when all panels use this approach).\n */\nexport function getAutoPaletteColor(name: string, fallbackColor: string): string {\n // corresponds to 'Auto' in palette.kind for generative color palette\n const generatedColor = getConsistentSeriesNameColor(name);\n return generatedColor ?? fallbackColor;\n}\n"],"names":["ColorHash","ERROR_HUE_CUTOFF","colorGenerator","hue","min","max","redColorGenerator","toHex","n","hex","toString","length","hexToRgb","cleanHex","replace","r","parseInt","substring","g","b","stringToSeed","str","hash","i","char","charCodeAt","Math","abs","generateGradientColor","baseColor","factor","newR","round","newG","newB","getSeriesColor","seriesNames","colorPalette","totalSeries","colors","undefined","nameIndex","seriesColor","getDefaultSeriesColor","categoricalPalette","muiPrimaryColor","seriesName","push","gradientFactor","toSorted","a","seedA","indexOf","seedB","color","getColor","palette","seriesIndex","paletteTotalColors","paletteIndex","cycleNumber","floor","computeConsistentColor","name","error","saturation","lightness","hsl","saturationPercent","toFixed","lightnessPercent","colorLookup","getConsistentColor","key","value","getConsistentSeriesNameColor","inputString","toLowerCase","includes","props","fallbackColor","Array","isArray","getAutoPaletteColor","generatedColor"],"mappings":"AAAA,+BAA+B;AAC/B,kE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 +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"}
|
package/lib/index-federation.js
CHANGED
|
@@ -10,6 +10,6 @@
|
|
|
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(
|
|
13
|
+
import("./bootstrap.js");
|
|
14
14
|
|
|
15
15
|
//# sourceMappingURL=index-federation.js.map
|
package/lib/index.js
CHANGED
|
@@ -10,11 +10,11 @@
|
|
|
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
|
-
export * from
|
|
14
|
-
export { getPluginModule } from
|
|
15
|
-
export * from
|
|
16
|
-
export * from
|
|
17
|
-
export * from
|
|
18
|
-
export * from
|
|
13
|
+
export * from "./PieChartPanel.js";
|
|
14
|
+
export { getPluginModule } from "./getPluginModule.js";
|
|
15
|
+
export * from "./colors.js";
|
|
16
|
+
export * from "./pie-chart-model.js";
|
|
17
|
+
export * from "./PieChart.js";
|
|
18
|
+
export * from "./PieChartOptionsEditorSettings.js";
|
|
19
19
|
|
|
20
20
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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 * from './PieChartPanel';\nexport { getPluginModule } from './getPluginModule';\nexport * from './colors';\nexport * from './pie-chart-model';\nexport * from './PieChart';\nexport * from './PieChartOptionsEditorSettings';\n"],"names":["getPluginModule"],"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;AAEjC,cAAc,
|
|
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 * from './PieChartPanel';\nexport { getPluginModule } from './getPluginModule';\nexport * from './colors';\nexport * from './pie-chart-model';\nexport * from './PieChart';\nexport * from './PieChartOptionsEditorSettings';\n"],"names":["getPluginModule"],"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;AAEjC,cAAc,qBAAkB;AAChC,SAASA,eAAe,QAAQ,uBAAoB;AACpD,cAAc,cAAW;AACzB,cAAc,uBAAoB;AAClC,cAAc,gBAAa;AAC3B,cAAc,qCAAkC"}
|
package/lib/pie-chart-model.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FormatOptions, ModeOption, SortOption } from '@perses-dev/components';
|
|
2
|
-
import { CalculationType, LegendSpecOptions, OptionsEditorProps } from '@perses-dev/plugin-system';
|
|
3
|
-
import { Definition } from '@perses-dev/spec';
|
|
1
|
+
import type { FormatOptions, ModeOption, SortOption } from '@perses-dev/components';
|
|
2
|
+
import type { CalculationType, LegendSpecOptions, OptionsEditorProps } from '@perses-dev/plugin-system';
|
|
3
|
+
import type { Definition } from '@perses-dev/spec';
|
|
4
4
|
export declare const DEFAULT_FORMAT: FormatOptions;
|
|
5
5
|
export declare const DEFAULT_SORT: SortOption;
|
|
6
6
|
export declare const DEFAULT_MODE: ModeOption;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pie-chart-model.d.ts","sourceRoot":"","sources":["../../src/pie-chart-model.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"pie-chart-model.d.ts","sourceRoot":"","sources":["../../src/pie-chart-model.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpF,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAExG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,eAAO,MAAM,cAAc,EAAE,aAAsD,CAAC;AACpF,eAAO,MAAM,YAAY,EAAE,UAAmB,CAAC;AAC/C,eAAO,MAAM,YAAY,EAAE,UAAoB,CAAC;AAEhD,MAAM,WAAW,kBAAmB,SAAQ,UAAU,CAAC,eAAe,CAAC;IACrE,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,eAAe,CAAC;IAC7B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED,MAAM,MAAM,0BAA0B,GAAG,kBAAkB,CAAC,eAAe,CAAC,CAAC;AAE7E,wBAAgB,4BAA4B,IAAI,eAAe,CAS9D"}
|
package/lib/pie-chart-model.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
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 { DEFAULT_CALCULATION } from
|
|
13
|
+
import { DEFAULT_CALCULATION } from "@perses-dev/plugin-system";
|
|
14
14
|
export const DEFAULT_FORMAT = {
|
|
15
15
|
unit: 'decimal',
|
|
16
16
|
shortValues: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/pie-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 { FormatOptions, ModeOption, SortOption } from '@perses-dev/components';\nimport { CalculationType,
|
|
1
|
+
{"version":3,"sources":["../../src/pie-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 type { FormatOptions, ModeOption, SortOption } from '@perses-dev/components';\nimport type { CalculationType, LegendSpecOptions, OptionsEditorProps } from '@perses-dev/plugin-system';\nimport { DEFAULT_CALCULATION } from '@perses-dev/plugin-system';\nimport type { Definition } from '@perses-dev/spec';\n\nexport const DEFAULT_FORMAT: FormatOptions = { unit: 'decimal', shortValues: true };\nexport const DEFAULT_SORT: SortOption = 'desc';\nexport const DEFAULT_MODE: ModeOption = 'value';\n\nexport interface BarChartDefinition extends Definition<PieChartOptions> {\n kind: 'PieChart';\n}\n\nexport interface PieChartOptions {\n calculation: CalculationType;\n format?: FormatOptions;\n colorPalette?: string[];\n legend?: LegendSpecOptions;\n mode?: ModeOption;\n radius: number;\n showLabels?: boolean;\n sort?: SortOption;\n}\n\nexport type PieChartOptionsEditorProps = OptionsEditorProps<PieChartOptions>;\n\nexport function createInitialPieChartOptions(): PieChartOptions {\n return {\n calculation: DEFAULT_CALCULATION,\n format: DEFAULT_FORMAT,\n mode: DEFAULT_MODE,\n radius: 50,\n showLabels: false,\n sort: DEFAULT_SORT,\n };\n}\n"],"names":["DEFAULT_CALCULATION","DEFAULT_FORMAT","unit","shortValues","DEFAULT_SORT","DEFAULT_MODE","createInitialPieChartOptions","calculation","format","mode","radius","showLabels","sort"],"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,4BAA4B;AAGhE,OAAO,MAAMC,iBAAgC;IAAEC,MAAM;IAAWC,aAAa;AAAK,EAAE;AACpF,OAAO,MAAMC,eAA2B,OAAO;AAC/C,OAAO,MAAMC,eAA2B,QAAQ;AAmBhD,OAAO,SAASC;IACd,OAAO;QACLC,aAAaP;QACbQ,QAAQP;QACRQ,MAAMJ;QACNK,QAAQ;QACRC,YAAY;QACZC,MAAMR;IACR;AACF"}
|
package/lib/setup-tests.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import '@testing-library/jest-dom';
|
|
1
|
+
import '@testing-library/jest-dom/vitest';
|
|
2
2
|
//# sourceMappingURL=setup-tests.d.ts.map
|
package/lib/setup-tests.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-tests.d.ts","sourceRoot":"","sources":["../../src/setup-tests.ts"],"names":[],"mappings":"AAaA,OAAO,
|
|
1
|
+
{"version":3,"file":"setup-tests.d.ts","sourceRoot":"","sources":["../../src/setup-tests.ts"],"names":[],"mappings":"AAaA,OAAO,kCAAkC,CAAC"}
|
package/lib/setup-tests.js
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
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
|
|
13
|
+
import "@testing-library/jest-dom/vitest";
|
|
14
14
|
// Always mock e-charts during tests since we don't have a proper canvas in jsdom
|
|
15
|
-
|
|
15
|
+
vi.mock('echarts/core');
|
|
16
16
|
|
|
17
17
|
//# sourceMappingURL=setup-tests.js.map
|
package/lib/setup-tests.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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\
|
|
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/vitest';\n\n// Always mock e-charts during tests since we don't have a proper canvas in jsdom\nvi.mock('echarts/core');\n"],"names":["vi","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,mCAAmC;AAE1C,iFAAiF;AACjFA,GAAGC,IAAI,CAAC"}
|