@perses-dev/components 0.4.2 → 0.5.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 (140) hide show
  1. package/README.md +18 -0
  2. package/dist/EChart.d.ts +4 -1
  3. package/dist/EChart.d.ts.map +1 -1
  4. package/dist/EChart.js +1 -1
  5. package/dist/{GaugeChart.d.ts → GaugeChart/GaugeChart.d.ts} +2 -1
  6. package/dist/GaugeChart/GaugeChart.d.ts.map +1 -0
  7. package/dist/GaugeChart/GaugeChart.js +1 -0
  8. package/dist/GaugeChart/index.d.ts +2 -0
  9. package/dist/GaugeChart/index.d.ts.map +1 -0
  10. package/dist/GaugeChart/index.js +1 -0
  11. package/dist/InfoTooltip/InfoTooltip.d.ts +17 -0
  12. package/dist/InfoTooltip/InfoTooltip.d.ts.map +1 -0
  13. package/dist/InfoTooltip/InfoTooltip.js +1 -0
  14. package/dist/InfoTooltip/InfoTooltip.test.d.ts +2 -0
  15. package/dist/InfoTooltip/InfoTooltip.test.d.ts.map +1 -0
  16. package/dist/InfoTooltip/InfoTooltip.test.js +1 -0
  17. package/dist/InfoTooltip/index.d.ts +2 -0
  18. package/dist/InfoTooltip/index.d.ts.map +1 -0
  19. package/dist/InfoTooltip/index.js +1 -0
  20. package/dist/LineChart/LineChart.d.ts +17 -0
  21. package/dist/LineChart/LineChart.d.ts.map +1 -0
  22. package/dist/LineChart/LineChart.js +1 -0
  23. package/dist/LineChart/index.d.ts +3 -0
  24. package/dist/LineChart/index.d.ts.map +1 -0
  25. package/dist/LineChart/index.js +1 -0
  26. package/dist/LineChart/utils.d.ts +12 -0
  27. package/dist/LineChart/utils.d.ts.map +1 -0
  28. package/dist/LineChart/utils.js +1 -0
  29. package/dist/{StatChart.d.ts → StatChart/StatChart.d.ts} +4 -9
  30. package/dist/StatChart/StatChart.d.ts.map +1 -0
  31. package/dist/StatChart/StatChart.js +1 -0
  32. package/dist/StatChart/StatChart.test.d.ts +2 -0
  33. package/dist/StatChart/StatChart.test.d.ts.map +1 -0
  34. package/dist/StatChart/StatChart.test.js +1 -0
  35. package/dist/StatChart/index.d.ts +2 -0
  36. package/dist/StatChart/index.d.ts.map +1 -0
  37. package/dist/StatChart/index.js +1 -0
  38. package/dist/{tooltip → Tooltip}/SeriesInfo.d.ts +0 -0
  39. package/dist/{tooltip → Tooltip}/SeriesInfo.d.ts.map +1 -1
  40. package/dist/{tooltip → Tooltip}/SeriesInfo.js +0 -0
  41. package/dist/{tooltip → Tooltip}/SeriesMarker.d.ts +0 -0
  42. package/dist/{tooltip → Tooltip}/SeriesMarker.d.ts.map +1 -1
  43. package/dist/{tooltip → Tooltip}/SeriesMarker.js +0 -0
  44. package/dist/{tooltip → Tooltip}/Tooltip.d.ts +1 -1
  45. package/dist/{tooltip → Tooltip}/Tooltip.d.ts.map +1 -1
  46. package/dist/{tooltip → Tooltip}/Tooltip.js +0 -0
  47. package/dist/{tooltip → Tooltip}/TooltipContent.d.ts +0 -0
  48. package/dist/{tooltip → Tooltip}/TooltipContent.d.ts.map +1 -1
  49. package/dist/{tooltip → Tooltip}/TooltipContent.js +0 -0
  50. package/dist/{tooltip → Tooltip}/focused-series.d.ts +1 -1
  51. package/dist/{tooltip → Tooltip}/focused-series.d.ts.map +1 -1
  52. package/dist/{tooltip → Tooltip}/focused-series.js +0 -0
  53. package/dist/Tooltip/focused-series.test.d.ts +2 -0
  54. package/dist/Tooltip/focused-series.test.d.ts.map +1 -0
  55. package/dist/Tooltip/focused-series.test.js +1 -0
  56. package/dist/Tooltip/index.d.ts +3 -0
  57. package/dist/Tooltip/index.d.ts.map +1 -0
  58. package/dist/Tooltip/index.js +1 -0
  59. package/dist/{tooltip → Tooltip}/tooltip-model.d.ts +0 -0
  60. package/dist/{tooltip → Tooltip}/tooltip-model.d.ts.map +1 -1
  61. package/dist/{tooltip → Tooltip}/tooltip-model.js +0 -0
  62. package/dist/cjs/EChart.js +3 -3
  63. package/dist/cjs/{GaugeChart.js → GaugeChart/GaugeChart.js} +12 -45
  64. package/dist/cjs/GaugeChart/index.js +29 -0
  65. package/dist/cjs/InfoTooltip/InfoTooltip.js +39 -0
  66. package/dist/cjs/InfoTooltip/InfoTooltip.test.js +33 -0
  67. package/dist/cjs/InfoTooltip/index.js +29 -0
  68. package/dist/cjs/LineChart/LineChart.js +154 -0
  69. package/dist/cjs/LineChart/index.js +29 -0
  70. package/dist/cjs/LineChart/utils.js +72 -0
  71. package/dist/cjs/StatChart/StatChart.js +104 -0
  72. package/dist/cjs/StatChart/StatChart.test.js +45 -0
  73. package/dist/cjs/StatChart/index.js +29 -0
  74. package/dist/cjs/{tooltip → Tooltip}/SeriesInfo.js +0 -0
  75. package/dist/cjs/{tooltip → Tooltip}/SeriesMarker.js +0 -0
  76. package/dist/cjs/{tooltip → Tooltip}/Tooltip.js +0 -0
  77. package/dist/cjs/{tooltip → Tooltip}/TooltipContent.js +0 -0
  78. package/dist/cjs/{tooltip → Tooltip}/focused-series.js +0 -0
  79. package/dist/cjs/Tooltip/focused-series.test.js +57 -0
  80. package/dist/cjs/Tooltip/index.js +30 -0
  81. package/dist/cjs/{tooltip → Tooltip}/tooltip-model.js +0 -0
  82. package/dist/cjs/context/ChartsThemeProvider.js +36 -0
  83. package/dist/cjs/index.js +5 -4
  84. package/dist/cjs/model/{graph-model.js → graph.js} +0 -0
  85. package/dist/cjs/model/index.js +31 -0
  86. package/dist/cjs/model/theme.js +14 -0
  87. package/dist/cjs/model/units.js +58 -85
  88. package/dist/cjs/test/index.js +29 -0
  89. package/dist/cjs/test/render.js +26 -0
  90. package/dist/cjs/test/setup-tests.js +18 -0
  91. package/dist/cjs/utils/index.js +30 -0
  92. package/dist/cjs/utils/theme-gen.js +180 -0
  93. package/dist/cjs/utils/theme-gen.test.js +196 -0
  94. package/dist/context/ChartsThemeProvider.d.ts +11 -0
  95. package/dist/context/ChartsThemeProvider.d.ts.map +1 -0
  96. package/dist/context/ChartsThemeProvider.js +1 -0
  97. package/dist/index.d.ts +5 -4
  98. package/dist/index.d.ts.map +1 -1
  99. package/dist/index.js +1 -1
  100. package/dist/model/{graph-model.d.ts → graph.d.ts} +6 -2
  101. package/dist/model/graph.d.ts.map +1 -0
  102. package/dist/model/{graph-model.js → graph.js} +0 -0
  103. package/dist/model/index.d.ts +4 -0
  104. package/dist/model/index.d.ts.map +1 -0
  105. package/dist/model/index.js +1 -0
  106. package/dist/model/theme.d.ts +16 -0
  107. package/dist/model/theme.d.ts.map +1 -0
  108. package/dist/model/theme.js +1 -0
  109. package/dist/model/units.d.ts +22 -11
  110. package/dist/model/units.d.ts.map +1 -1
  111. package/dist/model/units.js +1 -1
  112. package/dist/test/index.d.ts +2 -0
  113. package/dist/test/index.d.ts.map +1 -0
  114. package/dist/test/index.js +1 -0
  115. package/dist/test/render.d.ts +7 -0
  116. package/dist/test/render.d.ts.map +1 -0
  117. package/dist/test/render.js +1 -0
  118. package/dist/test/setup-tests.d.ts +2 -0
  119. package/dist/test/setup-tests.d.ts.map +1 -0
  120. package/dist/test/setup-tests.js +1 -0
  121. package/dist/utils/index.d.ts +3 -0
  122. package/dist/utils/index.d.ts.map +1 -0
  123. package/dist/utils/index.js +1 -0
  124. package/dist/utils/theme-gen.d.ts +6 -0
  125. package/dist/utils/theme-gen.d.ts.map +1 -0
  126. package/dist/utils/theme-gen.js +1 -0
  127. package/dist/utils/theme-gen.test.d.ts +2 -0
  128. package/dist/utils/theme-gen.test.d.ts.map +1 -0
  129. package/dist/utils/theme-gen.test.js +1 -0
  130. package/package.json +5 -4
  131. package/dist/GaugeChart.d.ts.map +0 -1
  132. package/dist/GaugeChart.js +0 -1
  133. package/dist/LineChart.d.ts +0 -22
  134. package/dist/LineChart.d.ts.map +0 -1
  135. package/dist/LineChart.js +0 -1
  136. package/dist/StatChart.d.ts.map +0 -1
  137. package/dist/StatChart.js +0 -1
  138. package/dist/cjs/LineChart.js +0 -252
  139. package/dist/cjs/StatChart.js +0 -207
  140. package/dist/model/graph-model.d.ts.map +0 -1
