@perses-dev/components 0.0.0-snapshot-explorer-plugin-c4a7621 → 0.0.0-snapshot-profile-8090608

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.
Files changed (187) hide show
  1. package/README.md +1 -4
  2. package/dist/ColorPicker/ColorPicker.js.map +1 -1
  3. package/dist/ColorPicker/OptionsColorPicker.js.map +1 -1
  4. package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
  5. package/dist/DragAndDrop/DragButton.d.ts +2 -2
  6. package/dist/DragAndDrop/DragButton.d.ts.map +1 -1
  7. package/dist/DragAndDrop/DragButton.js +5 -3
  8. package/dist/DragAndDrop/DragButton.js.map +1 -1
  9. package/dist/DragAndDrop/DropIndicator.js.map +1 -1
  10. package/dist/Drawer/Drawer.js.map +1 -1
  11. package/dist/EChart/EChart.d.ts +3 -2
  12. package/dist/EChart/EChart.d.ts.map +1 -1
  13. package/dist/EChart/EChart.js +26 -4
  14. package/dist/EChart/EChart.js.map +1 -1
  15. package/dist/InfoTooltip/InfoTooltip.js +2 -1
  16. package/dist/InfoTooltip/InfoTooltip.js.map +1 -1
  17. package/dist/JSONEditor.d.ts.map +1 -1
  18. package/dist/JSONEditor.js +5 -6
  19. package/dist/JSONEditor.js.map +1 -1
  20. package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
  21. package/dist/Overlay/Overlay.js +1 -1
  22. package/dist/Overlay/Overlay.js.map +1 -1
  23. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -1
  24. package/dist/SettingsAutocomplete/SettingsAutocomplete.js.map +1 -1
  25. package/dist/Table/Table.d.ts +1 -1
  26. package/dist/Table/Table.d.ts.map +1 -1
  27. package/dist/Table/Table.js +15 -4
  28. package/dist/Table/Table.js.map +1 -1
  29. package/dist/Table/TableCell.d.ts +2 -1
  30. package/dist/Table/TableCell.d.ts.map +1 -1
  31. package/dist/Table/TableCell.js +4 -2
  32. package/dist/Table/TableCell.js.map +1 -1
  33. package/dist/Table/TableFoot.d.ts +4 -0
  34. package/dist/Table/TableFoot.d.ts.map +1 -0
  35. package/dist/{BarChart/index.js → Table/TableFoot.js} +11 -3
  36. package/dist/Table/TableFoot.js.map +1 -0
  37. package/dist/Table/TableHeaderCell.js.map +1 -1
  38. package/dist/Table/VirtualizedTable.d.ts +3 -2
  39. package/dist/Table/VirtualizedTable.d.ts.map +1 -1
  40. package/dist/Table/VirtualizedTable.js +33 -2
  41. package/dist/Table/VirtualizedTable.js.map +1 -1
  42. package/dist/Table/model/table-model.d.ts +18 -2
  43. package/dist/Table/model/table-model.d.ts.map +1 -1
  44. package/dist/Table/model/table-model.js +4 -2
  45. package/dist/Table/model/table-model.js.map +1 -1
  46. package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -1
  47. package/dist/ThresholdsEditor/ThresholdsEditor.js +1 -1
  48. package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
  49. package/dist/TimeChart/TimeChart.d.ts.map +1 -1
  50. package/dist/TimeChart/TimeChart.js +6 -6
  51. package/dist/TimeChart/TimeChart.js.map +1 -1
  52. package/dist/TimeRangeSelector/DateTimeRangePicker.js +1 -1
  53. package/dist/TimeRangeSelector/DateTimeRangePicker.js.map +1 -1
  54. package/dist/TimeRangeSelector/TimeRangeSelector.d.ts +1 -1
  55. package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -1
  56. package/dist/TimeRangeSelector/utils.js.map +1 -1
  57. package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts.map +1 -1
  58. package/dist/TimeSeriesTooltip/LineChartTooltip.js +2 -5
  59. package/dist/TimeSeriesTooltip/LineChartTooltip.js.map +1 -1
  60. package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
  61. package/dist/TimeSeriesTooltip/SeriesLabelsStack.js.map +1 -1
  62. package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts.map +1 -1
  63. package/dist/TimeSeriesTooltip/TimeChartTooltip.js +2 -5
  64. package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
  65. package/dist/TimeSeriesTooltip/tooltip-model.d.ts +1 -8
  66. package/dist/TimeSeriesTooltip/tooltip-model.d.ts.map +1 -1
  67. package/dist/TimeSeriesTooltip/tooltip-model.js +6 -16
  68. package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
  69. package/dist/TimeSeriesTooltip/utils.d.ts +1 -1
  70. package/dist/TimeSeriesTooltip/utils.d.ts.map +1 -1
  71. package/dist/TimeSeriesTooltip/utils.js +27 -23
  72. package/dist/TimeSeriesTooltip/utils.js.map +1 -1
  73. package/dist/TransformsEditor/TransformEditorContainer.js.map +1 -1
  74. package/dist/cjs/DragAndDrop/DragButton.js +4 -2
  75. package/dist/cjs/EChart/EChart.js +25 -3
  76. package/dist/cjs/InfoTooltip/InfoTooltip.js +2 -1
  77. package/dist/cjs/JSONEditor.js +4 -5
  78. package/dist/cjs/Overlay/Overlay.js +1 -1
  79. package/dist/cjs/Table/Table.js +14 -3
  80. package/dist/cjs/Table/TableCell.js +4 -2
  81. package/dist/cjs/{StatChart/utils/formatStatChartValue.js → Table/TableFoot.js} +12 -15
  82. package/dist/cjs/Table/VirtualizedTable.js +32 -1
  83. package/dist/cjs/Table/model/table-model.js +7 -2
  84. package/dist/cjs/ThresholdsEditor/ThresholdsEditor.js +9 -9
  85. package/dist/cjs/TimeChart/TimeChart.js +5 -5
  86. package/dist/cjs/TimeRangeSelector/DateTimeRangePicker.js +2 -2
  87. package/dist/cjs/TimeSeriesTooltip/LineChartTooltip.js +1 -4
  88. package/dist/cjs/TimeSeriesTooltip/TimeChartTooltip.js +1 -4
  89. package/dist/cjs/TimeSeriesTooltip/tooltip-model.js +6 -25
  90. package/dist/cjs/TimeSeriesTooltip/utils.js +26 -22
  91. package/dist/cjs/context/ChartsProvider.js +3 -1
  92. package/dist/cjs/index.js +0 -5
  93. package/dist/cjs/test-utils/theme.js +1 -0
  94. package/dist/context/ChartsProvider.d.ts +2 -0
  95. package/dist/context/ChartsProvider.d.ts.map +1 -1
  96. package/dist/context/ChartsProvider.js +3 -1
  97. package/dist/context/ChartsProvider.js.map +1 -1
  98. package/dist/context/SnackbarProvider.js.map +1 -1
  99. package/dist/index.d.ts +0 -5
  100. package/dist/index.d.ts.map +1 -1
  101. package/dist/index.js +0 -5
  102. package/dist/index.js.map +1 -1
  103. package/dist/model/timeOption.js.map +1 -1
  104. package/dist/test-utils/theme.d.ts.map +1 -1
  105. package/dist/test-utils/theme.js +1 -0
  106. package/dist/test-utils/theme.js.map +1 -1
  107. package/dist/theme/component-overrides/alert.js.map +1 -1
  108. package/dist/utils/component-ids.js.map +1 -1
  109. package/package.json +6 -11
  110. package/dist/BarChart/BarChart.d.ts +0 -16
  111. package/dist/BarChart/BarChart.d.ts.map +0 -1
  112. package/dist/BarChart/BarChart.js +0 -134
  113. package/dist/BarChart/BarChart.js.map +0 -1
  114. package/dist/BarChart/index.d.ts +0 -2
  115. package/dist/BarChart/index.d.ts.map +0 -1
  116. package/dist/BarChart/index.js.map +0 -1
  117. package/dist/GaugeChart/GaugeChart.d.ts +0 -23
  118. package/dist/GaugeChart/GaugeChart.d.ts.map +0 -1
  119. package/dist/GaugeChart/GaugeChart.js +0 -214
  120. package/dist/GaugeChart/GaugeChart.js.map +0 -1
  121. package/dist/GaugeChart/index.d.ts +0 -2
  122. package/dist/GaugeChart/index.d.ts.map +0 -1
  123. package/dist/GaugeChart/index.js +0 -15
  124. package/dist/GaugeChart/index.js.map +0 -1
  125. package/dist/PieChart/PieChart.d.ts +0 -14
  126. package/dist/PieChart/PieChart.d.ts.map +0 -1
  127. package/dist/PieChart/PieChart.js +0 -92
  128. package/dist/PieChart/PieChart.js.map +0 -1
  129. package/dist/PieChart/index.d.ts +0 -2
  130. package/dist/PieChart/index.d.ts.map +0 -1
  131. package/dist/PieChart/index.js +0 -15
  132. package/dist/PieChart/index.js.map +0 -1
  133. package/dist/StatChart/StatChart.d.ts +0 -21
  134. package/dist/StatChart/StatChart.d.ts.map +0 -1
  135. package/dist/StatChart/StatChart.js +0 -185
  136. package/dist/StatChart/StatChart.js.map +0 -1
  137. package/dist/StatChart/calculateFontSize.d.ts +0 -16
  138. package/dist/StatChart/calculateFontSize.d.ts.map +0 -1
  139. package/dist/StatChart/calculateFontSize.js +0 -49
  140. package/dist/StatChart/calculateFontSize.js.map +0 -1
  141. package/dist/StatChart/index.d.ts +0 -2
  142. package/dist/StatChart/index.d.ts.map +0 -1
  143. package/dist/StatChart/index.js +0 -15
  144. package/dist/StatChart/index.js.map +0 -1
  145. package/dist/StatChart/utils/formatStatChartValue.d.ts +0 -3
  146. package/dist/StatChart/utils/formatStatChartValue.d.ts.map +0 -1
  147. package/dist/StatChart/utils/formatStatChartValue.js +0 -26
  148. package/dist/StatChart/utils/formatStatChartValue.js.map +0 -1
  149. package/dist/StatusHistoryChart/StatusHistoryChart.d.ts +0 -27
  150. package/dist/StatusHistoryChart/StatusHistoryChart.d.ts.map +0 -1
  151. package/dist/StatusHistoryChart/StatusHistoryChart.js +0 -132
  152. package/dist/StatusHistoryChart/StatusHistoryChart.js.map +0 -1
  153. package/dist/StatusHistoryChart/StatusHistoryTooltip.d.ts +0 -13
  154. package/dist/StatusHistoryChart/StatusHistoryTooltip.d.ts.map +0 -1
  155. package/dist/StatusHistoryChart/StatusHistoryTooltip.js +0 -47
  156. package/dist/StatusHistoryChart/StatusHistoryTooltip.js.map +0 -1
  157. package/dist/StatusHistoryChart/get-formatted-axis-label.d.ts +0 -2
  158. package/dist/StatusHistoryChart/get-formatted-axis-label.d.ts.map +0 -1
  159. package/dist/StatusHistoryChart/get-formatted-axis-label.js +0 -41
  160. package/dist/StatusHistoryChart/get-formatted-axis-label.js.map +0 -1
  161. package/dist/StatusHistoryChart/index.d.ts +0 -3
  162. package/dist/StatusHistoryChart/index.d.ts.map +0 -1
  163. package/dist/StatusHistoryChart/index.js +0 -16
  164. package/dist/StatusHistoryChart/index.js.map +0 -1
  165. package/dist/StatusHistoryChart/utils/get-color.d.ts +0 -6
  166. package/dist/StatusHistoryChart/utils/get-color.d.ts.map +0 -1
  167. package/dist/StatusHistoryChart/utils/get-color.js +0 -100
  168. package/dist/StatusHistoryChart/utils/get-color.js.map +0 -1
  169. package/dist/StatusHistoryChart/utils/get-tooltip-position.d.ts +0 -3
  170. package/dist/StatusHistoryChart/utils/get-tooltip-position.d.ts.map +0 -1
  171. package/dist/StatusHistoryChart/utils/get-tooltip-position.js +0 -27
  172. package/dist/StatusHistoryChart/utils/get-tooltip-position.js.map +0 -1
  173. package/dist/cjs/BarChart/BarChart.js +0 -142
  174. package/dist/cjs/BarChart/index.js +0 -30
  175. package/dist/cjs/GaugeChart/GaugeChart.js +0 -227
  176. package/dist/cjs/GaugeChart/index.js +0 -30
  177. package/dist/cjs/PieChart/PieChart.js +0 -100
  178. package/dist/cjs/PieChart/index.js +0 -30
  179. package/dist/cjs/StatChart/StatChart.js +0 -198
  180. package/dist/cjs/StatChart/calculateFontSize.js +0 -55
  181. package/dist/cjs/StatChart/index.js +0 -30
  182. package/dist/cjs/StatusHistoryChart/StatusHistoryChart.js +0 -140
  183. package/dist/cjs/StatusHistoryChart/StatusHistoryTooltip.js +0 -55
  184. package/dist/cjs/StatusHistoryChart/get-formatted-axis-label.js +0 -48
  185. package/dist/cjs/StatusHistoryChart/index.js +0 -31
  186. package/dist/cjs/StatusHistoryChart/utils/get-color.js +0 -125
  187. package/dist/cjs/StatusHistoryChart/utils/get-tooltip-position.js +0 -35
