@perses-dev/components 0.0.0-snapshot-time-range-height-80d08fc → 0.0.0-snapshot-test-theming-76fd1cc
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/dist/GaugeChart/GaugeChart.d.ts +11 -2
- package/dist/GaugeChart/GaugeChart.d.ts.map +1 -1
- package/dist/GaugeChart/GaugeChart.js +58 -10
- package/dist/GaugeChart/GaugeChart.js.map +1 -1
- package/dist/InfoTooltip/InfoTooltip.d.ts +3 -1
- package/dist/InfoTooltip/InfoTooltip.d.ts.map +1 -1
- package/dist/InfoTooltip/InfoTooltip.js +4 -2
- package/dist/InfoTooltip/InfoTooltip.js.map +1 -1
- package/dist/LegendOptionsEditor/LegendOptionsEditor.d.ts +8 -0
- package/dist/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -0
- package/dist/LegendOptionsEditor/LegendOptionsEditor.js +82 -0
- package/dist/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -0
- package/dist/LegendOptionsEditor/LegendOptionsEditor.test.d.ts +2 -0
- package/dist/LegendOptionsEditor/LegendOptionsEditor.test.d.ts.map +1 -0
- package/dist/LegendOptionsEditor/LegendOptionsEditor.test.js +41 -0
- package/dist/LegendOptionsEditor/LegendOptionsEditor.test.js.map +1 -0
- package/dist/LegendOptionsEditor/index.d.ts +2 -0
- package/dist/LegendOptionsEditor/index.d.ts.map +1 -0
- package/dist/LegendOptionsEditor/index.js +15 -0
- package/dist/LegendOptionsEditor/index.js.map +1 -0
- package/dist/LineChart/LineChart.d.ts +2 -3
- package/dist/LineChart/LineChart.d.ts.map +1 -1
- package/dist/LineChart/LineChart.js +35 -32
- package/dist/LineChart/LineChart.js.map +1 -1
- package/dist/StatChart/StatChart.test.js +9 -2
- package/dist/StatChart/StatChart.test.js.map +1 -1
- package/dist/Tooltip/TooltipContent.d.ts.map +1 -1
- package/dist/Tooltip/TooltipContent.js +1 -1
- package/dist/Tooltip/TooltipContent.js.map +1 -1
- package/dist/UnitSelector/UnitSelector.test.js +3 -4
- package/dist/UnitSelector/UnitSelector.test.js.map +1 -1
- package/dist/cjs/GaugeChart/GaugeChart.js +66 -15
- package/dist/cjs/InfoTooltip/InfoTooltip.js +4 -2
- package/dist/cjs/LegendOptionsEditor/LegendOptionsEditor.js +88 -0
- package/dist/cjs/LegendOptionsEditor/LegendOptionsEditor.test.js +48 -0
- package/dist/cjs/LegendOptionsEditor/index.js +28 -0
- package/dist/cjs/LineChart/LineChart.js +34 -31
- package/dist/cjs/StatChart/StatChart.test.js +9 -2
- package/dist/cjs/Tooltip/TooltipContent.js +1 -1
- package/dist/cjs/UnitSelector/UnitSelector.test.js +3 -4
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/model/graph.js +14 -3
- package/dist/cjs/model/units/bytes.js +32 -6
- package/dist/cjs/model/units/time.js +1 -1
- package/dist/cjs/model/units/units.js +1 -4
- package/dist/cjs/model/units/units.test.js +153 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/model/graph.d.ts +4 -2
- package/dist/model/graph.d.ts.map +1 -1
- package/dist/model/graph.js +4 -0
- package/dist/model/graph.js.map +1 -1
- package/dist/model/units/bytes.d.ts +6 -1
- package/dist/model/units/bytes.d.ts.map +1 -1
- package/dist/model/units/bytes.js +35 -7
- package/dist/model/units/bytes.js.map +1 -1
- package/dist/model/units/time.js +1 -1
- package/dist/model/units/time.js.map +1 -1
- package/dist/model/units/units.d.ts.map +1 -1
- package/dist/model/units/units.js +1 -4
- package/dist/model/units/units.js.map +1 -1
- package/dist/model/units/units.test.d.ts +2 -0
- package/dist/model/units/units.test.d.ts.map +1 -0
- package/dist/model/units/units.test.js +151 -0
- package/dist/model/units/units.test.js.map +1 -0
- package/package.json +2 -2
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { GaugeSeriesOption } from 'echarts/charts';
|
|
3
3
|
import { UnitOptions } from '../model/units';
|
|
4
|
-
export declare type
|
|
4
|
+
export declare type GaugeChartValue = number | null | undefined;
|
|
5
|
+
export declare type GaugeSeries = {
|
|
6
|
+
value: GaugeChartValue;
|
|
7
|
+
label: string;
|
|
8
|
+
};
|
|
5
9
|
interface GaugeChartProps {
|
|
6
10
|
width: number;
|
|
7
11
|
height: number;
|
|
8
|
-
data:
|
|
12
|
+
data: GaugeSeries;
|
|
9
13
|
unit: UnitOptions;
|
|
10
14
|
axisLine: GaugeSeriesOption['axisLine'];
|
|
11
15
|
max?: number;
|
|
12
16
|
}
|
|
13
17
|
export declare function GaugeChart(props: GaugeChartProps): JSX.Element;
|
|
18
|
+
/**
|
|
19
|
+
* Responsive font size depending on number of characters, clamp used
|
|
20
|
+
* to ensure size stays within given range
|
|
21
|
+
*/
|
|
22
|
+
export declare function getResponsiveValueSize(value: number, unit: UnitOptions, width: number, height: number): string;
|
|
14
23
|
export {};
|
|
15
24
|
//# sourceMappingURL=GaugeChart.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GaugeChart.d.ts","sourceRoot":"","sources":["../../src/GaugeChart/GaugeChart.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAmC,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAIpF,OAAO,EAAe,WAAW,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"GaugeChart.d.ts","sourceRoot":"","sources":["../../src/GaugeChart/GaugeChart.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAmC,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAIpF,OAAO,EAAe,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAU1D,oBAAY,eAAe,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAExD,oBAAY,WAAW,GAAG;IACxB,KAAK,EAAE,eAAe,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAC;IACxC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,eAkJhD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAWrG"}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
-
import {
|
|
14
|
+
import { useDeepMemo } from '@perses-dev/core';
|
|
15
15
|
import { use } from 'echarts/core';
|
|
16
16
|
import { GaugeChart as EChartsGaugeChart } from 'echarts/charts';
|
|
17
17
|
import { GridComponent, TitleComponent, TooltipComponent } from 'echarts/components';
|
|
@@ -26,12 +26,19 @@ use([
|
|
|
26
26
|
TooltipComponent,
|
|
27
27
|
CanvasRenderer
|
|
28
28
|
]);
|
|
29
|
+
const PROGRESS_WIDTH = 16;
|
|
30
|
+
// adjusts when to show pointer icon
|
|
31
|
+
const GAUGE_SMALL_BREAKPOINT = 170;
|
|
29
32
|
export function GaugeChart(props) {
|
|
30
33
|
const { width , height , data , unit , axisLine , max } = props;
|
|
31
34
|
const chartsTheme = useChartsTheme();
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
// useDeepMemo ensures value size util does not rerun everytime you hover on the chart
|
|
36
|
+
const option = useDeepMemo(()=>{
|
|
37
|
+
var ref;
|
|
38
|
+
if (data.value === undefined || data.value === null) return chartsTheme.noDataOption;
|
|
39
|
+
// adjusts fontSize depending on number of characters
|
|
40
|
+
const valueSizeClamp = getResponsiveValueSize(data.value, unit, width, height);
|
|
41
|
+
var ref1;
|
|
35
42
|
return {
|
|
36
43
|
title: {
|
|
37
44
|
show: false
|
|
@@ -54,7 +61,7 @@ export function GaugeChart(props) {
|
|
|
54
61
|
silent: true,
|
|
55
62
|
progress: {
|
|
56
63
|
show: true,
|
|
57
|
-
width:
|
|
64
|
+
width: PROGRESS_WIDTH,
|
|
58
65
|
itemStyle: {
|
|
59
66
|
color: 'auto'
|
|
60
67
|
}
|
|
@@ -70,7 +77,7 @@ export function GaugeChart(props) {
|
|
|
70
77
|
'#e1e5e9'
|
|
71
78
|
]
|
|
72
79
|
],
|
|
73
|
-
width:
|
|
80
|
+
width: PROGRESS_WIDTH
|
|
74
81
|
}
|
|
75
82
|
},
|
|
76
83
|
axisTick: {
|
|
@@ -78,7 +85,7 @@ export function GaugeChart(props) {
|
|
|
78
85
|
distance: 0
|
|
79
86
|
},
|
|
80
87
|
splitLine: {
|
|
81
|
-
show:
|
|
88
|
+
show: false
|
|
82
89
|
},
|
|
83
90
|
axisLabel: {
|
|
84
91
|
show: false,
|
|
@@ -97,7 +104,7 @@ export function GaugeChart(props) {
|
|
|
97
104
|
},
|
|
98
105
|
data: [
|
|
99
106
|
{
|
|
100
|
-
value:
|
|
107
|
+
value: data.value
|
|
101
108
|
}
|
|
102
109
|
]
|
|
103
110
|
},
|
|
@@ -113,7 +120,15 @@ export function GaugeChart(props) {
|
|
|
113
120
|
min: 0,
|
|
114
121
|
max,
|
|
115
122
|
pointer: {
|
|
116
|
-
show:
|
|
123
|
+
show: true,
|
|
124
|
+
// pointer hidden for small panels, path taken from ex: https://echarts.apache.org/examples/en/editor.html?c=gauge-grade
|
|
125
|
+
icon: width > GAUGE_SMALL_BREAKPOINT ? 'path://M12.8,0.7l12,40.1H0.7L12.8,0.7z' : 'none',
|
|
126
|
+
length: 10,
|
|
127
|
+
width: 5,
|
|
128
|
+
offsetCenter: [
|
|
129
|
+
0,
|
|
130
|
+
'-49%'
|
|
131
|
+
],
|
|
117
132
|
itemStyle: {
|
|
118
133
|
color: 'auto'
|
|
119
134
|
}
|
|
@@ -137,6 +152,7 @@ export function GaugeChart(props) {
|
|
|
137
152
|
'-9%'
|
|
138
153
|
],
|
|
139
154
|
color: 'inherit',
|
|
155
|
+
fontSize: valueSizeClamp,
|
|
140
156
|
formatter: (value)=>{
|
|
141
157
|
return formatValue(value, {
|
|
142
158
|
kind: unit.kind,
|
|
@@ -146,7 +162,21 @@ export function GaugeChart(props) {
|
|
|
146
162
|
},
|
|
147
163
|
data: [
|
|
148
164
|
{
|
|
149
|
-
value:
|
|
165
|
+
value: data.value,
|
|
166
|
+
name: data.label,
|
|
167
|
+
// TODO: new UX for series names, create separate React component or reuse ListLegendItem
|
|
168
|
+
// https://echarts.apache.org/en/option.html#series-gauge.data.title
|
|
169
|
+
title: {
|
|
170
|
+
show: true,
|
|
171
|
+
color: (ref1 = (ref = chartsTheme.echartsTheme.textStyle) === null || ref === void 0 ? void 0 : ref.color) !== null && ref1 !== void 0 ? ref1 : 'inherit',
|
|
172
|
+
offsetCenter: [
|
|
173
|
+
0,
|
|
174
|
+
'55%'
|
|
175
|
+
],
|
|
176
|
+
overflow: 'truncate',
|
|
177
|
+
fontSize: 12,
|
|
178
|
+
width: width * 0.8
|
|
179
|
+
}
|
|
150
180
|
}
|
|
151
181
|
]
|
|
152
182
|
}
|
|
@@ -154,6 +184,8 @@ export function GaugeChart(props) {
|
|
|
154
184
|
};
|
|
155
185
|
}, [
|
|
156
186
|
data,
|
|
187
|
+
width,
|
|
188
|
+
height,
|
|
157
189
|
chartsTheme,
|
|
158
190
|
unit,
|
|
159
191
|
axisLine,
|
|
@@ -168,5 +200,21 @@ export function GaugeChart(props) {
|
|
|
168
200
|
theme: chartsTheme.echartsTheme
|
|
169
201
|
});
|
|
170
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* Responsive font size depending on number of characters, clamp used
|
|
205
|
+
* to ensure size stays within given range
|
|
206
|
+
*/ export function getResponsiveValueSize(value, unit, width, height) {
|
|
207
|
+
const MIN_SIZE = 3;
|
|
208
|
+
const MAX_SIZE = 24;
|
|
209
|
+
const SIZE_MULTIPLIER = 0.7;
|
|
210
|
+
const formattedValue = formatValue(value, {
|
|
211
|
+
kind: unit.kind,
|
|
212
|
+
decimal_places: 0
|
|
213
|
+
});
|
|
214
|
+
var _length;
|
|
215
|
+
const valueCharacters = (_length = formattedValue.length) !== null && _length !== void 0 ? _length : 2;
|
|
216
|
+
const valueSize = Math.min(width, height) / valueCharacters * SIZE_MULTIPLIER;
|
|
217
|
+
return `clamp(${MIN_SIZE}px, ${valueSize}px, ${MAX_SIZE}px)`;
|
|
218
|
+
}
|
|
171
219
|
|
|
172
220
|
//# sourceMappingURL=GaugeChart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/GaugeChart/GaugeChart.tsx"],"sourcesContent":["// Copyright 2022 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 { useMemo } from 'react';\nimport { use, EChartsCoreOption } from 'echarts/core';\nimport { GaugeChart as EChartsGaugeChart, GaugeSeriesOption } from 'echarts/charts';\nimport { GridComponent, TitleComponent, TooltipComponent } from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { useChartsTheme } from '../context/ChartsThemeProvider';\nimport { formatValue, UnitOptions } from '../model/units';\nimport { EChart } from '../EChart';\n\nuse([EChartsGaugeChart, GridComponent, TitleComponent, TooltipComponent, CanvasRenderer]);\n\nexport type GaugeChartData = number | null | undefined;\n\ninterface GaugeChartProps {\n width: number;\n height: number;\n data: GaugeChartData;\n unit: UnitOptions;\n axisLine: GaugeSeriesOption['axisLine'];\n max?: number;\n}\n\nexport function GaugeChart(props: GaugeChartProps) {\n const { width, height, data, unit, axisLine, max } = props;\n\n const chartsTheme = useChartsTheme();\n\n const option: EChartsCoreOption = useMemo(() => {\n if (data === null || data === undefined) return chartsTheme.noDataOption;\n\n const calculatedValue = data;\n return {\n title: {\n show: false,\n },\n tooltip: {\n show: false,\n },\n series: [\n {\n type: 'gauge',\n center: ['50%', '65%'],\n radius: '86%',\n startAngle: 200,\n endAngle: -20,\n min: 0,\n max,\n silent: true,\n progress: {\n show: true,\n width: 22,\n itemStyle: {\n color: 'auto',\n },\n },\n pointer: {\n show: false,\n },\n axisLine: {\n lineStyle: {\n color: [[1, '#e1e5e9']], // TODO (sjcobb): use future chart theme colors\n width: 22,\n },\n },\n axisTick: {\n show: false,\n distance: 0,\n },\n splitLine: {\n show: true,\n },\n axisLabel: {\n show: false,\n distance: -18,\n color: '#999',\n fontSize: 12,\n },\n anchor: {\n show: false,\n },\n title: {\n show: false,\n },\n detail: {\n show: false,\n },\n data: [\n {\n value: calculatedValue,\n },\n ],\n },\n {\n type: 'gauge',\n center: ['50%', '65%'],\n radius: '100%',\n startAngle: 200,\n endAngle: -20,\n min: 0,\n max,\n pointer: {\n show: false,\n itemStyle: {\n color: 'auto',\n },\n },\n axisLine,\n axisTick: {\n show: false,\n },\n splitLine: {\n show: false,\n },\n axisLabel: {\n show: false,\n },\n detail: {\n show: true,\n width: '60%',\n borderRadius: 8,\n offsetCenter: [0, '-9%'],\n color: 'inherit',\n formatter: (value: number) => {\n return formatValue(value, {\n kind: unit.kind,\n decimal_places: 0,\n });\n },\n },\n data: [\n {\n value: calculatedValue,\n },\n ],\n },\n ],\n };\n }, [data, chartsTheme, unit, axisLine, max]);\n\n return (\n <EChart\n sx={{\n width: width,\n height: height,\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n />\n );\n}\n"],"names":["useMemo","use","GaugeChart","EChartsGaugeChart","GridComponent","TitleComponent","TooltipComponent","CanvasRenderer","useChartsTheme","formatValue","EChart","props","width","height","data","unit","axisLine","max","chartsTheme","option","undefined","noDataOption","calculatedValue","title","show","tooltip","series","type","center","radius","startAngle","endAngle","min","silent","progress","itemStyle","color","pointer","lineStyle","axisTick","distance","splitLine","axisLabel","fontSize","anchor","detail","value","borderRadius","offsetCenter","formatter","kind","decimal_places","sx","theme","echartsTheme"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,OAAO,QAAQ,OAAO,CAAC;AAChC,SAASC,GAAG,QAA2B,cAAc,CAAC;AACtD,SAASC,UAAU,IAAIC,iBAAiB,QAA2B,gBAAgB,CAAC;AACpF,SAASC,aAAa,EAAEC,cAAc,EAAEC,gBAAgB,QAAQ,oBAAoB,CAAC;AACrF,SAASC,cAAc,QAAQ,mBAAmB,CAAC;AACnD,SAASC,cAAc,QAAQ,gCAAgC,CAAC;AAChE,SAASC,WAAW,QAAqB,gBAAgB,CAAC;AAC1D,SAASC,MAAM,QAAQ,WAAW,CAAC;AAEnCT,GAAG,CAAC;IAACE,iBAAiB;IAAEC,aAAa;IAAEC,cAAc;IAAEC,gBAAgB;IAAEC,cAAc;CAAC,CAAC,CAAC;AAa1F,OAAO,SAASL,UAAU,CAACS,KAAsB,EAAE;IACjD,MAAM,EAAEC,KAAK,CAAA,EAAEC,MAAM,CAAA,EAAEC,IAAI,CAAA,EAAEC,IAAI,CAAA,EAAEC,QAAQ,CAAA,EAAEC,GAAG,CAAA,EAAE,GAAGN,KAAK,AAAC;IAE3D,MAAMO,WAAW,GAAGV,cAAc,EAAE,AAAC;IAErC,MAAMW,MAAM,GAAsBnB,OAAO,CAAC,IAAM;QAC9C,IAAIc,IAA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ACDM,MAAM,EAAEA,MAAM;QACdkC,KAAK,EAAEnC,WAAW,CAACoC,YAAY;MAC/B,CACF;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/GaugeChart/GaugeChart.tsx"],"sourcesContent":["// Copyright 2022 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 { useDeepMemo } from '@perses-dev/core';\nimport { use, EChartsCoreOption } from 'echarts/core';\nimport { GaugeChart as EChartsGaugeChart, GaugeSeriesOption } from 'echarts/charts';\nimport { GridComponent, TitleComponent, TooltipComponent } from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { useChartsTheme } from '../context/ChartsThemeProvider';\nimport { formatValue, UnitOptions } from '../model/units';\nimport { EChart } from '../EChart';\n\nuse([EChartsGaugeChart, GridComponent, TitleComponent, TooltipComponent, CanvasRenderer]);\n\nconst PROGRESS_WIDTH = 16;\n\n// adjusts when to show pointer icon\nconst GAUGE_SMALL_BREAKPOINT = 170;\n\nexport type GaugeChartValue = number | null | undefined;\n\nexport type GaugeSeries = {\n value: GaugeChartValue;\n label: string;\n};\n\ninterface GaugeChartProps {\n width: number;\n height: number;\n data: GaugeSeries;\n unit: UnitOptions;\n axisLine: GaugeSeriesOption['axisLine'];\n max?: number;\n}\n\nexport function GaugeChart(props: GaugeChartProps) {\n const { width, height, data, unit, axisLine, max } = props;\n const chartsTheme = useChartsTheme();\n\n // useDeepMemo ensures value size util does not rerun everytime you hover on the chart\n const option: EChartsCoreOption = useDeepMemo(() => {\n if (data.value === undefined || data.value === null) return chartsTheme.noDataOption;\n\n // adjusts fontSize depending on number of characters\n const valueSizeClamp = getResponsiveValueSize(data.value, unit, width, height);\n\n return {\n title: {\n show: false,\n },\n tooltip: {\n show: false,\n },\n series: [\n {\n type: 'gauge',\n center: ['50%', '65%'],\n radius: '86%',\n startAngle: 200,\n endAngle: -20,\n min: 0,\n max,\n silent: true,\n progress: {\n show: true,\n width: PROGRESS_WIDTH,\n itemStyle: {\n color: 'auto',\n },\n },\n pointer: {\n show: false,\n },\n axisLine: {\n lineStyle: {\n color: [[1, '#e1e5e9']], // TODO (sjcobb): use future chart theme colors\n width: PROGRESS_WIDTH,\n },\n },\n axisTick: {\n show: false,\n distance: 0,\n },\n splitLine: {\n show: false,\n },\n axisLabel: {\n show: false,\n distance: -18,\n color: '#999',\n fontSize: 12,\n },\n anchor: {\n show: false,\n },\n title: {\n show: false,\n },\n detail: {\n show: false,\n },\n data: [\n {\n value: data.value,\n },\n ],\n },\n {\n type: 'gauge',\n center: ['50%', '65%'],\n radius: '100%',\n startAngle: 200,\n endAngle: -20,\n min: 0,\n max,\n pointer: {\n show: true,\n // pointer hidden for small panels, path taken from ex: https://echarts.apache.org/examples/en/editor.html?c=gauge-grade\n icon: width > GAUGE_SMALL_BREAKPOINT ? 'path://M12.8,0.7l12,40.1H0.7L12.8,0.7z' : 'none',\n length: 10,\n width: 5,\n offsetCenter: [0, '-49%'],\n itemStyle: {\n color: 'auto',\n },\n },\n axisLine,\n axisTick: {\n show: false,\n },\n splitLine: {\n show: false,\n },\n axisLabel: {\n show: false,\n },\n detail: {\n show: true,\n width: '60%',\n borderRadius: 8,\n offsetCenter: [0, '-9%'],\n color: 'inherit', // allows value color to match active threshold color\n fontSize: valueSizeClamp,\n formatter: (value: number) => {\n return formatValue(value, {\n kind: unit.kind,\n decimal_places: 0,\n });\n },\n },\n data: [\n {\n value: data.value,\n name: data.label,\n // TODO: new UX for series names, create separate React component or reuse ListLegendItem\n // https://echarts.apache.org/en/option.html#series-gauge.data.title\n title: {\n show: true,\n color: chartsTheme.echartsTheme.textStyle?.color ?? 'inherit', // series name font color\n offsetCenter: [0, '55%'],\n overflow: 'truncate',\n fontSize: 12,\n width: width * 0.8,\n },\n },\n ],\n },\n ],\n };\n }, [data, width, height, chartsTheme, unit, axisLine, max]);\n\n return (\n <EChart\n sx={{\n width: width,\n height: height,\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n />\n );\n}\n\n/**\n * Responsive font size depending on number of characters, clamp used\n * to ensure size stays within given range\n */\nexport function getResponsiveValueSize(value: number, unit: UnitOptions, width: number, height: number) {\n const MIN_SIZE = 3;\n const MAX_SIZE = 24;\n const SIZE_MULTIPLIER = 0.7;\n const formattedValue = formatValue(value, {\n kind: unit.kind,\n decimal_places: 0,\n });\n const valueCharacters = formattedValue.length ?? 2;\n const valueSize = (Math.min(width, height) / valueCharacters) * SIZE_MULTIPLIER;\n return `clamp(${MIN_SIZE}px, ${valueSize}px, ${MAX_SIZE}px)`;\n}\n"],"names":["useDeepMemo","use","GaugeChart","EChartsGaugeChart","GridComponent","TitleComponent","TooltipComponent","CanvasRenderer","useChartsTheme","formatValue","EChart","PROGRESS_WIDTH","GAUGE_SMALL_BREAKPOINT","props","width","height","data","unit","axisLine","max","chartsTheme","option","value","undefined","noDataOption","valueSizeClamp","getResponsiveValueSize","title","show","tooltip","series","type","center","radius","startAngle","endAngle","min","silent","progress","itemStyle","color","pointer","lineStyle","axisTick","distance","splitLine","axisLabel","fontSize","anchor","detail","icon","length","offsetCenter","borderRadius","formatter","kind","decimal_places","name","label","echartsTheme","textStyle","overflow","sx","theme","MIN_SIZE","MAX_SIZE","SIZE_MULTIPLIER","formattedValue","valueCharacters","valueSize","Math"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,WAAW,QAAQ,kBAAkB,CAAC;AAC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F,OAAO,CAAC,MAAM,EAAEF,QAAQ,CAAC,IAAI,EAAEK,SAAS,CAAC,IAAI,EAAEJ,QAAQ,CAAC,GAAG,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -11,7 +11,9 @@ interface InfoTooltipProps {
|
|
|
11
11
|
id?: string;
|
|
12
12
|
title?: string;
|
|
13
13
|
placement?: TooltipPlacement;
|
|
14
|
+
enterDelay?: number;
|
|
15
|
+
enterNextDelay?: number;
|
|
14
16
|
}
|
|
15
|
-
export declare const InfoTooltip: ({ id, title, description, placement, children }: InfoTooltipProps) => JSX.Element;
|
|
17
|
+
export declare const InfoTooltip: ({ id, title, description, placement, children, enterDelay, enterNextDelay, }: InfoTooltipProps) => JSX.Element;
|
|
16
18
|
export {};
|
|
17
19
|
//# sourceMappingURL=InfoTooltip.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InfoTooltip.d.ts","sourceRoot":"","sources":["../../src/InfoTooltip/InfoTooltip.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,MAAM,OAAO,CAAC;AAS1B,oBAAY,gBAAgB;IAC1B,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,KAAK,UAAU;IACf,MAAM,WAAW;CAClB;AAED,UAAU,gBAAgB;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"InfoTooltip.d.ts","sourceRoot":"","sources":["../../src/InfoTooltip/InfoTooltip.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,MAAM,OAAO,CAAC;AAS1B,oBAAY,gBAAgB;IAC1B,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,KAAK,UAAU;IACf,MAAM,WAAW;CAClB;AAED,UAAU,gBAAgB;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,WAAW,iFAQrB,gBAAgB,gBAalB,CAAC"}
|
|
@@ -20,15 +20,17 @@ export var TooltipPlacement;
|
|
|
20
20
|
TooltipPlacement["Right"] = 'right';
|
|
21
21
|
TooltipPlacement["Bottom"] = 'bottom';
|
|
22
22
|
})(TooltipPlacement || (TooltipPlacement = {}));
|
|
23
|
-
export const InfoTooltip = ({ id , title , description , placement , children })=>{
|
|
23
|
+
export const InfoTooltip = ({ id , title , description , placement , children , enterDelay , enterNextDelay })=>{
|
|
24
24
|
return /*#__PURE__*/ _jsx(StyledTooltip, {
|
|
25
25
|
arrow: true,
|
|
26
26
|
id: id,
|
|
27
|
-
placement: placement,
|
|
27
|
+
placement: placement !== null && placement !== void 0 ? placement : TooltipPlacement.Top,
|
|
28
28
|
title: /*#__PURE__*/ _jsx(TooltipContent, {
|
|
29
29
|
title: title,
|
|
30
30
|
description: description
|
|
31
31
|
}),
|
|
32
|
+
enterDelay: enterDelay !== null && enterDelay !== void 0 ? enterDelay : 500,
|
|
33
|
+
enterNextDelay: enterNextDelay !== null && enterNextDelay !== void 0 ? enterNextDelay : 500,
|
|
32
34
|
children: /*#__PURE__*/ _jsx("div", {
|
|
33
35
|
children: children
|
|
34
36
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/InfoTooltip/InfoTooltip.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React from 'react';\nimport {\n styled,\n TooltipProps as MuiTooltipProps,\n Tooltip as MuiTooltip,\n tooltipClasses,\n Typography,\n} from '@mui/material';\n\nexport enum TooltipPlacement {\n Top = 'top',\n Left = 'left',\n Right = 'right',\n Bottom = 'bottom',\n}\n\ninterface InfoTooltipProps {\n description: string;\n children: React.ReactNode;\n id?: string;\n title?: string;\n placement?: TooltipPlacement;\n}\n\nexport const InfoTooltip = ({
|
|
1
|
+
{"version":3,"sources":["../../src/InfoTooltip/InfoTooltip.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React from 'react';\nimport {\n styled,\n TooltipProps as MuiTooltipProps,\n Tooltip as MuiTooltip,\n tooltipClasses,\n Typography,\n} from '@mui/material';\n\nexport enum TooltipPlacement {\n Top = 'top',\n Left = 'left',\n Right = 'right',\n Bottom = 'bottom',\n}\n\ninterface InfoTooltipProps {\n description: string;\n children: React.ReactNode;\n id?: string;\n title?: string;\n placement?: TooltipPlacement;\n enterDelay?: number; // default is 500ms\n enterNextDelay?: number; // default is 500ms\n}\n\nexport const InfoTooltip = ({\n id,\n title,\n description,\n placement,\n children,\n enterDelay,\n enterNextDelay,\n}: InfoTooltipProps) => {\n return (\n <StyledTooltip\n arrow\n id={id}\n placement={placement ?? TooltipPlacement.Top}\n title={<TooltipContent title={title} description={description} />}\n enterDelay={enterDelay ?? 500}\n enterNextDelay={enterNextDelay ?? 500}\n >\n <div>{children}</div>\n </StyledTooltip>\n );\n};\n\nconst TooltipContent = ({ title, description }: Pick<InfoTooltipProps, 'title' | 'description'>) => {\n return (\n <>\n {title && (\n <Typography\n variant=\"body2\"\n sx={(theme) => ({\n color: theme.palette.text.primary,\n fontWeight: theme.typography.fontWeightMedium,\n })}\n >\n {title}\n </Typography>\n )}\n <Typography\n variant=\"caption\"\n sx={(theme) => ({\n color: theme.palette.text.primary,\n })}\n >\n {description}\n </Typography>\n </>\n );\n};\n\nconst StyledTooltip = styled(({ className, ...props }: MuiTooltipProps) => (\n <MuiTooltip {...props} classes={{ popper: className }} />\n))(({ theme }) => ({\n [`& .${tooltipClasses.tooltip}`]: {\n backgroundColor: theme.palette.background.tooltip,\n color: theme.palette.text.primary,\n maxWidth: '300px',\n padding: theme.spacing(1),\n boxShadow: theme.shadows[1],\n },\n [`& .${tooltipClasses.arrow}`]: {\n color: theme.palette.background.tooltip,\n },\n}));\n"],"names":["React","styled","Tooltip","MuiTooltip","tooltipClasses","Typography","TooltipPlacement","Top","Left","Right","Bottom","InfoTooltip","id","title","description","placement","children","enterDelay","enterNextDelay","StyledTooltip","arrow","TooltipContent","div","variant","sx","theme","color","palette","text","primary","fontWeight","typography","fontWeightMedium","className","props","classes","popper","tooltip","backgroundColor","background","maxWidth","padding","spacing","boxShadow","shadows"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,OAAOA,KAAK,MAAM,OAAO,CAAC;AAC1B,SACEC,MAAM,EAENC,OAAO,IAAIC,UAAU,EACrBC,cAAc,EACdC,UAAU,QACL,eAAe,CAAC;WAEhB,gBAKN;UALWC,gBAAgB;IAAhBA,gBA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CAACC,KAAK,GAAM,CAAA;wBACdC,KAAK,EAAED,KAAK,CAACE,OAAO,CAACC,IAAI,CAACC,OAAO;qBAClC,CAAA,AAAC;0BAEDf,WAAW;cACD;;MACZ,CACH;AACJ,CAAC,AAAC;AAEF,MAAMK,aAAa,GAAGlB,MAAM,CAAC,CAAC,EAAEgC,SAAS,CAAA,EAAE,GAAGC,KAAK,EAAmB,iBACpE,KAAC/B,UAAU;QAAE,GAAG+B,KAAK;QAAEC,OAAO,EAAE;YAAEC,MAAM,EAAEH,SAAS;SAAE;MAAI,AAC1D,CAAC,CAAC,CAAC,EAAER,KAAK,CAAA,EAAE,GAAM,CAAA;QACjB,CAAC,CAAC,GAAG,EAAErB,cAAc,CAACiC,OAAO,CAAC,CAAC,CAAC,EAAE;YAChCC,eAAe,EAAEb,KAAK,CAACE,OAAO,CAACY,UAAU,CAACF,OAAO;YACjDX,KAAK,EAAED,KAAK,CAACE,OAAO,CAACC,IAAI,CAACC,OAAO;YACjCW,QAAQ,EAAE,OAAO;YACjBC,OAAO,EAAEhB,KAAK,CAACiB,OAAO,CAAC,CAAC,CAAC;YACzBC,SAAS,EAAElB,KAAK,CAACmB,OAAO,CAAC,CAAC,CAAC;SAC5B;QACD,CAAC,CAAC,GAAG,EAAExC,cAAc,CAACgB,KAAK,CAAC,CAAC,CAAC,EAAE;YAC9BM,KAAK,EAAED,KAAK,CAACE,OAAO,CAACY,UAAU,CAACF,OAAO;SACxC;KACF,CAAA,AAAC,CAAC,AAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { LegendOptions } from '../model';
|
|
3
|
+
export interface LegendOptionsEditorProps {
|
|
4
|
+
value?: LegendOptions;
|
|
5
|
+
onChange: (legend?: LegendOptions) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function LegendOptionsEditor({ value, onChange }: LegendOptionsEditorProps): JSX.Element;
|
|
8
|
+
//# sourceMappingURL=LegendOptionsEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LegendOptionsEditor.d.ts","sourceRoot":"","sources":["../../src/LegendOptionsEditor/LegendOptionsEditor.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAkB,aAAa,EAAE,MAAM,UAAU,CAAC;AAyBzD,MAAM,WAAW,wBAAwB;IACvC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;CAC5C;AAED,wBAAgB,mBAAmB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,wBAAwB,eAyChF"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
+
import { Autocomplete, Switch, TextField } from '@mui/material';
|
|
15
|
+
import { DEFAULT_LEGEND } from '../model';
|
|
16
|
+
import { OptionsEditorControl } from '../OptionsEditorLayout';
|
|
17
|
+
const LEGEND_POSITIONS = [
|
|
18
|
+
'bottom',
|
|
19
|
+
'right'
|
|
20
|
+
];
|
|
21
|
+
const LEGEND_POSITIONS_CONFIG = {
|
|
22
|
+
bottom: {
|
|
23
|
+
label: 'Bottom'
|
|
24
|
+
},
|
|
25
|
+
right: {
|
|
26
|
+
label: 'Right'
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const POSITION_OPTIONS = Object.entries(LEGEND_POSITIONS_CONFIG).map(([id, config])=>{
|
|
30
|
+
return {
|
|
31
|
+
id: id,
|
|
32
|
+
...config
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
export function LegendOptionsEditor({ value , onChange }) {
|
|
36
|
+
const handleLegendShowChange = (_, checked)=>{
|
|
37
|
+
// legend is hidden when legend obj is undefined
|
|
38
|
+
const legendValue = checked === true ? {
|
|
39
|
+
position: DEFAULT_LEGEND.position
|
|
40
|
+
} : undefined;
|
|
41
|
+
onChange(legendValue);
|
|
42
|
+
};
|
|
43
|
+
const handleLegendPositionChange = (_, newValue)=>{
|
|
44
|
+
onChange({
|
|
45
|
+
...value,
|
|
46
|
+
position: newValue.id
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
var ref;
|
|
50
|
+
const legendConfig = LEGEND_POSITIONS_CONFIG[(ref = value === null || value === void 0 ? void 0 : value.position) !== null && ref !== void 0 ? ref : DEFAULT_LEGEND.position];
|
|
51
|
+
var ref1;
|
|
52
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
53
|
+
children: [
|
|
54
|
+
/*#__PURE__*/ _jsx(OptionsEditorControl, {
|
|
55
|
+
label: "Show",
|
|
56
|
+
control: /*#__PURE__*/ _jsx(Switch, {
|
|
57
|
+
checked: value !== undefined,
|
|
58
|
+
onChange: handleLegendShowChange
|
|
59
|
+
})
|
|
60
|
+
}),
|
|
61
|
+
/*#__PURE__*/ _jsx(OptionsEditorControl, {
|
|
62
|
+
label: "Position",
|
|
63
|
+
control: /*#__PURE__*/ _jsx(Autocomplete, {
|
|
64
|
+
value: {
|
|
65
|
+
...legendConfig,
|
|
66
|
+
id: (ref1 = value === null || value === void 0 ? void 0 : value.position) !== null && ref1 !== void 0 ? ref1 : DEFAULT_LEGEND.position
|
|
67
|
+
},
|
|
68
|
+
options: POSITION_OPTIONS,
|
|
69
|
+
isOptionEqualToValue: (option, value)=>option.id === value.id,
|
|
70
|
+
renderInput: (params)=>/*#__PURE__*/ _jsx(TextField, {
|
|
71
|
+
...params
|
|
72
|
+
}),
|
|
73
|
+
onChange: handleLegendPositionChange,
|
|
74
|
+
disabled: value === undefined,
|
|
75
|
+
disableClearable: true
|
|
76
|
+
})
|
|
77
|
+
})
|
|
78
|
+
]
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
//# sourceMappingURL=LegendOptionsEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/LegendOptionsEditor/LegendOptionsEditor.tsx"],"sourcesContent":["// Copyright 2022 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 { Autocomplete, Switch, SwitchProps, TextField } from '@mui/material';\nimport { DEFAULT_LEGEND, LegendOptions } from '../model';\nimport { OptionsEditorControl } from '../OptionsEditorLayout';\n\ntype LegendPositionConfig = {\n label: string;\n};\n\nconst LEGEND_POSITIONS = ['bottom', 'right'] as const;\n\ntype LegendPositions = typeof LEGEND_POSITIONS[number];\n\nconst LEGEND_POSITIONS_CONFIG: Readonly<Record<LegendPositions, LegendPositionConfig>> = {\n bottom: { label: 'Bottom' },\n right: { label: 'Right' },\n};\n\ntype LegendPositionOption = LegendPositionConfig & { id: LegendOptions['position'] };\n\nconst POSITION_OPTIONS: LegendPositionOption[] = Object.entries(LEGEND_POSITIONS_CONFIG).map(([id, config]) => {\n return {\n id: id as LegendOptions['position'],\n ...config,\n };\n});\n\nexport interface LegendOptionsEditorProps {\n value?: LegendOptions;\n onChange: (legend?: LegendOptions) => void;\n}\n\nexport function LegendOptionsEditor({ value, onChange }: LegendOptionsEditorProps) {\n const handleLegendShowChange: SwitchProps['onChange'] = (_: unknown, checked: boolean) => {\n // legend is hidden when legend obj is undefined\n const legendValue = checked === true ? { position: DEFAULT_LEGEND.position } : undefined;\n onChange(legendValue);\n };\n\n const handleLegendPositionChange = (_: unknown, newValue: LegendPositionOption) => {\n onChange({\n ...value,\n position: newValue.id,\n });\n };\n\n const legendConfig = LEGEND_POSITIONS_CONFIG[value?.position ?? DEFAULT_LEGEND.position];\n\n return (\n <>\n <OptionsEditorControl\n label=\"Show\"\n control={<Switch checked={value !== undefined} onChange={handleLegendShowChange} />}\n />\n <OptionsEditorControl\n label=\"Position\"\n control={\n <Autocomplete\n value={{\n ...legendConfig,\n id: value?.position ?? DEFAULT_LEGEND.position,\n }}\n options={POSITION_OPTIONS}\n isOptionEqualToValue={(option, value) => option.id === value.id}\n renderInput={(params) => <TextField {...params} />}\n onChange={handleLegendPositionChange}\n disabled={value === undefined}\n disableClearable\n ></Autocomplete>\n }\n />\n </>\n );\n}\n"],"names":["Autocomplete","Switch","TextField","DEFAULT_LEGEND","OptionsEditorControl","LEGEND_POSITIONS","LEGEND_POSITIONS_CONFIG","bottom","label","right","POSITION_OPTIONS","Object","entries","map","id","config","LegendOptionsEditor","value","onChange","handleLegendShowChange","_","checked","legendValue","position","undefined","handleLegendPositionChange","newValue","legendConfig","control","options","isOptionEqualToValue","option","renderInput","params","disabled","disableClearable"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,YAAY,EAAEC,MAAM,EAAeC,SAAS,QAAQ,eAAe,CAAC;AAC7E,SAASC,cAAc,QAAuB,UAAU,CAAC;AACzD,SAASC,oBAAo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AoB;gBACnBI,KAAK,EAAC,MAAM;gBACZoB,OAAO,gBAAE,KAAC3B,MAAM;oBAACoB,OAAO,EAAEJ,KAAK,KAAKO,SAAS;oBAAEN,QAAQ,EAAEC,sBAAsB;kBAAI;cACnF;0BACF,KAACf,oBAAoB;gBACnBI,KAAK,EAAC,UAAU;gBAChBoB,OAAO,gBACL,KAAC5B,YAAY;oBACXiB,KAAK,EAAE;wBACL,GAAGU,YAAY;wBACfb,EAAE,EAAEG,CAAAA,IAAe,GAAfA,KAAK,aAALA,KAAK,WAAU,GAAfA,KAAAA,CAAe,GAAfA,KAAK,CAAEM,QAAQ,cAAfN,IAAe,cAAfA,IAAe,GAAId,cAAc,CAACoB,QAAQ;qBAC/C;oBACDM,OAAO,EAAEnB,gBAAgB;oBACzBoB,oBAAoB,EAAE,CAACC,MAAM,EAAEd,KAAK,GAAKc,MAAM,CAACjB,EAAE,KAAKG,KAAK,CAACH,EAAE;oBAC/DkB,WAAW,EAAE,CAACC,MAAM,iBAAK,KAAC/B,SAAS;4BAAE,GAAG+B,MAAM;0BAAI;oBAClDf,QAAQ,EAAEO,0BAA0B;oBACpCS,QAAQ,EAAEjB,KAAK,KAAKO,SAAS;oBAC7BW,gBAAgB;kBACF;cAElB;;MACD,CACH;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LegendOptionsEditor.test.d.ts","sourceRoot":"","sources":["../../src/LegendOptionsEditor/LegendOptionsEditor.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { render, screen } from '@testing-library/react';
|
|
15
|
+
import userEvent from '@testing-library/user-event';
|
|
16
|
+
import { LegendOptionsEditor } from './LegendOptionsEditor';
|
|
17
|
+
describe('LegendOptionsEditor', ()=>{
|
|
18
|
+
const renderLegendOptionsEditor = (value, onChange = jest.fn())=>{
|
|
19
|
+
render(/*#__PURE__*/ _jsx("div", {
|
|
20
|
+
children: /*#__PURE__*/ _jsx(LegendOptionsEditor, {
|
|
21
|
+
value: value,
|
|
22
|
+
onChange: onChange
|
|
23
|
+
})
|
|
24
|
+
}));
|
|
25
|
+
};
|
|
26
|
+
const getLegendShowSwitch = ()=>{
|
|
27
|
+
return screen.getByRole('checkbox', {
|
|
28
|
+
name: 'Show'
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
it('can change legend visibility by clicking', ()=>{
|
|
32
|
+
const onChange = jest.fn();
|
|
33
|
+
renderLegendOptionsEditor(undefined, onChange);
|
|
34
|
+
userEvent.click(getLegendShowSwitch());
|
|
35
|
+
expect(onChange).toHaveBeenCalledWith({
|
|
36
|
+
position: 'bottom'
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=LegendOptionsEditor.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/LegendOptionsEditor/LegendOptionsEditor.test.tsx"],"sourcesContent":["// Copyright 2022 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 { render, screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { LegendOptions } from '../model';\nimport { LegendOptionsEditor } from './LegendOptionsEditor';\n\ndescribe('LegendOptionsEditor', () => {\n const renderLegendOptionsEditor = (value?: LegendOptions, onChange = jest.fn()) => {\n render(\n <div>\n <LegendOptionsEditor value={value} onChange={onChange} />\n </div>\n );\n };\n\n const getLegendShowSwitch = () => {\n return screen.getByRole('checkbox', { name: 'Show' });\n };\n\n it('can change legend visibility by clicking', () => {\n const onChange = jest.fn();\n renderLegendOptionsEditor(undefined, onChange);\n userEvent.click(getLegendShowSwitch());\n expect(onChange).toHaveBeenCalledWith({ position: 'bottom' });\n });\n});\n"],"names":["render","screen","userEvent","LegendOptionsEditor","describe","renderLegendOptionsEditor","value","onChange","jest","fn","div","getLegendShowSwitch","getByRole","name","it","undefined","click","expect","toHaveBeenCalledWith","position"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,MAAM,EAAEC,MAAM,QAAQ,wBAAwB,CAAC;AACxD,OAAOC,SAAS,MAAM,6BAA6B,CAAC;AAEpD,SAASC,mBAAmB,QAAQ,uBAAuB,CAAC;AAE5DC,QAAQ,CAAC,qBAAqB,EAAE,IAAM;IACpC,MAAMC,yBAAyB,GAAG,CAACC,KAAqB,EAAEC,QAAQ,GAAGC,IAAI,CAACC,EAAE,EAAE,GAAK;QACjFT,MAAM,eACJ,KAACU,KAAG;sBACF,cAAA,KAACP,mBAAmB;gBAACG,KAAK,EAAEA,KAAK;gBAAEC,QAAQ,EAAEA,QAAQ;cAAI;UACrD,CACP,CAAC;IACJ,CAAC,AAAC;IAEF,MAAMI,mBAAmB,GAAG,IAAM;QAChC,OAAOV,MAAM,CAACW,SAAS,CAAC,UAAU,EAAE;YAAEC,IAAI,EAAE,MAAM;SAAE,CAAC,CAAC;IACxD,CAAC,AAAC;IAEFC,EAAE,CAAC,0CAA0C,EAAE,IAAM;QACnD,MAAMP,QAAQ,GAAGC,IAAI,CAACC,EAAE,EAAE,AAAC;QAC3BJ,yBAAyB,CAACU,SAAS,EAAER,QAAQ,CAAC,CAAC;QAC/CL,SAAS,CAACc,KAAK,CAACL,mBAAmB,EAAE,CAAC,CAAC;QACvCM,MAAM,CAACV,QAAQ,CAAC,CAACW,oBAAoB,CAAC;YAAEC,QAAQ,EAAE,QAAQ;SAAE,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/LegendOptionsEditor/index.ts"],"names":[],"mappings":"AAaA,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
export * from './LegendOptionsEditor';
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/LegendOptionsEditor/index.ts"],"sourcesContent":["// Copyright 2022 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 './LegendOptionsEditor';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,uBAAuB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MouseEvent } from 'react';
|
|
2
|
-
import type { GridComponentOption, LegendComponentOption,
|
|
2
|
+
import type { GridComponentOption, LegendComponentOption, YAXisComponentOption } from 'echarts';
|
|
3
3
|
import { EChartsDataFormat } from '../model/graph';
|
|
4
4
|
import { UnitOptions } from '../model/units';
|
|
5
5
|
import { ZoomEventData } from './utils';
|
|
@@ -10,10 +10,9 @@ interface LineChartProps {
|
|
|
10
10
|
unit?: UnitOptions;
|
|
11
11
|
grid?: GridComponentOption;
|
|
12
12
|
legend?: LegendComponentOption;
|
|
13
|
-
visualMap?: VisualMapComponentOption[];
|
|
14
13
|
onDataZoom?: (e: ZoomEventData) => void;
|
|
15
14
|
onDoubleClick?: (e: MouseEvent) => void;
|
|
16
15
|
}
|
|
17
|
-
export declare function LineChart({ height, data, yAxis, unit, grid, legend,
|
|
16
|
+
export declare function LineChart({ height, data, yAxis, unit, grid, legend, onDataZoom, onDoubleClick }: LineChartProps): JSX.Element;
|
|
18
17
|
export {};
|
|
19
18
|
//# sourceMappingURL=LineChart.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../src/LineChart/LineChart.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAA6B,MAAM,OAAO,CAAC;AAE9D,OAAO,KAAK,EAEV,mBAAmB,EAEnB,qBAAqB,EACrB,
|
|
1
|
+
{"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../src/LineChart/LineChart.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAA6B,MAAM,OAAO,CAAC;AAE9D,OAAO,KAAK,EAEV,mBAAmB,EAEnB,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAgBjB,OAAO,EAAE,iBAAiB,EAA+B,MAAM,gBAAgB,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAI7C,OAAO,EAA0E,aAAa,EAAE,MAAM,SAAS,CAAC;AAgBhH,UAAU,cAAc;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,iBAAiB,CAAC;IACxB,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAC7B,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IACxC,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;CACzC;AAED,wBAAgB,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,EAAE,cAAc,eAgJ/G"}
|