@perses-dev/components 0.51.0-rc.0 → 0.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/README.md +1 -8
  2. package/dist/EChart/EChart.d.ts.map +1 -1
  3. package/dist/EChart/EChart.js +13 -4
  4. package/dist/EChart/EChart.js.map +1 -1
  5. package/dist/TimeSeriesTooltip/index.d.ts +0 -1
  6. package/dist/TimeSeriesTooltip/index.d.ts.map +1 -1
  7. package/dist/TimeSeriesTooltip/index.js +0 -1
  8. package/dist/TimeSeriesTooltip/index.js.map +1 -1
  9. package/dist/cjs/EChart/EChart.js +11 -2
  10. package/dist/cjs/TimeSeriesTooltip/index.js +0 -1
  11. package/dist/cjs/context/ChartsProvider.js +3 -1
  12. package/dist/cjs/index.js +0 -7
  13. package/dist/cjs/test-utils/theme.js +1 -0
  14. package/dist/cjs/utils/axis.js +3 -18
  15. package/dist/cjs/utils/format.js +0 -21
  16. package/dist/context/ChartsProvider.d.ts +2 -0
  17. package/dist/context/ChartsProvider.d.ts.map +1 -1
  18. package/dist/context/ChartsProvider.js +3 -1
  19. package/dist/context/ChartsProvider.js.map +1 -1
  20. package/dist/index.d.ts +0 -7
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +0 -7
  23. package/dist/index.js.map +1 -1
  24. package/dist/model/graph.d.ts +0 -1
  25. package/dist/model/graph.d.ts.map +1 -1
  26. package/dist/model/graph.js.map +1 -1
  27. package/dist/test-utils/theme.d.ts.map +1 -1
  28. package/dist/test-utils/theme.js +1 -0
  29. package/dist/test-utils/theme.js.map +1 -1
  30. package/dist/utils/axis.d.ts +0 -4
  31. package/dist/utils/axis.d.ts.map +1 -1
  32. package/dist/utils/axis.js +0 -9
  33. package/dist/utils/axis.js.map +1 -1
  34. package/dist/utils/chart-actions.d.ts +0 -2
  35. package/dist/utils/chart-actions.d.ts.map +1 -1
  36. package/dist/utils/chart-actions.js.map +1 -1
  37. package/dist/utils/format.d.ts +0 -1
  38. package/dist/utils/format.d.ts.map +1 -1
  39. package/dist/utils/format.js +0 -20
  40. package/dist/utils/format.js.map +1 -1
  41. package/package.json +4 -9
  42. package/dist/BarChart/BarChart.d.ts +0 -16
  43. package/dist/BarChart/BarChart.d.ts.map +0 -1
  44. package/dist/BarChart/BarChart.js +0 -134
  45. package/dist/BarChart/BarChart.js.map +0 -1
  46. package/dist/BarChart/index.d.ts +0 -2
  47. package/dist/BarChart/index.d.ts.map +0 -1
  48. package/dist/BarChart/index.js +0 -15
  49. package/dist/BarChart/index.js.map +0 -1
  50. package/dist/GaugeChart/GaugeChart.d.ts +0 -23
  51. package/dist/GaugeChart/GaugeChart.d.ts.map +0 -1
  52. package/dist/GaugeChart/GaugeChart.js +0 -214
  53. package/dist/GaugeChart/GaugeChart.js.map +0 -1
  54. package/dist/GaugeChart/index.d.ts +0 -2
  55. package/dist/GaugeChart/index.d.ts.map +0 -1
  56. package/dist/GaugeChart/index.js +0 -15
  57. package/dist/GaugeChart/index.js.map +0 -1
  58. package/dist/LineChart/LineChart.d.ts +0 -22
  59. package/dist/LineChart/LineChart.d.ts.map +0 -1
  60. package/dist/LineChart/LineChart.js +0 -266
  61. package/dist/LineChart/LineChart.js.map +0 -1
  62. package/dist/LineChart/index.d.ts +0 -2
  63. package/dist/LineChart/index.d.ts.map +0 -1
  64. package/dist/LineChart/index.js +0 -15
  65. package/dist/LineChart/index.js.map +0 -1
  66. package/dist/PieChart/PieChart.d.ts +0 -14
  67. package/dist/PieChart/PieChart.d.ts.map +0 -1
  68. package/dist/PieChart/PieChart.js +0 -92
  69. package/dist/PieChart/PieChart.js.map +0 -1
  70. package/dist/PieChart/index.d.ts +0 -2
  71. package/dist/PieChart/index.d.ts.map +0 -1
  72. package/dist/PieChart/index.js +0 -15
  73. package/dist/PieChart/index.js.map +0 -1
  74. package/dist/StatChart/StatChart.d.ts +0 -21
  75. package/dist/StatChart/StatChart.d.ts.map +0 -1
  76. package/dist/StatChart/StatChart.js +0 -189
  77. package/dist/StatChart/StatChart.js.map +0 -1
  78. package/dist/StatChart/calculateFontSize.d.ts +0 -16
  79. package/dist/StatChart/calculateFontSize.d.ts.map +0 -1
  80. package/dist/StatChart/calculateFontSize.js +0 -49
  81. package/dist/StatChart/calculateFontSize.js.map +0 -1
  82. package/dist/StatChart/index.d.ts +0 -2
  83. package/dist/StatChart/index.d.ts.map +0 -1
  84. package/dist/StatChart/index.js +0 -15
  85. package/dist/StatChart/index.js.map +0 -1
  86. package/dist/StatChart/utils/formatStatChartValue.d.ts +0 -3
  87. package/dist/StatChart/utils/formatStatChartValue.d.ts.map +0 -1
  88. package/dist/StatChart/utils/formatStatChartValue.js +0 -26
  89. package/dist/StatChart/utils/formatStatChartValue.js.map +0 -1
  90. package/dist/StatusHistoryChart/StatusHistoryChart.d.ts +0 -27
  91. package/dist/StatusHistoryChart/StatusHistoryChart.d.ts.map +0 -1
  92. package/dist/StatusHistoryChart/StatusHistoryChart.js +0 -132
  93. package/dist/StatusHistoryChart/StatusHistoryChart.js.map +0 -1
  94. package/dist/StatusHistoryChart/StatusHistoryTooltip.d.ts +0 -13
  95. package/dist/StatusHistoryChart/StatusHistoryTooltip.d.ts.map +0 -1
  96. package/dist/StatusHistoryChart/StatusHistoryTooltip.js +0 -47
  97. package/dist/StatusHistoryChart/StatusHistoryTooltip.js.map +0 -1
  98. package/dist/StatusHistoryChart/get-formatted-axis-label.d.ts +0 -2
  99. package/dist/StatusHistoryChart/get-formatted-axis-label.d.ts.map +0 -1
  100. package/dist/StatusHistoryChart/get-formatted-axis-label.js +0 -41
  101. package/dist/StatusHistoryChart/get-formatted-axis-label.js.map +0 -1
  102. package/dist/StatusHistoryChart/index.d.ts +0 -3
  103. package/dist/StatusHistoryChart/index.d.ts.map +0 -1
  104. package/dist/StatusHistoryChart/index.js +0 -16
  105. package/dist/StatusHistoryChart/index.js.map +0 -1
  106. package/dist/StatusHistoryChart/utils/get-color.d.ts +0 -6
  107. package/dist/StatusHistoryChart/utils/get-color.d.ts.map +0 -1
  108. package/dist/StatusHistoryChart/utils/get-color.js +0 -100
  109. package/dist/StatusHistoryChart/utils/get-color.js.map +0 -1
  110. package/dist/StatusHistoryChart/utils/get-tooltip-position.d.ts +0 -3
  111. package/dist/StatusHistoryChart/utils/get-tooltip-position.d.ts.map +0 -1
  112. package/dist/StatusHistoryChart/utils/get-tooltip-position.js +0 -27
  113. package/dist/StatusHistoryChart/utils/get-tooltip-position.js.map +0 -1
  114. package/dist/TimeChart/TimeChart.d.ts +0 -24
  115. package/dist/TimeChart/TimeChart.d.ts.map +0 -1
  116. package/dist/TimeChart/TimeChart.js +0 -394
  117. package/dist/TimeChart/TimeChart.js.map +0 -1
  118. package/dist/TimeChart/index.d.ts +0 -2
  119. package/dist/TimeChart/index.d.ts.map +0 -1
  120. package/dist/TimeChart/index.js +0 -15
  121. package/dist/TimeChart/index.js.map +0 -1
  122. package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts +0 -21
  123. package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts.map +0 -1
  124. package/dist/TimeSeriesTooltip/LineChartTooltip.js +0 -101
  125. package/dist/TimeSeriesTooltip/LineChartTooltip.js.map +0 -1
  126. package/dist/cjs/BarChart/BarChart.js +0 -142
  127. package/dist/cjs/BarChart/index.js +0 -30
  128. package/dist/cjs/GaugeChart/GaugeChart.js +0 -227
  129. package/dist/cjs/GaugeChart/index.js +0 -30
  130. package/dist/cjs/LineChart/LineChart.js +0 -274
  131. package/dist/cjs/LineChart/index.js +0 -30
  132. package/dist/cjs/PieChart/PieChart.js +0 -100
  133. package/dist/cjs/PieChart/index.js +0 -30
  134. package/dist/cjs/StatChart/StatChart.js +0 -202
  135. package/dist/cjs/StatChart/calculateFontSize.js +0 -55
  136. package/dist/cjs/StatChart/index.js +0 -30
  137. package/dist/cjs/StatChart/utils/formatStatChartValue.js +0 -34
  138. package/dist/cjs/StatusHistoryChart/StatusHistoryChart.js +0 -140
  139. package/dist/cjs/StatusHistoryChart/StatusHistoryTooltip.js +0 -55
  140. package/dist/cjs/StatusHistoryChart/get-formatted-axis-label.js +0 -48
  141. package/dist/cjs/StatusHistoryChart/index.js +0 -31
  142. package/dist/cjs/StatusHistoryChart/utils/get-color.js +0 -125
  143. package/dist/cjs/StatusHistoryChart/utils/get-tooltip-position.js +0 -35
  144. package/dist/cjs/TimeChart/TimeChart.js +0 -407
  145. package/dist/cjs/TimeChart/index.js +0 -30
  146. package/dist/cjs/TimeSeriesTooltip/LineChartTooltip.js +0 -114