@@ -0,0 +1,196 @@
1
+ "use strict";
2
+ // Copyright 2022 The Perses Authors
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const material_1 = require("@mui/material");
16
+ const theme_gen_1 = require("./theme-gen");
17
+ describe('generateChartsTheme', () => {
18
+ const muiTheme = (0, material_1.createTheme)({});
19
+ const echartsThemeOverrides = {
20
+ legend: {
21
+ textStyle: {
22
+ color: 'yellow',
23
+ },
24
+ },
25
+ line: {
26
+ showSymbol: true,
27
+ smooth: true,
28
+ },
29
+ };
30
+ const chartsTheme = (0, theme_gen_1.generateChartsTheme)('perses', muiTheme, echartsThemeOverrides);
31
+ it('should return perses specific charts theme from converted MUI theme', () => {
32
+ expect(chartsTheme).toMatchInlineSnapshot(`
33
+ Object {
34
+ "echartsTheme": Object {
35
+ "bar": Object {
36
+ "barMaxWidth": 150,
37
+ "itemStyle": Object {
38
+ "borderColor": "#e0e0e0",
39
+ "borderWidth": 0,
40
+ },
41
+ },
42
+ "categoryAxis": Object {
43
+ "axisLabel": Object {
44
+ "color": "rgba(0, 0, 0, 0.87)",
45
+ "margin": 15,
46
+ "show": true,
47
+ },
48
+ "axisLine": Object {
49
+ "lineStyle": Object {
50
+ "color": "#757575",
51
+ },
52
+ "show": true,
53
+ },
54
+ "axisTick": Object {
55
+ "length": 6,
56
+ "lineStyle": Object {
57
+ "color": "#757575",
58
+ },
59
+ "show": false,
60
+ },
61
+ "show": true,
62
+ "splitArea": Object {
63
+ "areaStyle": Object {
64
+ "color": Array [
65
+ "#e0e0e0",
66
+ ],
67
+ },
68
+ "show": false,
69
+ },
70
+ "splitLine": Object {
71
+ "lineStyle": Object {
72
+ "color": "#e0e0e0",
73
+ "opacity": 0.6,
74
+ "width": 0.5,
75
+ },
76
+ "show": true,
77
+ },
78
+ },
79
+ "color": Array [
80
+ "#8dd3c7",
81
+ "#bebada",
82
+ "#fb8072",
83
+ "#80b1d3",
84
+ "#fdb462",
85
+ ],
86
+ "gauge": Object {
87
+ "detail": Object {
88
+ "fontSize": 18,
89
+ "fontWeight": 600,
90
+ "valueAnimation": false,
91
+ },
92
+ "splitLine": Object {
93
+ "distance": 0,
94
+ "length": 4,
95
+ "lineStyle": Object {
96
+ "width": 1,
97
+ },
98
+ },
99
+ "splitNumber": 12,
100
+ },
101
+ "grid": Object {
102
+ "bottom": 0,
103
+ "containLabel": true,
104
+ "left": 20,
105
+ "right": 20,
106
+ "top": 5,
107
+ },
108
+ "legend": Object {
109
+ "orient": "horizontal",
110
+ "pageIconColor": "rgba(0, 0, 0, 0.54)",
111
+ "pageIconInactiveColor": "rgba(0, 0, 0, 0.26)",
112
+ "pageTextStyle": Object {
113
+ "color": "#757575",
114
+ },
115
+ "textStyle": Object {
116
+ "color": "yellow",
117
+ },
118
+ },
119
+ "line": Object {
120
+ "emphasis": Object {
121
+ "lineStyle": Object {
122
+ "width": 1.5,
123
+ },
124
+ },
125
+ "lineStyle": Object {
126
+ "width": 1,
127
+ },
128
+ "showSymbol": true,
129
+ "smooth": true,
130
+ "symbol": "circle",
131
+ "symbolSize": 4,
132
+ },
133
+ "textStyle": Object {
134
+ "color": "rgba(0, 0, 0, 0.87)",
135
+ "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif",
136
+ "fontSize": 12,
137
+ },
138
+ "title": Object {
139
+ "show": false,
140
+ },
141
+ "toolbox": Object {
142
+ "iconStyle": Object {
143
+ "borderColor": "rgba(0, 0, 0, 0.87)",
144
+ },
145
+ "right": 10,
146
+ "show": true,
147
+ "top": 10,
148
+ },
149
+ "tooltip": Object {},
150
+ "valueAxis": Object {
151
+ "axisLabel": Object {
152
+ "color": "rgba(0, 0, 0, 0.87)",
153
+ "margin": 12,
154
+ },
155
+ "axisLine": Object {
156
+ "show": false,
157
+ },
158
+ "show": true,
159
+ "splitLine": Object {
160
+ "lineStyle": Object {
161
+ "color": "#e0e0e0",
162
+ "opacity": 0.6,
163
+ "width": 0.5,
164
+ },
165
+ "show": true,
166
+ },
167
+ },
168
+ },
169
+ "noDataOption": Object {
170
+ "title": Object {
171
+ "left": "center",
172
+ "show": true,
173
+ "text": "No data",
174
+ "textStyle": Object {
175
+ "color": "rgba(0, 0, 0, 0.87)",
176
+ "fontSize": 16,
177
+ "fontWeight": 400,
178
+ },
179
+ "top": "center",
180
+ },
181
+ "xAxis": Object {
182
+ "show": false,
183
+ },
184
+ "yAxis": Object {
185
+ "show": false,
186
+ },
187
+ },
188
+ "sparkline": Object {
189
+ "color": "#1976d2",
190
+ "width": 2,
191
+ },
192
+ "themeName": "perses",
193
+ }
194
+ `);
195
+ });
196
+ });
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { PersesChartsTheme } from '../model';
3
+ export interface ChartsThemeProviderProps {
4
+ themeName: string;
5
+ chartsTheme?: PersesChartsTheme;
6
+ children?: React.ReactNode;
7
+ }
8
+ export declare function ChartsThemeProvider(props: ChartsThemeProviderProps): JSX.Element;
9
+ export declare const ChartsThemeContext: React.Context<PersesChartsTheme | undefined>;
10
+ export declare function useChartsTheme(): PersesChartsTheme;
11
+ //# sourceMappingURL=ChartsThemeProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartsThemeProvider.d.ts","sourceRoot":"","sources":["../../src/context/ChartsThemeProvider.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAEzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,MAAM,WAAW,wBAAwB;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,eASlE;AAED,eAAO,MAAM,kBAAkB,8CAA0D,CAAC;AAE1F,wBAAgB,cAAc,IAAI,iBAAiB,CAMlD"}
@@ -0,0 +1 @@
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{createContext,useContext}from"react";import{registerTheme}from"echarts";export function ChartsThemeProvider(e){const{children:t,themeName:r,chartsTheme:o}=e;return void 0!==o&&void 0!==o.echartsTheme&&registerTheme(r,o.echartsTheme),_jsx(ChartsThemeContext.Provider,{value:o,children:t})}export const ChartsThemeContext=createContext(void 0);export function useChartsTheme(){const e=useContext(ChartsThemeContext);if(void 0===e)throw new Error("No ChartsThemeContext found. Did you forget a Provider?");return e}
package/dist/index.d.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  export * from './EChart';
2
2
  export * from './ErrorAlert';