@@ -1,214 +0,0 @@
1
- // Copyright 2023 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 { formatValue, useDeepMemo } from '@perses-dev/core';
15
- import { use } from 'echarts/core';
16
- import { GaugeChart as EChartsGaugeChart } from 'echarts/charts';
17
- import { GridComponent, TitleComponent, TooltipComponent } from 'echarts/components';
18
- import { CanvasRenderer } from 'echarts/renderers';
19
- import { useChartsTheme } from '../context';
20
- import { EChart } from '../EChart';
21
- use([
22
- EChartsGaugeChart,
23
- GridComponent,
24
- TitleComponent,
25
- TooltipComponent,
26
- CanvasRenderer
27
- ]);
28
- const PROGRESS_WIDTH = 16;
29
- // adjusts when to show pointer icon
30
- const GAUGE_SMALL_BREAKPOINT = 170;
31
- export function GaugeChart(props) {
32
- const { width, height, data, format, axisLine, max } = props;
33
- const chartsTheme = useChartsTheme();
34
- // useDeepMemo ensures value size util does not rerun everytime you hover on the chart
35
- const option = useDeepMemo(()=>{
36
- if (data.value === undefined) return chartsTheme.noDataOption;
37
- // adjusts fontSize depending on number of characters
38
- const valueSizeClamp = getResponsiveValueSize(data.value, format, width, height);
39
- return {
40
- title: {
41
- show: false
42
- },
43
- tooltip: {
44
- show: false
45
- },
46
- series: [
47
- {
48
- type: 'gauge',
49
- center: [
50
- '50%',
51
- '65%'
52
- ],
53
- radius: '86%',
54
- startAngle: 200,
55
- endAngle: -20,
56
- min: 0,
57
- max,
58
- silent: true,
59
- progress: {
60
- show: true,
61
- width: PROGRESS_WIDTH,
62
- itemStyle: {
63
- color: 'auto'
64
- }
65
- },
66
- pointer: {
67
- show: false
68
- },
69
- axisLine: {
70
- lineStyle: {
71
- color: [
72
- [
73
- 1,
74
- 'rgba(127,127,127,0.35)'
75
- ]
76
- ],
77
- width: PROGRESS_WIDTH
78
- }
79
- },
80
- axisTick: {
81
- show: false,
82
- distance: 0
83
- },
84
- splitLine: {
85
- show: false
86
- },
87
- axisLabel: {
88
- show: false,
89
- distance: -18,
90
- color: '#999',
91
- fontSize: 12
92
- },
93
- anchor: {
94
- show: false
95
- },
96
- title: {
97
- show: false
98
- },
99
- detail: {
100
- show: false
101
- },
102
- data: [
103
- {
104
- value: data.value
105
- }
106
- ]
107
- },
108
- {
109
- type: 'gauge',
110
- center: [
111
- '50%',
112
- '65%'
113
- ],
114
- radius: '100%',
115
- startAngle: 200,
116
- endAngle: -20,
117
- min: 0,
118
- max,
119
- pointer: {
120
- show: true,
121
- // pointer hidden for small panels, path taken from ex: https://echarts.apache.org/examples/en/editor.html?c=gauge-grade
122
- icon: width > GAUGE_SMALL_BREAKPOINT ? 'path://M12.8,0.7l12,40.1H0.7L12.8,0.7z' : 'none',
123
- length: 10,
124
- width: 5,
125
- offsetCenter: [
126
- 0,
127
- '-49%'
128
- ],
129
- itemStyle: {
130
- color: 'auto'
131
- }
132
- },
133
- axisLine,
134
- axisTick: {
135
- show: false
136
- },
137
- splitLine: {
138
- show: false
139
- },
140
- axisLabel: {
141
- show: false
142
- },
143
- detail: {
144
- show: true,
145
- width: '60%',
146
- borderRadius: 8,
147
- offsetCenter: [
148
- 0,
149
- '-9%'
150
- ],
151
- color: 'inherit',
152
- fontSize: valueSizeClamp,
153
- formatter: data.value === null ? // at this level because the `formatter` function argument is `NaN`
154
- // when the value is `null`, making it difficult to differentiate
155
- // `null` from a true `NaN` case.
156
- ()=>'null' : (value)=>{
157
- return formatValue(value, format);
158
- }
159
- },
160
- data: [
161
- {
162
- value: data.value,
163
- name: data.label,
164
- // TODO: new UX for series names, create separate React component or reuse ListLegendItem
165
- // https://echarts.apache.org/en/option.html#series-gauge.data.title
166
- title: {
167
- show: true,
168
- color: chartsTheme.echartsTheme.textStyle?.color ?? 'inherit',
169
- offsetCenter: [
170
- 0,
171
- '55%'
172
- ],
173
- overflow: 'truncate',
174
- fontSize: 12,
175
- width: width * 0.8
176
- }
177
- }
178
- ]
179
- }
180
- ]
181
- };
182
- }, [
183
- data,
184
- width,
185
- height,
186
- chartsTheme,
187
- format,
188
- axisLine,
189
- max
190
- ]);
191
- return /*#__PURE__*/ _jsx(EChart, {
192
- sx: {
193
- width: width,
194
- height: height,
195
- padding: `${chartsTheme.container.padding.default}px`
196
- },
197
- option: option,
198
- theme: chartsTheme.echartsTheme
199
- });
200
- }
201
- /**
202
- * Responsive font size depending on number of characters, clamp used
203
- * to ensure size stays within given range
204
- */ export function getResponsiveValueSize(value, format, width, height) {
205
- const MIN_SIZE = 3;
206
- const MAX_SIZE = 24;
207
- const SIZE_MULTIPLIER = 0.7;
208
- const formattedValue = typeof value === 'number' ? formatValue(value, format) : `${value}`;
209
- const valueCharacters = formattedValue.length ?? 2;
210
- const valueSize = Math.min(width, height) / valueCharacters * SIZE_MULTIPLIER;
211
- return `clamp(${MIN_SIZE}px, ${valueSize}px, ${MAX_SIZE}px)`;
212
- }
213
-
214
- //# sourceMappingURL=GaugeChart.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/GaugeChart/GaugeChart.tsx"],"sourcesContent":["// Copyright 2023 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 { formatValue, useDeepMemo, FormatOptions } 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 { ReactElement } from 'react';\nimport { useChartsTheme } from '../context';\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\nexport interface GaugeChartProps {\n width: number;\n height: number;\n data: GaugeSeries;\n format: FormatOptions;\n axisLine: GaugeSeriesOption['axisLine'];\n max?: number;\n}\n\nexport function GaugeChart(props: GaugeChartProps): ReactElement {\n const { width, height, data, format, 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) return chartsTheme.noDataOption;\n\n // adjusts fontSize depending on number of characters\n const valueSizeClamp = getResponsiveValueSize(data.value, format, 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, 'rgba(127,127,127,0.35)']], // 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:\n data.value === null\n ? // We use a different function when we *know* the value is null\n // at this level because the `formatter` function argument is `NaN`\n // when the value is `null`, making it difficult to differentiate\n // `null` from a true `NaN` case.\n (): string => 'null'\n : (value: number): string | undefined => {\n return formatValue(value, format);\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, format, axisLine, max]);\n\n return (\n <EChart\n sx={{\n width: width,\n height: height,\n padding: `${chartsTheme.container.padding.default}px`,\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(\n value: number | null,\n format: FormatOptions,\n width: number,\n height: number\n): string {\n const MIN_SIZE = 3;\n const MAX_SIZE = 24;\n const SIZE_MULTIPLIER = 0.7;\n const formattedValue = typeof value === 'number' ? formatValue(value, format) : `${value}`;\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":["formatValue","useDeepMemo","use","GaugeChart","EChartsGaugeChart","GridComponent","TitleComponent","TooltipComponent","CanvasRenderer","useChartsTheme","EChart","PROGRESS_WIDTH","GAUGE_SMALL_BREAKPOINT","props","width","height","data","format","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","name","label","echartsTheme","textStyle","overflow","sx","padding","container","default","theme","MIN_SIZE","MAX_SIZE","SIZE_MULTIPLIER","formattedValue","valueCharacters","valueSize","Math"],"mappings":"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"}
@@ -1,2 +0,0 @@
1
- export * from './GaugeChart';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/GaugeChart/index.ts"],"names":[],"mappings":"AAaA,cAAc,cAAc,CAAC"}
@@ -1,15 +0,0 @@
1
- // Copyright 2023 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 './GaugeChart';
14
-
15
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/GaugeChart/index.ts"],"sourcesContent":["// Copyright 2023 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 './GaugeChart';\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,eAAe"}
@@ -1,14 +0,0 @@
1
- import { LegendComponentOption } from 'echarts/components';
2
- import { ReactElement } from 'react';
3
- export interface PieChartData {
4
- name: string;
5
- value: number | null;
6
- }
7
- export interface PieChartProps {
8
- width: number;
9
- height: number;
10
- data: PieChartData[] | null;
11
- legend?: LegendComponentOption;
12
- }
13
- export declare function PieChart(props: PieChartProps): ReactElement;
14
- //# sourceMappingURL=PieChart.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PieChart.d.ts","sourceRoot":"","sources":["../../src/PieChart/PieChart.tsx"],"names":[],"mappings":"AAeA,OAAO,EAKL,qBAAqB,EACtB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAQrC,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IAC5B,MAAM,CAAC,EAAE,qBAAqB,CAAC;CAChC;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,YAAY,CA2D3D"}
@@ -1,92 +0,0 @@
1
- // Copyright 2024 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 { use } from 'echarts/core';
15
- import { PieChart as EChartsPieChart } from 'echarts/charts';
16
- import { GridComponent, DatasetComponent, TitleComponent, TooltipComponent } from 'echarts/components';
17
- import { CanvasRenderer } from 'echarts/renderers';
18
- import { Box } from '@mui/material';
19
- import { useChartsTheme } from '../context/ChartsProvider';
20
- import { EChart } from '../EChart';
21
- use([
22
- EChartsPieChart,
23
- GridComponent,
24
- DatasetComponent,
25
- TitleComponent,
26
- TooltipComponent,
27
- CanvasRenderer
28
- ]);
29
- const PIE_WIN_WIDTH = 12;
30
- const PIE_GAP = 4;
31
- export function PieChart(props) {
32
- const { width, height, data } = props;
33
- const chartsTheme = useChartsTheme();
34
- const option = {
35
- title: {
36
- text: 'Referer of a Website',
37
- subtext: 'Fake Data',
38
- left: 'center'
39
- },
40
- tooltip: {
41
- trigger: 'item',
42
- formatter: '{a} <br/>{b} : {c} ({d}%)'
43
- },
44
- axisLabel: {
45
- overflow: 'truncate',
46
- width: width / 3
47
- },
48
- series: [
49
- {
50
- name: 'Access From',
51
- type: 'pie',
52
- radius: '55%',
53
- label: false,
54
- center: [
55
- '40%',
56
- '50%'
57
- ],
58
- data: data,
59
- emphasis: {
60
- itemStyle: {
61
- shadowBlur: 10,
62
- shadowOffsetX: 0,
63
- shadowColor: 'rgba(0, 0, 0, 0.5)'
64
- }
65
- }
66
- }
67
- ],
68
- itemStyle: {
69
- borderRadius: 2,
70
- color: chartsTheme.echartsTheme[0]
71
- }
72
- };
73
- return /*#__PURE__*/ _jsx(Box, {
74
- style: {
75
- width: width,
76
- height: height
77
- },
78
- sx: {
79
- overflow: 'auto'
80
- },
81
- children: /*#__PURE__*/ _jsx(EChart, {
82
- sx: {
83
- minHeight: height,
84
- height: data ? data.length * (PIE_WIN_WIDTH + PIE_GAP) : '100%'
85
- },
86
- option: option,
87
- theme: chartsTheme.echartsTheme
88
- })
89
- });
90
- }
91
-
92
- //# sourceMappingURL=PieChart.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/PieChart/PieChart.tsx"],"sourcesContent":["// Copyright 2024 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 { use } from 'echarts/core';\nimport { PieChart as EChartsPieChart } from 'echarts/charts';\nimport {\n GridComponent,\n DatasetComponent,\n TitleComponent,\n TooltipComponent,\n LegendComponentOption,\n} from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { Box } from '@mui/material';\nimport { ReactElement } from 'react';\nimport { useChartsTheme } from '../context/ChartsProvider';\nimport { EChart } from '../EChart';\n\nuse([EChartsPieChart, GridComponent, DatasetComponent, TitleComponent, TooltipComponent, CanvasRenderer]);\n\nconst PIE_WIN_WIDTH = 12;\nconst PIE_GAP = 4;\nexport interface PieChartData {\n name: string;\n value: number | null;\n}\n\nexport interface PieChartProps {\n width: number;\n height: number;\n data: PieChartData[] | null;\n legend?: LegendComponentOption;\n}\n\nexport function PieChart(props: PieChartProps): ReactElement {\n const { width, height, data } = props;\n const chartsTheme = useChartsTheme();\n\n const option = {\n title: {\n text: 'Referer of a Website',\n subtext: 'Fake Data',\n left: 'center',\n },\n tooltip: {\n trigger: 'item',\n formatter: '{a} <br/>{b} : {c} ({d}%)',\n },\n axisLabel: {\n overflow: 'truncate',\n width: width / 3,\n },\n series: [\n {\n name: 'Access From',\n type: 'pie',\n radius: '55%',\n label: false,\n center: ['40%', '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 },\n ],\n itemStyle: {\n borderRadius: 2,\n color: chartsTheme.echartsTheme[0],\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 minHeight: height,\n height: data ? data.length * (PIE_WIN_WIDTH + PIE_GAP) : '100%',\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n />\n </Box>\n );\n}\n"],"names":["use","PieChart","EChartsPieChart","GridComponent","DatasetComponent","TitleComponent","TooltipComponent","CanvasRenderer","Box","useChartsTheme","EChart","PIE_WIN_WIDTH","PIE_GAP","props","width","height","data","chartsTheme","option","title","text","subtext","left","tooltip","trigger","formatter","axisLabel","overflow","series","name","type","radius","label","center","emphasis","itemStyle","shadowBlur","shadowOffsetX","shadowColor","borderRadius","color","echartsTheme","style","sx","minHeight","length","theme"],"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,SAASA,GAAG,QAAQ,eAAe;AACnC,SAASC,YAAYC,eAAe,QAAQ,iBAAiB;AAC7D,SACEC,aAAa,EACbC,gBAAgB,EAChBC,cAAc,EACdC,gBAAgB,QAEX,qBAAqB;AAC5B,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,GAAG,QAAQ,gBAAgB;AAEpC,SAASC,cAAc,QAAQ,4BAA4B;AAC3D,SAASC,MAAM,QAAQ,YAAY;AAEnCV,IAAI;IAACE;IAAiBC;IAAeC;IAAkBC;IAAgBC;IAAkBC;CAAe;AAExG,MAAMI,gBAAgB;AACtB,MAAMC,UAAU;AAahB,OAAO,SAASX,SAASY,KAAoB;IAC3C,MAAM,EAAEC,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAE,GAAGH;IAChC,MAAMI,cAAcR;IAEpB,MAAMS,SAAS;QACbC,OAAO;YACLC,MAAM;YACNC,SAAS;YACTC,MAAM;QACR;QACAC,SAAS;YACPC,SAAS;YACTC,WAAW;QACb;QACAC,WAAW;YACTC,UAAU;YACVb,OAAOA,QAAQ;QACjB;QACAc,QAAQ;YACN;gBACEC,MAAM;gBACNC,MAAM;gBACNC,QAAQ;gBACRC,OAAO;gBACPC,QAAQ;oBAAC;oBAAO;iBAAM;gBACtBjB,MAAMA;gBACNkB,UAAU;oBACRC,WAAW;wBACTC,YAAY;wBACZC,eAAe;wBACfC,aAAa;oBACf;gBACF;YACF;SACD;QACDH,WAAW;YACTI,cAAc;YACdC,OAAOvB,YAAYwB,YAAY,CAAC,EAAE;QACpC;IACF;IAEA,qBACE,KAACjC;QACCkC,OAAO;YACL5B,OAAOA;YACPC,QAAQA;QACV;QACA4B,IAAI;YAAEhB,UAAU;QAAO;kBAEvB,cAAA,KAACjB;YACCiC,IAAI;gBACFC,WAAW7B;gBACXA,QAAQC,OAAOA,KAAK6B,MAAM,GAAIlC,CAAAA,gBAAgBC,OAAM,IAAK;YAC3D;YACAM,QAAQA;YACR4B,OAAO7B,YAAYwB,YAAY;;;AAIvC"}
@@ -1,2 +0,0 @@
1
- export * from './PieChart';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/PieChart/index.ts"],"names":[],"mappings":"AAaA,cAAc,YAAY,CAAC"}
@@ -1,15 +0,0 @@
1
- // Copyright 2024 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 './PieChart';
14
-
15
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/PieChart/index.ts"],"sourcesContent":["// Copyright 2024 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 './PieChart';\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,aAAa"}
@@ -1,21 +0,0 @@
1
- import { FC } from 'react';
2
- import { FormatOptions } from '@perses-dev/core';
3
- import { LineSeriesOption } from 'echarts/charts';
4
- import { GraphSeries } from '../model';
5
- import { FontSizeOption } from '../FontSizeSelector';
6
- export interface StatChartData {
7
- color: string;
8
- calculatedValue?: string | number | null;
9
- seriesData?: GraphSeries;
10
- }
11
- export interface StatChartProps {
12
- width: number;
13
- height: number;
14
- data: StatChartData;
15
- format?: FormatOptions;
16
- sparkline?: LineSeriesOption;
17
- showSeriesName?: boolean;
18
- valueFontSize?: FontSizeOption;
19
- }
20
- export declare const StatChart: FC<StatChartProps>;
21
- //# sourceMappingURL=StatChart.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StatChart.d.ts","sourceRoot":"","sources":["../../src/StatChart/StatChart.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,EAAE,EAAW,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAIjD,OAAO,EAAiC,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAKjF,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAWrD,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACzC,UAAU,CAAC,EAAE,WAAW,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,cAAc,CAAC;CAChC;AAED,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CAiIxC,CAAC"}
@@ -1,185 +0,0 @@
1
- // Copyright 2023 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 } from "react/jsx-runtime";
14
- import { useMemo } from 'react';
15
- import { Box, Typography, styled } from '@mui/material';
16
- import merge from 'lodash/merge';
17
- import { use } from 'echarts/core';
18
- import { LineChart as EChartsLineChart } from 'echarts/charts';
19
- import { GridComponent, DatasetComponent, TitleComponent, TooltipComponent } from 'echarts/components';
20
- import { CanvasRenderer } from 'echarts/renderers';
21
- import { useChartsTheme } from '../context';
22
- import { EChart } from '../EChart';
23
- import { useOptimalFontSize } from './calculateFontSize';
24
- import { formatStatChartValue } from './utils/formatStatChartValue';
25
- use([
26
- EChartsLineChart,
27
- GridComponent,
28
- DatasetComponent,
29
- TitleComponent,
30
- TooltipComponent,
31
- CanvasRenderer
32
- ]);
33
- const LINE_HEIGHT = 1.2;
34
- const SERIES_NAME_MAX_FONT_SIZE = 30;
35
- const SERIES_NAME_FONT_WEIGHT = 400;
36
- const VALUE_FONT_WEIGHT = 700;
37
- export const StatChart = (props)=>{
38
- const { width, height, data, sparkline, showSeriesName, format, valueFontSize } = props;
39
- const chartsTheme = useChartsTheme();
40
- const color = data.color;
41
- const formattedValue = formatStatChartValue(data.calculatedValue, format);
42
- const containerPadding = chartsTheme.container.padding.default;
43
- // calculate series name font size and height
44
- let seriesNameFontSize = useOptimalFontSize({
45
- text: data?.seriesData?.name ?? '',
46
- fontWeight: SERIES_NAME_FONT_WEIGHT,
47
- width,
48
- height: height * 0.125,
49
- lineHeight: LINE_HEIGHT,
50
- maxSize: SERIES_NAME_MAX_FONT_SIZE
51
- });
52
- const seriesNameHeight = showSeriesName ? seriesNameFontSize * LINE_HEIGHT + containerPadding : 0;
53
- // calculate value font size and height
54
- const availableWidth = width - containerPadding * 2;
55
- const availableHeight = height - seriesNameHeight;
56
- const optimalValueFontSize = useOptimalFontSize({
57
- text: formattedValue,
58
- // override the font size if user selects it in the settings
59
- fontSizeOverride: valueFontSize,
60
- fontWeight: VALUE_FONT_WEIGHT,
61
- // without sparkline, use only 50% of the available width so it looks better for multiseries
62
- width: sparkline ? availableWidth : availableWidth * 0.5,
63
- // with sparkline, use only 25% of available height to leave room for chart
64
- // without sparkline, value should take up 90% of available space
65
- height: sparkline ? availableHeight * 0.25 : availableHeight * 0.9,
66
- lineHeight: LINE_HEIGHT
67
- });
68
- const valueFontHeight = optimalValueFontSize * LINE_HEIGHT;
69
- // make sure the series name font size is slightly smaller than value font size
70
- seriesNameFontSize = Math.min(optimalValueFontSize * 0.7, seriesNameFontSize);
71
- const option = useMemo(()=>{
72
- if (data.seriesData === undefined) return chartsTheme.noDataOption;
73
- const series = data.seriesData;
74
- const statSeries = [];
75
- if (sparkline !== undefined) {
76
- const lineSeries = {
77
- type: 'line',
78
- name: series.name,
79
- data: series.values,
80
- zlevel: 1,
81
- symbol: 'none',
82
- animation: false,
83
- silent: true
84
- };
85
- const mergedSeries = merge(lineSeries, sparkline);
86
- statSeries.push(mergedSeries);
87
- }
88
- const option = {
89
- title: {
90
- show: false
91
- },
92
- grid: {
93
- show: false,
94
- top: '35%',
95
- right: 0,
96
- bottom: 0,
97
- left: 0,
98
- containLabel: false
99
- },
100
- xAxis: {
101
- type: 'time',
102
- show: false,
103
- boundaryGap: false
104
- },
105
- yAxis: {
106
- type: 'value',
107
- show: false,
108
- min: (value)=>{
109
- if (value.min >= 0 && value.min <= 1) {
110
- // helps with percent-decimal units, or datasets that return 0 or 1 booleans
111
- return 0;
112
- }
113
- return value.min;
114
- }
115
- },
116
- tooltip: {
117
- show: false
118
- },
119
- series: statSeries
120
- };
121
- return option;
122
- }, [
123
- data,
124
- chartsTheme,
125
- sparkline
126
- ]);
127
- const textAlignment = sparkline ? 'auto' : 'center';
128
- const textStyles = {
129
- display: 'flex',
130
- flexDirection: 'column',
131
- justifyContent: textAlignment,
132
- alignItems: textAlignment
133
- };
134
- return /*#__PURE__*/ _jsxs(Box, {
135
- sx: {
136
- height: '100%',
137
- width: '100%',
138
- ...textStyles
139
- },
140
- children: [
141
- showSeriesName && /*#__PURE__*/ _jsx(SeriesName, {
142
- padding: containerPadding,
143
- fontSize: seriesNameFontSize,
144
- children: data.seriesData?.name
145
- }),
146
- /*#__PURE__*/ _jsx(Value, {
147
- variant: "h3",
148
- color: color,
149
- fontSize: optimalValueFontSize,
150
- padding: containerPadding,
151
- children: formattedValue
152
- }),
153
- sparkline !== undefined && /*#__PURE__*/ _jsx(EChart, {
154
- sx: {
155
- width: '100%',
156
- height: height - seriesNameHeight - valueFontHeight
157
- },
158
- option: option,
159
- theme: chartsTheme.echartsTheme,
160
- renderer: "svg"
161
- })
162
- ]
163
- });
164
- };
165
- const SeriesName = styled(Typography, {
166
- shouldForwardProp: (prop)=>prop !== 'padding' && prop !== 'fontSize'
167
- })(({ theme, padding, fontSize })=>({
168
- color: theme.palette.text.secondary,
169
- padding: `${padding}px`,
170
- fontSize: `${fontSize}px`,
171
- overflow: 'hidden',
172
- textOverflow: 'ellipsis',
173
- whiteSpace: 'nowrap'
174
- }));
175
- const Value = styled(Typography, {
176
- shouldForwardProp: (prop)=>prop !== 'color' && prop !== 'padding' && prop !== 'fontSize' && prop !== 'sparkline'
177
- })(({ theme, color, padding, fontSize, sparkline })=>({
178
- color: color ?? theme.palette.text.primary,
179
- fontSize: `${fontSize}px`,
180
- padding: sparkline ? `${padding}px ${padding}px 0 ${padding}px` : ` 0 ${padding}px`,
181
- whiteSpace: 'nowrap',
182
- lineHeight: LINE_HEIGHT
183
- }));
184
-
185
- //# sourceMappingURL=StatChart.js.map