@@ -1,142 +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
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- Object.defineProperty(exports, "BarChart", {
18
- enumerable: true,
19
- get: function() {
20
- return BarChart;
21
- }
22
- });
23
- const _jsxruntime = require("react/jsx-runtime");
24
- const _react = require("react");
25
- const _core = require("@perses-dev/core");
26
- const _core1 = require("echarts/core");
27
- const _charts = require("echarts/charts");
28
- const _components = require("echarts/components");
29
- const _renderers = require("echarts/renderers");
30
- const _material = require("@mui/material");
31
- const _context = require("../context");
32
- const _EChart = require("../EChart");
33
- const _utils = require("../utils");
34
- (0, _core1.use)([
35
- _charts.BarChart,
36
- _components.GridComponent,
37
- _components.DatasetComponent,
38
- _components.TitleComponent,
39
- _components.TooltipComponent,
40
- _renderers.CanvasRenderer
41
- ]);
42
- const BAR_WIN_WIDTH = 14;
43
- const BAR_GAP = 6;
44
- function BarChart(props) {
45
- const { width, height, data, format = {
46
- unit: 'decimal'
47
- }, mode = 'value' } = props;
48
- const chartsTheme = (0, _context.useChartsTheme)();
49
- const option = (0, _react.useMemo)(()=>{
50
- if (!data || !data.length) return chartsTheme.noDataOption;
51
- const source = [];
52
- data.map((d)=>{
53
- source.push([
54
- d.label,
55
- d.value
56
- ]);
57
- });
58
- return {
59
- title: {
60
- show: false
61
- },
62
- dataset: [
63
- {
64
- dimensions: [
65
- 'label',
66
- 'value'
67
- ],
68
- source: source
69
- }
70
- ],
71
- xAxis: (0, _utils.getFormattedAxis)({}, format),
72
- yAxis: {
73
- type: 'category',
74
- splitLine: {
75
- show: false
76
- },
77
- axisLabel: {
78
- overflow: 'truncate',
79
- width: width / 3
80
- }
81
- },
82
- series: {
83
- type: 'bar',
84
- label: {
85
- show: true,
86
- position: 'right',
87
- formatter: (params)=>{
88
- if (!params.data[1]) {
89
- return undefined;
90
- }
91
- if (mode === 'percentage') {
92
- return (0, _core.formatValue)(params.data[1], {
93
- unit: 'percent',
94
- decimalPlaces: format.decimalPlaces
95
- });
96
- }
97
- return (0, _core.formatValue)(params.data[1], format);
98
- },
99
- barMinWidth: BAR_WIN_WIDTH,
100
- barCategoryGap: BAR_GAP
101
- },
102
- itemStyle: {
103
- borderRadius: 4,
104
- color: chartsTheme.echartsTheme[0]
105
- }
106
- },
107
- tooltip: {
108
- appendToBody: true,
109
- confine: true,
110
- formatter: (params)=>params.data[1] && `<b>${params.name}</b> &emsp; ${(0, _core.formatValue)(params.data[1], format)}`
111
- },
112
- // increase distance between grid and container to prevent y axis labels from getting cut off
113
- grid: {
114
- left: '5%',
115
- right: '5%'
116
- }
117
- };
118
- }, [
119
- data,
120
- chartsTheme,
121
- width,
122
- mode,
123
- format
124
- ]);
125
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
126
- style: {
127
- width: width,
128
- height: height
129
- },
130
- sx: {
131
- overflow: 'auto'
132
- },
133
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_EChart.EChart, {
134
- sx: {
135
- minHeight: height,
136
- height: data ? data.length * (BAR_WIN_WIDTH + BAR_GAP) : '100%'
137
- },
138
- option: option,
139
- theme: chartsTheme.echartsTheme
140
- })
141
- });
142
- }
@@ -1,30 +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
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- _export_star(require("./BarChart"), exports);
18
- function _export_star(from, to) {
19
- Object.keys(from).forEach(function(k) {
20
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
21
- Object.defineProperty(to, k, {
22
- enumerable: true,
23
- get: function() {
24
- return from[k];
25
- }
26
- });
27
- }
28
- });
29
- return from;
30
- }
@@ -1,227 +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
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- function _export(target, all) {
18
- for(var name in all)Object.defineProperty(target, name, {
19
- enumerable: true,
20
- get: all[name]
21
- });
22
- }
23
- _export(exports, {
24
- GaugeChart: function() {
25
- return GaugeChart;
26
- },
27
- getResponsiveValueSize: function() {
28
- return getResponsiveValueSize;
29
- }
30
- });
31
- const _jsxruntime = require("react/jsx-runtime");
32
- const _core = require("@perses-dev/core");
33
- const _core1 = require("echarts/core");
34
- const _charts = require("echarts/charts");
35
- const _components = require("echarts/components");
36
- const _renderers = require("echarts/renderers");
37
- const _context = require("../context");
38
- const _EChart = require("../EChart");
39
- (0, _core1.use)([
40
- _charts.GaugeChart,
41
- _components.GridComponent,
42
- _components.TitleComponent,
43
- _components.TooltipComponent,
44
- _renderers.CanvasRenderer
45
- ]);
46
- const PROGRESS_WIDTH = 16;
47
- // adjusts when to show pointer icon
48
- const GAUGE_SMALL_BREAKPOINT = 170;
49
- function GaugeChart(props) {
50
- const { width, height, data, format, axisLine, max } = props;
51
- const chartsTheme = (0, _context.useChartsTheme)();
52
- // useDeepMemo ensures value size util does not rerun everytime you hover on the chart
53
- const option = (0, _core.useDeepMemo)(()=>{
54
- if (data.value === undefined) return chartsTheme.noDataOption;
55
- // adjusts fontSize depending on number of characters
56
- const valueSizeClamp = getResponsiveValueSize(data.value, format, width, height);
57
- return {
58
- title: {
59
- show: false
60
- },
61
- tooltip: {
62
- show: false
63
- },
64
- series: [
65
- {
66
- type: 'gauge',
67
- center: [
68
- '50%',
69
- '65%'
70
- ],
71
- radius: '86%',
72
- startAngle: 200,
73
- endAngle: -20,
74
- min: 0,
75
- max,
76
- silent: true,
77
- progress: {
78
- show: true,
79
- width: PROGRESS_WIDTH,
80
- itemStyle: {
81
- color: 'auto'
82
- }
83
- },
84
- pointer: {
85
- show: false
86
- },
87
- axisLine: {
88
- lineStyle: {
89
- color: [
90
- [
91
- 1,
92
- 'rgba(127,127,127,0.35)'
93
- ]
94
- ],
95
- width: PROGRESS_WIDTH
96
- }
97
- },
98
- axisTick: {
99
- show: false,
100
- distance: 0
101
- },
102
- splitLine: {
103
- show: false
104
- },
105
- axisLabel: {
106
- show: false,
107
- distance: -18,
108
- color: '#999',
109
- fontSize: 12
110
- },
111
- anchor: {
112
- show: false
113
- },
114
- title: {
115
- show: false
116
- },
117
- detail: {
118
- show: false
119
- },
120
- data: [
121
- {
122
- value: data.value
123
- }
124
- ]
125
- },
126
- {
127
- type: 'gauge',
128
- center: [
129
- '50%',
130
- '65%'
131
- ],
132
- radius: '100%',
133
- startAngle: 200,
134
- endAngle: -20,
135
- min: 0,
136
- max,
137
- pointer: {
138
- show: true,
139
- // pointer hidden for small panels, path taken from ex: https://echarts.apache.org/examples/en/editor.html?c=gauge-grade
140
- icon: width > GAUGE_SMALL_BREAKPOINT ? 'path://M12.8,0.7l12,40.1H0.7L12.8,0.7z' : 'none',
141
- length: 10,
142
- width: 5,
143
- offsetCenter: [
144
- 0,
145
- '-49%'
146
- ],
147
- itemStyle: {
148
- color: 'auto'
149
- }
150
- },
151
- axisLine,
152
- axisTick: {
153
- show: false
154
- },
155
- splitLine: {
156
- show: false
157
- },
158
- axisLabel: {
159
- show: false
160
- },
161
- detail: {
162
- show: true,
163
- width: '60%',
164
- borderRadius: 8,
165
- offsetCenter: [
166
- 0,
167
- '-9%'
168
- ],
169
- color: 'inherit',
170
- fontSize: valueSizeClamp,
171
- formatter: data.value === null ? // at this level because the `formatter` function argument is `NaN`
172
- // when the value is `null`, making it difficult to differentiate
173
- // `null` from a true `NaN` case.
174
- ()=>'null' : (value)=>{
175
- return (0, _core.formatValue)(value, format);
176
- }
177
- },
178
- data: [
179
- {
180
- value: data.value,
181
- name: data.label,
182
- // TODO: new UX for series names, create separate React component or reuse ListLegendItem
183
- // https://echarts.apache.org/en/option.html#series-gauge.data.title
184
- title: {
185
- show: true,
186
- color: chartsTheme.echartsTheme.textStyle?.color ?? 'inherit',
187
- offsetCenter: [
188
- 0,
189
- '55%'
190
- ],
191
- overflow: 'truncate',
192
- fontSize: 12,
193
- width: width * 0.8
194
- }
195
- }
196
- ]
197
- }
198
- ]
199
- };
200
- }, [
201
- data,
202
- width,
203
- height,
204
- chartsTheme,
205
- format,
206
- axisLine,
207
- max
208
- ]);
209
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_EChart.EChart, {
210
- sx: {
211
- width: width,
212
- height: height,
213
- padding: `${chartsTheme.container.padding.default}px`
214
- },
215
- option: option,
216
- theme: chartsTheme.echartsTheme
217
- });
218
- }
219
- function getResponsiveValueSize(value, format, width, height) {
220
- const MIN_SIZE = 3;
221
- const MAX_SIZE = 24;
222
- const SIZE_MULTIPLIER = 0.7;
223
- const formattedValue = typeof value === 'number' ? (0, _core.formatValue)(value, format) : `${value}`;
224
- const valueCharacters = formattedValue.length ?? 2;
225
- const valueSize = Math.min(width, height) / valueCharacters * SIZE_MULTIPLIER;
226
- return `clamp(${MIN_SIZE}px, ${valueSize}px, ${MAX_SIZE}px)`;
227
- }
@@ -1,30 +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
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- _export_star(require("./GaugeChart"), exports);
18
- function _export_star(from, to) {
19
- Object.keys(from).forEach(function(k) {
20
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
21
- Object.defineProperty(to, k, {
22
- enumerable: true,
23
- get: function() {
24
- return from[k];
25
- }
26
- });
27
- }
28
- });
29
- return from;
30
- }