3
3
  export * from './ErrorBoundary';
4
- export * from './GaugeChart';
4
+ export * from './InfoTooltip';
5
5
  export * from './LineChart';
6
+ export * from './GaugeChart';
6
7
  export * from './StatChart';
7
- export * from './utils/combine-sx';
8
- export * from './model/graph-model';
9
- export * from './model/units';
8
+ export * from './context/ChartsThemeProvider';
9
+ export * from './utils';
10
+ export * from './model';
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export*from"./EChart";export*from"./ErrorAlert";export*from"./ErrorBoundary";export*from"./GaugeChart";export*from"./LineChart";export*from"./StatChart";export*from"./utils/combine-sx";export*from"./model/graph-model";export*from"./model/units";
1
+ export*from"./EChart";export*from"./ErrorAlert";export*from"./ErrorBoundary";export*from"./InfoTooltip";export*from"./LineChart";export*from"./GaugeChart";export*from"./StatChart";export*from"./context/ChartsThemeProvider";export*from"./utils";export*from"./model";
@@ -2,6 +2,10 @@ import { LineSeriesOption } from 'echarts/charts';
2
2
  export declare const PROGRESSIVE_MODE_SERIES_LIMIT = 500;
3
3
  export declare type UnixTimeMs = number;
4
4
  export declare type GraphSeriesValueTuple = [timestamp: UnixTimeMs, value: number];
5
+ export interface GraphSeries {
6
+ name: string;
7
+ values: Iterable<GraphSeriesValueTuple>;
8
+ }
5
9
  export declare type EChartsValues = number | null | '-';
6
10
  export interface EChartsTimeSeries extends Omit<LineSeriesOption, 'data'> {
7
11
  data: Iterable<GraphSeriesValueTuple> | EChartsValues[];
@@ -9,7 +13,7 @@ export interface EChartsTimeSeries extends Omit<LineSeriesOption, 'data'> {
9
13
  export declare type EChartsDataFormat = {
10
14
  timeSeries: EChartsTimeSeries[];
11
15
  xAxis: number[];
12
- xAxisMax?: number | 'dataMax';
16
+ xAxisMax?: number | string;
13
17
  rangeMs?: number;
14
18
  };
15
- //# sourceMappingURL=graph-model.d.ts.map
19
+ //# sourceMappingURL=graph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/model/graph.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,eAAO,MAAM,6BAA6B,MAAM,CAAC;AAEjD,oBAAY,UAAU,GAAG,MAAM,CAAC;AAEhC,oBAAY,qBAAqB,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAE3E,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,QAAQ,CAAC,qBAAqB,CAAC,CAAC;CACzC;AAED,oBAAY,aAAa,GAAG,MAAM,GAAG,IAAI,GAAG,GAAG,CAAC;AAEhD,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAEvE,IAAI,EAAE,QAAQ,CAAC,qBAAqB,CAAC,GAAG,aAAa,EAAE,CAAC;CACzD;AAED,oBAAY,iBAAiB,GAAG;IAC9B,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC"}
File without changes
@@ -0,0 +1,4 @@
1
+ export * from './graph';
2
+ export * from './theme';
3
+ export * from './units';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
@@ -0,0 +1 @@
1
+ export*from"./graph";export*from"./theme";export*from"./units";
@@ -0,0 +1,16 @@
1
+ import type { EChartsOption, EChartsCoreOption, BarSeriesOption, LineSeriesOption, GaugeSeriesOption } from 'echarts';
2
+ export interface PersesChartsTheme {
3
+ themeName: string;
4
+ echartsTheme: EChartsTheme;
5
+ noDataOption: EChartsCoreOption;
6
+ sparkline: {
7
+ width: number;
8
+ color: string;
9
+ };
10
+ }
11
+ export interface EChartsTheme extends EChartsOption {
12
+ bar?: BarSeriesOption;
13
+ line?: LineSeriesOption;
14
+ gauge?: GaugeSeriesOption;
15
+ }
16
+ //# sourceMappingURL=theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/model/theme.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,eAAe,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEtH,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,EAAE,iBAAiB,CAAC;IAChC,SAAS,EAAE;QACT,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH;AAGD,MAAM,WAAW,YAAa,SAAQ,aAAa;IACjD,GAAG,CAAC,EAAE,eAAe,CAAC;IACtB,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,KAAK,CAAC,EAAE,iBAAiB,CAAC;CAC3B"}
@@ -0,0 +1 @@
1
+ export{};
@@ -1,25 +1,36 @@
1
- export declare type UnitOptions = TimeUnitOptions | PercentUnitOptions | DecimalUnitOptions;
1
+ export declare const DEFAULT_DECIMAL_PLACES = 2;
2
+ export declare type UnitOptions = TimeUnitOptions | PercentUnitOptions | DecimalUnitOptions | BytesUnitOptions;
2
3
  export declare function formatValue(value: number, unitOptions?: UnitOptions): string;
3
4
  declare const timeUnitKinds: readonly ["Milliseconds", "Seconds", "Minutes", "Hours", "Days", "Weeks", "Months", "Years"];
4
5
  declare type TimeUnitOptions = {
5
6
  kind: typeof timeUnitKinds[number];
6
7
  };
7
- declare const percentUnitKinds: readonly ["Percent", "PercentDecimal"];
8
+ declare const percentUnitKinds: readonly ["Percent", "PercentDecimal", "%"];
8
9
  declare type PercentUnitOptions = {
9
10
  kind: typeof percentUnitKinds[number];
10
- decimal_places: number;
11
+ decimal_places?: number;
11
12
  };
12
13
  declare const decimalUnitKinds: readonly ["Decimal"];
13
14
  declare type DecimalUnitOptions = {
14
15
  kind: typeof decimalUnitKinds[number];
15
- decimal_places: number;
16
- suffix?: 'string';
17
- unitDisplay?: 'short' | 'long' | 'narrow';
16
+ decimal_places?: number;
17
+ abbreviate?: boolean;
18
+ };
19
+ /**
20
+ * Takes large numbers and abbreviates them with the appropriate suffix
21
+ * 10123 -> 10.123k
22
+ * 1000000 -> 1M
23
+ */
24
+ export declare function abbreviateLargeNumber(num: number, decimals?: number): string;
25
+ /**
26
+ * Takes large numbers, rounds and abbreviates them with the appropriate suffix
27
+ * Add modifier to run on output value prior to unit being added (defaults to rounding)
28
+ */
29
+ export declare function formatNumber(num: number, modifier?: (n: number) => number): string;
30
+ declare const bytesUnitKinds: readonly ["Bytes"];
31
+ declare type BytesUnitOptions = {
32
+ kind: typeof bytesUnitKinds[number];
33
+ decimal_places?: number;
18
34
  };
19
- export declare function abbreviateLargeNumber(num: number): string | number;
20
- export declare function isSanctionedSimpleUnitIdentifier(unitIdentifier: string): boolean;
21
- export declare const SANCTIONED_UNITS: string[];
22
- export declare function removeUnitNamespace(unit: string): string;
23
- export declare const SIMPLE_UNITS: string[];
24
35
  export {};
25
36
  //# sourceMappingURL=units.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"units.d.ts","sourceRoot":"","sources":["../../src/model/units.ts"],"names":[],"mappings":"AAeA,oBAAY,WAAW,GAAG,eAAe,GAAG,kBAAkB,GAAG,kBAAkB,CAAC;AAEpF,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,MAAM,CAmB5E;AAED,QAAA,MAAM,aAAa,8FAA+F,CAAC;AAGnH,aAAK,eAAe,GAAG;IACrB,IAAI,EAAE,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC;CACpC,CAAC;AA0EF,QAAA,MAAM,gBAAgB,wCAAyC,CAAC;AAGhE,aAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACtC,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAcF,QAAA,MAAM,gBAAgB,sBAAuB,CAAC;AAG9C,aAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACtC,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,QAAQ,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;CAC3C,CAAC;AAkCF,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,mBAUhD;AAGD,wBAAgB,gCAAgC,CAAC,cAAc,EAAE,MAAM,WAEtE;AAGD,eAAO,MAAM,gBAAgB,UA4C5B,CAAC;AAGF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,UAE/C;AAED,eAAO,MAAM,YAAY,UAA4C,CAAC"}
1
+ {"version":3,"file":"units.d.ts","sourceRoot":"","sources":["../../src/model/units.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC,oBAAY,WAAW,GAAG,eAAe,GAAG,kBAAkB,GAAG,kBAAkB,GAAG,gBAAgB,CAAC;AAEvG,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,MAAM,CAwB5E;AAGD,QAAA,MAAM,aAAa,8FAA+F,CAAC;AAGnH,aAAK,eAAe,GAAG;IACrB,IAAI,EAAE,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC;CACpC,CAAC;AA2EF,QAAA,MAAM,gBAAgB,6CAA8C,CAAC;AAGrE,aAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACtC,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAiBF,QAAA,MAAM,gBAAgB,sBAAuB,CAAC;AAG9C,aAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACtC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAuBF;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,SAAI,UAG9D;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM,CAYlF;AAGD,QAAA,MAAM,cAAc,oBAAqB,CAAC;AAG1C,aAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC;IACpC,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC"}
@@ -1 +1 @@
1
- import{milliseconds}from"date-fns";export function formatValue(e,i){if(void 0===i)return e.toString();if(isTimeUnit(i))return formatTime(e,i);if(isPercentUnit(i))return formatPercent(e,i);if(isDecimalUnit(i))return formatDecimal(e,i);throw new Error(`Unknown unit options ${i}`)}const timeUnitKinds=["Milliseconds","Seconds","Minutes","Hours","Days","Weeks","Months","Years"],timeUnitKindsSet=new Set(timeUnitKinds);function isTimeUnit(e){return timeUnitKindsSet.has(e.kind)}function formatTime(e,i){const t={};switch(i.kind){case"Milliseconds":t.seconds=e/1e3;break;case"Seconds":t.seconds=e;break;case"Minutes":t.minutes=e;break;case"Hours":t.hours=e;break;case"Days":t.days=e;break;case"Weeks":t.weeks=e;break;case"Months":t.months=e;break;case"Years":t.years=e;break;default:const n=i.kind;throw new Error(`Unknown time unit type ${n}`)}const n=milliseconds(t),r=n/1e3;if(r<1)return`${n.toFixed()} milliseconds`;const a=r/60;if(a<1)return`${r.toFixed()} seconds`;const s=a/60;if(s<1)return`${a.toFixed()} minutes`;const o=s/24;if(o<1)return`${s.toFixed()} hours`;const c=o/7;if(c<1)return`${o.toFixed()} days`;const m=c/52;return m<1?`${c.toFixed()} weeks`:`${m.toFixed()} years`}const percentUnitKinds=["Percent","PercentDecimal"],percentUnitKindsSet=new Set(percentUnitKinds);function isPercentUnit(e){return percentUnitKindsSet.has(e.kind)}function formatPercent(e,i){return"PercentDecimal"===i.kind&&(e*=100),e.toFixed(i.decimal_places)+"%"}const decimalUnitKinds=["Decimal"],decimalUnitKindsSet=new Set(decimalUnitKinds);function isDecimalUnit(e){return decimalUnitKindsSet.has(e.kind)}function formatDecimal(e,i){var t,n;const r=null!==(t=i.decimal_places)&&void 0!==t?t:2;if(void 0!==i.suffix&&isSanctionedSimpleUnitIdentifier(i.suffix)){const t={style:"unit",minimumFractionDigits:0,maximumFractionDigits:r,useGrouping:!0,unit:i.suffix,unitDisplay:null!==(n=i.unitDisplay)&&void 0!==n?n:"narrow"};return new Intl.NumberFormat("en-US",t).format(e)}const a={style:"decimal",minimumFractionDigits:0,maximumFractionDigits:r,useGrouping:!0};return new Intl.NumberFormat("en-US",a).format(e)}export function abbreviateLargeNumber(e){return e>=1e12?e/1e12+"T":e>=1e9?e/1e9+"B":e>=1e6?e/1e6+"M":e>=1e3?e/1e3+"k":e}export function isSanctionedSimpleUnitIdentifier(e){return SIMPLE_UNITS.indexOf(e)>-1}export const SANCTIONED_UNITS=["angle-degree","area-acre","area-hectare","concentr-percent","digital-bit","digital-byte","digital-gigabit","digital-gigabyte","digital-kilobit","digital-kilobyte","digital-megabit","digital-megabyte","digital-petabyte","digital-terabit","digital-terabyte","duration-day","duration-hour","duration-millisecond","duration-minute","duration-month","duration-second","duration-week","duration-year","length-centimeter","length-foot","length-inch","length-kilometer","length-meter","length-mile-scandinavian","length-mile","length-millimeter","length-yard","mass-gram","mass-kilogram","mass-ounce","mass-pound","mass-stone","temperature-celsius","temperature-fahrenheit","volume-fluid-ounce","volume-gallon","volume-liter","volume-milliliter"];export function removeUnitNamespace(e){return e.slice(e.indexOf("-")+1)}export const SIMPLE_UNITS=SANCTIONED_UNITS.map(removeUnitNamespace);
1
+ import{milliseconds}from"date-fns";import{round}from"mathjs";export const DEFAULT_DECIMAL_PLACES=2;export function formatValue(e,t){var n;if(void 0===t)return e.toString();if(isDecimalUnit(t))return formatDecimal(e,t);if(isTimeUnit(t))return formatTime(e,t);if(isPercentUnit(t))return formatPercent(e,t);if(isBytesUnit(t))return formatBytes(e,null!==(n=t.decimal_places)&&void 0!==n?n:2);throw new Error(`Unknown unit options ${t}`)}const timeUnitKinds=["Milliseconds","Seconds","Minutes","Hours","Days","Weeks","Months","Years"],timeUnitKindsSet=new Set(timeUnitKinds);function isTimeUnit(e){return timeUnitKindsSet.has(e.kind)}function formatTime(e,t){const n={};switch(t.kind){case"Milliseconds":n.seconds=e/1e3;break;case"Seconds":n.seconds=e;break;case"Minutes":n.minutes=e;break;case"Hours":n.hours=e;break;case"Days":n.days=e;break;case"Weeks":n.weeks=e;break;case"Months":n.months=e;break;case"Years":n.years=e;break;default:const i=t.kind;throw new Error(`Unknown time unit type ${i}`)}const i=milliseconds(n),r=i/1e3;if(r<1)return`${i.toFixed()} milliseconds`;const s=r/60;if(s<1)return`${r.toFixed()} seconds`;const o=s/60;if(o<1)return`${s.toFixed()} minutes`;const a=o/24;if(a<1)return`${o.toFixed()} hours`;const c=a/7;if(c<1)return`${a.toFixed()} days`;const d=c/52;return d<1?`${c.toFixed()} weeks`:`${d.toFixed()} years`}const percentUnitKinds=["Percent","PercentDecimal","%"],percentUnitKindsSet=new Set(percentUnitKinds);function isPercentUnit(e){return percentUnitKindsSet.has(e.kind)}function formatPercent(e,t){var n;const i=null!==(n=t.decimal_places)&&void 0!==n?n:2;return"PercentDecimal"===t.kind&&(e*=100),e.toFixed(i)+"%"}const decimalUnitKinds=["Decimal"],decimalUnitKindsSet=new Set(decimalUnitKinds);function isDecimalUnit(e){return decimalUnitKindsSet.has(e.kind)}function formatDecimal(e,t){var n;const i=null!==(n=t.decimal_places)&&void 0!==n?n:2;if(!0===t.abbreviate)return abbreviateLargeNumber(e,i);const r={style:"decimal",minimumFractionDigits:0,maximumFractionDigits:i,useGrouping:!0};return new Intl.NumberFormat("en-US",r).format(e)}export function abbreviateLargeNumber(e,t=2){return formatNumber(e,(e=>round(e,t)))}export function formatNumber(e,t){const n=null!=t?t:Math.round;return e>=1e12?n(e/1e12)+"T":e>=1e9?n(e/1e9)+"B":e>=1e6?n(e/1e6)+"M":e>=1e3?n(e/1e3)+"K":e.toString()}const bytesUnitKinds=["Bytes"],bytesUnitKindsSet=new Set(bytesUnitKinds);function isBytesUnit(e){return bytesUnitKindsSet.has(e.kind)}function formatBytes(e,t=2){if(0===e)return"0 Bytes";const n=t<0?0:t,i=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,i)).toFixed(n))+" "+["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"][i]}
@@ -0,0 +1,2 @@
1
+ export * from './render';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAaA,cAAc,UAAU,CAAC"}
@@ -0,0 +1 @@
1
+ export*from"./render";
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import { RenderOptions } from '@testing-library/react';
3
+ /**
4
+ * Test helper to render a React component with some common app-level providers wrapped around it.
5
+ */
6
+ export declare function renderWithContext(ui: React.ReactElement, options?: Omit<RenderOptions, 'queries'>): import("@testing-library/react").RenderResult<typeof import("@testing-library/dom/types/queries"), HTMLElement, HTMLElement>;
7
+ //# sourceMappingURL=render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/test/render.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAU,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAK/D;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,KAAK,CAAC,YAAY,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,gIAEjG"}
@@ -0,0 +1 @@
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{render}from"@testing-library/react";import{QueryClient,QueryClientProvider}from"react-query";const queryClient=new QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1}}});export function renderWithContext(e,r){return render(_jsx(QueryClientProvider,{client:queryClient,children:e}),r)}
@@ -0,0 +1,2 @@
1
+ import '@testing-library/jest-dom/extend-expect';
2
+ //# sourceMappingURL=setup-tests.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-tests.d.ts","sourceRoot":"","sources":["../../src/test/setup-tests.ts"],"names":[],"mappings":"AAcA,OAAO,yCAAyC,CAAC"}
@@ -0,0 +1 @@
1
+ import"@testing-library/jest-dom/extend-expect";jest.mock("echarts/core");
@@ -0,0 +1,3 @@
1
+ export * from './combine-sx';
2
+ export * from './theme-gen';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAaA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
@@ -0,0 +1 @@
1
+ export*from"./combine-sx";export*from"./theme-gen";
@@ -0,0 +1,6 @@
1
+ import { Theme } from '@mui/material';
2
+ import { EChartsTheme, PersesChartsTheme } from '../model';
3
+ declare type MuiTheme = Omit<Theme, 'components'>;
4
+ export declare function generateChartsTheme(themeName: string, muiTheme: MuiTheme, echartsTheme: EChartsTheme): PersesChartsTheme;
5
+ export {};
6
+ //# sourceMappingURL=theme-gen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-gen.d.ts","sourceRoot":"","sources":["../../src/utils/theme-gen.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAK3D,aAAK,QAAQ,GAAG,IAAI,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;AAE1C,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,GACzB,iBAAiB,CA+JnB"}
@@ -0,0 +1 @@
1
+ import merge from"lodash/merge";const DEFAULT_TEXT_COLOR="#222";export function generateChartsTheme(e,t,o){var l,i,a,r,n,s;const h=null!==(i=null===(l=t.palette.text)||void 0===l?void 0:l.primary)&&void 0!==i?i:"#222",d={title:{show:!1},textStyle:{color:h,fontFamily:t.typography.fontFamily,fontSize:12},grid:{top:5,right:20,bottom:0,left:20,containLabel:!0},color:["#8dd3c7","#bebada","#fb8072","#80b1d3","#fdb462"],categoryAxis:{show:!0,axisLabel:{show:!0,color:h,margin:15},axisTick:{show:!1,length:6,lineStyle:{color:t.palette.grey[600]}},axisLine:{show:!0,lineStyle:{color:t.palette.grey[600]}},splitLine:{show:!0,lineStyle:{width:.5,color:t.palette.grey[300],opacity:.6}},splitArea:{show:!1,areaStyle:{color:[t.palette.grey[300]]}}},valueAxis:{show:!0,axisLabel:{color:h,margin:12},axisLine:{show:!1},splitLine:{show:!0,lineStyle:{width:.5,color:t.palette.grey[300],opacity:.6}}},legend:{orient:"horizontal",textStyle:{color:h},pageTextStyle:{color:t.palette.grey[600]},pageIconColor:null===(r=null===(a=null==t?void 0:t.palette)||void 0===a?void 0:a.action)||void 0===r?void 0:r.active,pageIconInactiveColor:null===(s=null===(n=null==t?void 0:t.palette)||void 0===n?void 0:n.action)||void 0===s?void 0:s.disabled},toolbox:{show:!0,top:10,right:10,iconStyle:{borderColor:h}},tooltip:{},line:{showSymbol:!1,symbol:"circle",symbolSize:4,smooth:!1,lineStyle:{width:1},emphasis:{lineStyle:{width:1.5}}},bar:{barMaxWidth:150,itemStyle:{borderWidth:0,borderColor:t.palette.grey[300]}},gauge:{detail:{fontSize:18,fontWeight:600,valueAnimation:!1},splitLine:{distance:0,length:4,lineStyle:{width:1}},splitNumber:12}};return{themeName:e,echartsTheme:merge(d,o),noDataOption:{title:{show:!0,textStyle:{color:h,fontSize:16,fontWeight:400},text:"No data",left:"center",top:"center"},xAxis:{show:!1},yAxis:{show:!1}},sparkline:{width:2,color:"#1976d2"}}}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=theme-gen.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-gen.test.d.ts","sourceRoot":"","sources":["../../src/utils/theme-gen.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ import{createTheme}from"@mui/material";import{generateChartsTheme}from"./theme-gen";describe("generateChartsTheme",(()=>{const n=createTheme({}),e=generateChartsTheme("perses",n,{legend:{textStyle:{color:"yellow"}},line:{showSymbol:!0,smooth:!0}});it("should return perses specific charts theme from converted MUI theme",(()=>{expect(e).toMatchInlineSnapshot('\n Object {\n "echartsTheme": Object {\n "bar": Object {\n "barMaxWidth": 150,\n "itemStyle": Object {\n "borderColor": "#e0e0e0",\n "borderWidth": 0,\n },\n },\n "categoryAxis": Object {\n "axisLabel": Object {\n "color": "rgba(0, 0, 0, 0.87)",\n "margin": 15,\n "show": true,\n },\n "axisLine": Object {\n "lineStyle": Object {\n "color": "#757575",\n },\n "show": true,\n },\n "axisTick": Object {\n "length": 6,\n "lineStyle": Object {\n "color": "#757575",\n },\n "show": false,\n },\n "show": true,\n "splitArea": Object {\n "areaStyle": Object {\n "color": Array [\n "#e0e0e0",\n ],\n },\n "show": false,\n },\n "splitLine": Object {\n "lineStyle": Object {\n "color": "#e0e0e0",\n "opacity": 0.6,\n "width": 0.5,\n },\n "show": true,\n },\n },\n "color": Array [\n "#8dd3c7",\n "#bebada",\n "#fb8072",\n "#80b1d3",\n "#fdb462",\n ],\n "gauge": Object {\n "detail": Object {\n "fontSize": 18,\n "fontWeight": 600,\n "valueAnimation": false,\n },\n "splitLine": Object {\n "distance": 0,\n "length": 4,\n "lineStyle": Object {\n "width": 1,\n },\n },\n "splitNumber": 12,\n },\n "grid": Object {\n "bottom": 0,\n "containLabel": true,\n "left": 20,\n "right": 20,\n "top": 5,\n },\n "legend": Object {\n "orient": "horizontal",\n "pageIconColor": "rgba(0, 0, 0, 0.54)",\n "pageIconInactiveColor": "rgba(0, 0, 0, 0.26)",\n "pageTextStyle": Object {\n "color": "#757575",\n },\n "textStyle": Object {\n "color": "yellow",\n },\n },\n "line": Object {\n "emphasis": Object {\n "lineStyle": Object {\n "width": 1.5,\n },\n },\n "lineStyle": Object {\n "width": 1,\n },\n "showSymbol": true,\n "smooth": true,\n "symbol": "circle",\n "symbolSize": 4,\n },\n "textStyle": Object {\n "color": "rgba(0, 0, 0, 0.87)",\n "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif",\n "fontSize": 12,\n },\n "title": Object {\n "show": false,\n },\n "toolbox": Object {\n "iconStyle": Object {\n "borderColor": "rgba(0, 0, 0, 0.87)",\n },\n "right": 10,\n "show": true,\n "top": 10,\n },\n "tooltip": Object {},\n "valueAxis": Object {\n "axisLabel": Object {\n "color": "rgba(0, 0, 0, 0.87)",\n "margin": 12,\n },\n "axisLine": Object {\n "show": false,\n },\n "show": true,\n "splitLine": Object {\n "lineStyle": Object {\n "color": "#e0e0e0",\n "opacity": 0.6,\n "width": 0.5,\n },\n "show": true,\n },\n },\n },\n "noDataOption": Object {\n "title": Object {\n "left": "center",\n "show": true,\n "text": "No data",\n "textStyle": Object {\n "color": "rgba(0, 0, 0, 0.87)",\n "fontSize": 16,\n "fontWeight": 400,\n },\n "top": "center",\n },\n "xAxis": Object {\n "show": false,\n },\n "yAxis": Object {\n "show": false,\n },\n },\n "sparkline": Object {\n "color": "#1976d2",\n "width": 2,\n },\n "themeName": "perses",\n }\n ')}))}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/components",
3
- "version": "0.4.2",
3
+ "version": "0.5.0",
4
4
  "description": "Common UI components used across Perses features",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/perses/perses/blob/main/README.md",
@@ -18,13 +18,14 @@
18
18
  "clean": "rimraf dist/",
19
19
  "build": "tsc --build",
20
20
  "build:cjs": "tsc --project ./tsconfig.cjs.json",
21
- "test": "echo 'no test to run' && exit 0",
21
+ "test": "TZ=UTC jest",
22
+ "test:watch": "TZ=UTC jest --watch",
22
23
  "lint": "eslint src --ext .ts,.tsx",
23
24
  "lint:fix": "eslint --fix src --ext .ts,.tsx"
24
25
  },
25
26
  "dependencies": {
26
- "@perses-dev/core": "^0.4.2",
27
- "echarts": "^5.3.2",
27
+ "@perses-dev/core": "^0.5.0",
28
+ "echarts": "^5.3.3",
28
29
  "lodash-es": "^4.17.21",
29
30
  "react-error-boundary": "^3.1.4"
30
31
  },
@@ -1 +0,0 @@
1
- {"version":3,"file":"GaugeChart.d.ts","sourceRoot":"","sources":["../src/GaugeChart.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAmC,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGpF,OAAO,EAAe,WAAW,EAAE,MAAM,eAAe,CAAC;AA0BzD,oBAAY,cAAc,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAEvD,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAC;CACzC;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,eA2IhD"}
@@ -1 +0,0 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{useMemo}from"react";import{use}from"echarts/core";import{GaugeChart as EChartsGaugeChart}from"echarts/charts";import{GridComponent,TitleComponent,TooltipComponent}from"echarts/components";import{CanvasRenderer}from"echarts/renderers";import{formatValue}from"./model/units";import{EChart}from"./EChart";use([EChartsGaugeChart,GridComponent,TitleComponent,TooltipComponent,CanvasRenderer]);const noDataOption={title:{show:!0,textStyle:{color:"grey",fontSize:16,fontWeight:400},text:"No data",left:"center",top:"center"},xAxis:{show:!1},yAxis:{show:!1},series:[]};export function GaugeChart(t){const{width:e,height:o,data:i,unit:r,axisLine:a}=t,s=useMemo((()=>null==i?noDataOption:{title:{show:!1},tooltip:{show:!1},series:[{type:"gauge",center:["50%","65%"],radius:"100%",startAngle:200,endAngle:-20,min:0,max:100,splitNumber:12,silent:!0,progress:{show:!0,width:22,itemStyle:{color:"auto"}},pointer:{show:!1},axisLine:{lineStyle:{color:[[1,"#e1e5e9"]],width:22}},axisTick:{show:!1,distance:-28,splitNumber:5,lineStyle:{width:2,color:"#999"}},splitLine:{show:!1,distance:-32,length:6,lineStyle:{width:2,color:"#999"}},axisLabel:{show:!1,distance:-18,color:"#999",fontSize:12},anchor:{show:!1},title:{show:!1},detail:{show:!1},data:[{value:i}]},{type:"gauge",center:["50%","65%"],radius:"114%",startAngle:200,endAngle:-20,min:0,max:100,pointer:{show:!1,itemStyle:{color:"auto"}},axisLine:a,axisTick:{show:!1},splitLine:{show:!1},axisLabel:{show:!1},detail:{show:!0,valueAnimation:!1,width:"60%",borderRadius:8,offsetCenter:[0,"-9%"],fontSize:20,fontWeight:"bolder",color:"inherit",formatter:t=>formatValue(t,{kind:r.kind,decimal_places:0})},data:[{value:i}]}]}),[i,r,a]);return _jsx(EChart,{sx:{width:e,height:o},option:s})}
@@ -1,22 +0,0 @@
1
- /// <reference types="react" />
2
- import type { GridComponentOption, LegendComponentOption, ToolboxComponentOption, VisualMapComponentOption } from 'echarts';
3
- import { EChartsDataFormat } from './model/graph-model';
4
- export interface ZoomEventData {
5
- start: number;
6
- end: number;
7
- startIndex: number;
8
- endIndex: number;
9
- }
10
- interface LineChartProps {
11
- height: number;
12
- data: EChartsDataFormat;
13
- grid?: GridComponentOption;
14
- legend?: LegendComponentOption;
15
- toolbox?: ToolboxComponentOption;
16
- visualMap?: VisualMapComponentOption[];
17
- dataZoomEnabled?: boolean;
18
- onDataZoom?: (e: ZoomEventData) => void;
19
- }
20
- export declare function LineChart({ height, data, grid, legend, toolbox, visualMap, dataZoomEnabled, onDataZoom, }: LineChartProps): JSX.Element;
21
- export {};
22
- //# sourceMappingURL=LineChart.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../src/LineChart.tsx"],"names":[],"mappings":";AAiBA,OAAO,KAAK,EAEV,mBAAmB,EAEnB,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAiBjB,OAAO,EAAiC,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAyCvF,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,cAAc;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,iBAAiB,CAAC;IACxB,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B,OAAO,CAAC,EAAE,sBAAsB,CAAC;IACjC,SAAS,CAAC,EAAE,wBAAwB,EAAE,CAAC;IACvC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;CACzC;AAED,wBAAgB,SAAS,CAAC,EACxB,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,OAAO,EACP,SAAS,EACT,eAAe,EACf,UAAU,GACX,EAAE,cAAc,eAwLhB"}
package/dist/LineChart.js DELETED
@@ -1 +0,0 @@
1
- import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useMemo,useRef,useState}from"react";import{useDeepMemo}from"@perses-dev/core";import{Box,useTheme}from"@mui/material";import merge from"lodash/merge";import{use}from"echarts/core";import{LineChart as EChartsLineChart}from"echarts/charts";import{GridComponent,DataZoomComponent,MarkAreaComponent,MarkLineComponent,MarkPointComponent,TitleComponent,ToolboxComponent,TooltipComponent,LegendComponent,VisualMapComponent}from"echarts/components";import{CanvasRenderer}from"echarts/renderers";import{EChart}from"./EChart";import{PROGRESSIVE_MODE_SERIES_LIMIT}from"./model/graph-model";import{abbreviateLargeNumber}from"./model/units";import{emptyTooltipData}from"./tooltip/tooltip-model";import{Tooltip}from"./tooltip/Tooltip";use([EChartsLineChart,GridComponent,DataZoomComponent,MarkAreaComponent,MarkLineComponent,MarkPointComponent,TitleComponent,ToolboxComponent,TooltipComponent,LegendComponent,VisualMapComponent,CanvasRenderer]);const noDataOption={title:{show:!0,textStyle:{color:"grey",fontSize:16,fontWeight:400},text:"No data",left:"center",top:"center"},xAxis:{show:!1},yAxis:{show:!1},series:[]};export function LineChart({height:e,data:t,grid:o,legend:r,toolbox:n,visualMap:a,dataZoomEnabled:i,onDataZoom:s}){const m=useTheme(),l=useRef(),[p,c]=useState(!0),u=useMemo((()=>({datazoom:e=>{var o,r;if(void 0===s||void 0===e.batch[0])return;const n=null!==(o=e.batch[0].startValue)&&void 0!==o?o:0,a=null!==(r=e.batch[0].endValue)&&void 0!==r?r:t.xAxis.length-1,i=t.xAxis[n],m=t.xAxis[a];void 0!==i&&void 0!==m&&s({start:i,end:m,startIndex:n,endIndex:a})}})),[t,s]);void 0!==l.current&&!0===i&&l.current.dispatchAction({type:"takeGlobalCursor",key:"dataZoomSelect",dataZoomSelectActive:!0});const d=useDeepMemo((()=>{var e;if(void 0===t.timeSeries)return{};if(null===t.timeSeries||0===t.timeSeries.length)return noDataOption;const s=t.timeSeries.length<PROGRESSIVE_MODE_SERIES_LIMIT,l={show:!0,top:10,right:10,iconStyle:{borderColor:m.palette.text.primary},feature:{dataZoom:{icon:i?null:void 0,yAxisIndex:"none"},restore:{}},emphasis:{iconStyle:{textFill:m.palette.text.primary}}};!1===i&&delete l.feature.dataZoom.icon;const p=null!==(e=t.rangeMs)&&void 0!==e?e:getDateRange(t.xAxis);return{title:{show:!1},grid:merge({top:10,right:20,bottom:5,left:20,containLabel:!0},o),toolbox:merge(l,n),series:t.timeSeries,xAxis:{type:"category",data:t.xAxis,max:t.xAxisMax,axisLabel:{margin:15,color:m.palette.text.primary,formatter:e=>getFormattedDate(e,p)},axisTick:{show:!1},axisLine:{lineStyle:{color:m.palette.grey[600]}}},yAxis:{type:"value",boundaryGap:[0,"10%"],axisLabel:{margin:12,color:m.palette.text.primary,formatter:e=>abbreviateLargeNumber(e)},splitLine:{show:!0,lineStyle:{width:.5,color:m.palette.grey[300],opacity:.95}}},animation:!1,tooltip:{show:s,trigger:"axis",showContent:!1,axisPointer:{type:"none"}},legend:r,visualMap:a}}),[t,m,o,r,n,i,a]);return _jsxs(Box,{sx:{height:e},onMouseDown:e=>{e.target instanceof HTMLCanvasElement&&c(!1)},onMouseUp:()=>{c(!0)},onMouseLeave:()=>{c(!1)},onMouseEnter:()=>{c(!0)},children:[!0===p&&_jsx(Tooltip,{chartRef:l,tooltipData:emptyTooltipData,chartData:t,wrapLabels:!0}),_jsx(EChart,{sx:{width:"100%",height:"100%"},option:d,onEvents:u,_instance:l})]})}function getDateRange(e){const t=36e5;if(0===e.length)return t;const o=e[e.length-1];return void 0===e[0]||void 0===o?t:o-e[0]}function getFormattedDate(e,t){const o={hour:"numeric",minute:"numeric",hourCycle:"h23"};return t<=18e5?o.second="numeric":t>=864e5&&(o.month="numeric",o.day="numeric"),new Intl.DateTimeFormat(void 0,o).format(e).replace(/, /g," ")}
@@ -1 +0,0 @@
1
- {"version":3,"file":"StatChart.d.ts","sourceRoot":"","sources":["../src/StatChart.tsx"],"names":[],"mappings":";AAmBA,OAAO,EAAiC,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGjF,OAAO,EAAe,WAAW,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAiC5D,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,QAAQ,CAAC,qBAAqB,CAAC,CAAC;CACzC;AAED,MAAM,WAAW,aAAa;IAC5B,eAAe,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC3C,UAAU,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,UAAU,cAAc;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,WAAW,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,gBAAgB,CAAC;CAC9B;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,eA+J9C"}
package/dist/StatChart.js DELETED
@@ -1 +0,0 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{useMemo}from"react";import{useTheme}from"@mui/material";import{merge}from"lodash-es";import{use}from"echarts/core";import{GaugeChart as EChartsGaugeChart}from"echarts/charts";import{LineChart as EChartsLineChart}from"echarts/charts";import{GridComponent,DatasetComponent,TitleComponent,TooltipComponent}from"echarts/components";import{CanvasRenderer}from"echarts/renderers";import{formatValue}from"./model/units";import{EChart}from"./EChart";use([EChartsGaugeChart,EChartsLineChart,GridComponent,DatasetComponent,TitleComponent,TooltipComponent,CanvasRenderer]);const noDataOption={title:{show:!0,textStyle:{color:"grey",fontSize:16,fontWeight:400},text:"No data",left:"center",top:"center"},xAxis:{show:!1},yAxis:{show:!1},series:[]};export function StatChart(t){const{width:e,height:o,data:a,unit:r,backgroundColor:i,sparkline:n}=t,s=useTheme(),h=useMemo((()=>{var t;if(void 0===a.seriesData)return{};if(null===a.seriesData||void 0===a.calculatedValue)return noDataOption;const h=a.seriesData,l=null!==(t=a.calculatedValue)&&void 0!==t?t:0,m=e>250,p=!0===m?a.name:"",u=Math.min(e,1.2*o),c=Math.min(u/4*.65,72),d=.5*c,f=[{type:"gauge",data:[{value:l,name:p}],detail:{show:!0,offsetCenter:["0%","-65%"],formatter:[`{name|${p}}`,`{value|${formatValue(l,r)}}`].join("\n"),rich:{name:{padding:!0===m?[0,0,5,0]:0,fontSize:d,lineHeight:2.5*d,fontWeight:500},value:{}}},center:["50%","60%"],animation:!1,silent:!0,title:{show:!1},progress:{show:!1},pointer:{show:!1},axisLine:{show:!1},axisTick:{show:!1},splitLine:{show:!1},axisLabel:{show:!1},anchor:{show:!1},zlevel:2}];if(void 0!==n){const t={type:"line",data:[...h.values],zlevel:1,symbol:"none",animation:!1,lineStyle:{color:"#FFFFFF",opacity:.6},areaStyle:{color:"#FFFFFF",opacity:.3},silent:!0},e=merge(t,n);f.push(e)}return{title:{show:!1},grid:[{show:!0,backgroundColor:i,top:0,right:0,bottom:0,left:0,containLabel:!1,borderWidth:0},{show:!1,top:"45%",right:0,bottom:0,left:0,containLabel:!1}],xAxis:{type:"time",show:!1,boundaryGap:!1,gridIndex:1},yAxis:{type:"value",show:!1,gridIndex:1},tooltip:{show:!1},series:f,textStyle:{color:"transparent"===i?s.palette.text.primary:"#FFFFFF",fontSize:25,lineHeight:18,fontFamily:'"Lato", sans-serif',fontWeight:"bold"},media:[{query:{maxWidth:150},option:{textStyle:{fontSize:12}}},{query:{minWidth:150},option:{textStyle:{fontSize:`max(14px, ${c}px)`,lineHeight:Math.min(16,1.2*c)}}}]}}),[a,o,s,r,e,n,i]);return _jsx(EChart,{sx:{width:e,height:o},option:h})}