@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.
- package/README.md +18 -0
- package/dist/EChart.d.ts +4 -1
- package/dist/EChart.d.ts.map +1 -1
- package/dist/EChart.js +1 -1
- package/dist/{GaugeChart.d.ts → GaugeChart/GaugeChart.d.ts} +2 -1
- package/dist/GaugeChart/GaugeChart.d.ts.map +1 -0
- package/dist/GaugeChart/GaugeChart.js +1 -0
- package/dist/GaugeChart/index.d.ts +2 -0
- package/dist/GaugeChart/index.d.ts.map +1 -0
- package/dist/GaugeChart/index.js +1 -0
- package/dist/InfoTooltip/InfoTooltip.d.ts +17 -0
- package/dist/InfoTooltip/InfoTooltip.d.ts.map +1 -0
- package/dist/InfoTooltip/InfoTooltip.js +1 -0
- package/dist/InfoTooltip/InfoTooltip.test.d.ts +2 -0
- package/dist/InfoTooltip/InfoTooltip.test.d.ts.map +1 -0
- package/dist/InfoTooltip/InfoTooltip.test.js +1 -0
- package/dist/InfoTooltip/index.d.ts +2 -0
- package/dist/InfoTooltip/index.d.ts.map +1 -0
- package/dist/InfoTooltip/index.js +1 -0
- package/dist/LineChart/LineChart.d.ts +17 -0
- package/dist/LineChart/LineChart.d.ts.map +1 -0
- package/dist/LineChart/LineChart.js +1 -0
- package/dist/LineChart/index.d.ts +3 -0
- package/dist/LineChart/index.d.ts.map +1 -0
- package/dist/LineChart/index.js +1 -0
- package/dist/LineChart/utils.d.ts +12 -0
- package/dist/LineChart/utils.d.ts.map +1 -0
- package/dist/LineChart/utils.js +1 -0
- package/dist/{StatChart.d.ts → StatChart/StatChart.d.ts} +4 -9
- package/dist/StatChart/StatChart.d.ts.map +1 -0
- package/dist/StatChart/StatChart.js +1 -0
- package/dist/StatChart/StatChart.test.d.ts +2 -0
- package/dist/StatChart/StatChart.test.d.ts.map +1 -0
- package/dist/StatChart/StatChart.test.js +1 -0
- package/dist/StatChart/index.d.ts +2 -0
- package/dist/StatChart/index.d.ts.map +1 -0
- package/dist/StatChart/index.js +1 -0
- package/dist/{tooltip → Tooltip}/SeriesInfo.d.ts +0 -0
- package/dist/{tooltip → Tooltip}/SeriesInfo.d.ts.map +1 -1
- package/dist/{tooltip → Tooltip}/SeriesInfo.js +0 -0
- package/dist/{tooltip → Tooltip}/SeriesMarker.d.ts +0 -0
- package/dist/{tooltip → Tooltip}/SeriesMarker.d.ts.map +1 -1
- package/dist/{tooltip → Tooltip}/SeriesMarker.js +0 -0
- package/dist/{tooltip → Tooltip}/Tooltip.d.ts +1 -1
- package/dist/{tooltip → Tooltip}/Tooltip.d.ts.map +1 -1
- package/dist/{tooltip → Tooltip}/Tooltip.js +0 -0
- package/dist/{tooltip → Tooltip}/TooltipContent.d.ts +0 -0
- package/dist/{tooltip → Tooltip}/TooltipContent.d.ts.map +1 -1
- package/dist/{tooltip → Tooltip}/TooltipContent.js +0 -0
- package/dist/{tooltip → Tooltip}/focused-series.d.ts +1 -1
- package/dist/{tooltip → Tooltip}/focused-series.d.ts.map +1 -1
- package/dist/{tooltip → Tooltip}/focused-series.js +0 -0
- package/dist/Tooltip/focused-series.test.d.ts +2 -0
- package/dist/Tooltip/focused-series.test.d.ts.map +1 -0
- package/dist/Tooltip/focused-series.test.js +1 -0
- package/dist/Tooltip/index.d.ts +3 -0
- package/dist/Tooltip/index.d.ts.map +1 -0
- package/dist/Tooltip/index.js +1 -0
- package/dist/{tooltip → Tooltip}/tooltip-model.d.ts +0 -0
- package/dist/{tooltip → Tooltip}/tooltip-model.d.ts.map +1 -1
- package/dist/{tooltip → Tooltip}/tooltip-model.js +0 -0
- package/dist/cjs/EChart.js +3 -3
- package/dist/cjs/{GaugeChart.js → GaugeChart/GaugeChart.js} +12 -45
- package/dist/cjs/GaugeChart/index.js +29 -0
- package/dist/cjs/InfoTooltip/InfoTooltip.js +39 -0
- package/dist/cjs/InfoTooltip/InfoTooltip.test.js +33 -0
- package/dist/cjs/InfoTooltip/index.js +29 -0
- package/dist/cjs/LineChart/LineChart.js +154 -0
- package/dist/cjs/LineChart/index.js +29 -0
- package/dist/cjs/LineChart/utils.js +72 -0
- package/dist/cjs/StatChart/StatChart.js +104 -0
- package/dist/cjs/StatChart/StatChart.test.js +45 -0
- package/dist/cjs/StatChart/index.js +29 -0
- package/dist/cjs/{tooltip → Tooltip}/SeriesInfo.js +0 -0
- package/dist/cjs/{tooltip → Tooltip}/SeriesMarker.js +0 -0
- package/dist/cjs/{tooltip → Tooltip}/Tooltip.js +0 -0
- package/dist/cjs/{tooltip → Tooltip}/TooltipContent.js +0 -0
- package/dist/cjs/{tooltip → Tooltip}/focused-series.js +0 -0
- package/dist/cjs/Tooltip/focused-series.test.js +57 -0
- package/dist/cjs/Tooltip/index.js +30 -0
- package/dist/cjs/{tooltip → Tooltip}/tooltip-model.js +0 -0
- package/dist/cjs/context/ChartsThemeProvider.js +36 -0
- package/dist/cjs/index.js +5 -4
- package/dist/cjs/model/{graph-model.js → graph.js} +0 -0
- package/dist/cjs/model/index.js +31 -0
- package/dist/cjs/model/theme.js +14 -0
- package/dist/cjs/model/units.js +58 -85
- package/dist/cjs/test/index.js +29 -0
- package/dist/cjs/test/render.js +26 -0
- package/dist/cjs/test/setup-tests.js +18 -0
- package/dist/cjs/utils/index.js +30 -0
- package/dist/cjs/utils/theme-gen.js +180 -0
- package/dist/cjs/utils/theme-gen.test.js +196 -0
- package/dist/context/ChartsThemeProvider.d.ts +11 -0
- package/dist/context/ChartsThemeProvider.d.ts.map +1 -0
- package/dist/context/ChartsThemeProvider.js +1 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/model/{graph-model.d.ts → graph.d.ts} +6 -2
- package/dist/model/graph.d.ts.map +1 -0
- package/dist/model/{graph-model.js → graph.js} +0 -0
- package/dist/model/index.d.ts +4 -0
- package/dist/model/index.d.ts.map +1 -0
- package/dist/model/index.js +1 -0
- package/dist/model/theme.d.ts +16 -0
- package/dist/model/theme.d.ts.map +1 -0
- package/dist/model/theme.js +1 -0
- package/dist/model/units.d.ts +22 -11
- package/dist/model/units.d.ts.map +1 -1
- package/dist/model/units.js +1 -1
- package/dist/test/index.d.ts +2 -0
- package/dist/test/index.d.ts.map +1 -0
- package/dist/test/index.js +1 -0
- package/dist/test/render.d.ts +7 -0
- package/dist/test/render.d.ts.map +1 -0
- package/dist/test/render.js +1 -0
- package/dist/test/setup-tests.d.ts +2 -0
- package/dist/test/setup-tests.d.ts.map +1 -0
- package/dist/test/setup-tests.js +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/theme-gen.d.ts +6 -0
- package/dist/utils/theme-gen.d.ts.map +1 -0
- package/dist/utils/theme-gen.js +1 -0
- package/dist/utils/theme-gen.test.d.ts +2 -0
- package/dist/utils/theme-gen.test.d.ts.map +1 -0
- package/dist/utils/theme-gen.test.js +1 -0
- package/package.json +5 -4
- package/dist/GaugeChart.d.ts.map +0 -1
- package/dist/GaugeChart.js +0 -1
- package/dist/LineChart.d.ts +0 -22
- package/dist/LineChart.d.ts.map +0 -1
- package/dist/LineChart.js +0 -1
- package/dist/StatChart.d.ts.map +0 -1
- package/dist/StatChart.js +0 -1
- package/dist/cjs/LineChart.js +0 -252
- package/dist/cjs/StatChart.js +0 -207
- package/dist/model/graph-model.d.ts.map +0 -1
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
17
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
18
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
19
|
+
}
|
|
20
|
+
Object.defineProperty(o, k2, desc);
|
|
21
|
+
}) : (function(o, m, k, k2) {
|
|
22
|
+
if (k2 === undefined) k2 = k;
|
|
23
|
+
o[k2] = m[k];
|
|
24
|
+
}));
|
|
25
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
26
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
__exportStar(require("./graph"), exports);
|
|
30
|
+
__exportStar(require("./theme"), exports);
|
|
31
|
+
__exportStar(require("./units"), exports);
|
|
@@ -0,0 +1,14 @@
|
|
|
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 });
|
package/dist/cjs/model/units.js
CHANGED
|
@@ -12,25 +12,33 @@
|
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
15
|
+
exports.formatNumber = exports.abbreviateLargeNumber = exports.formatValue = exports.DEFAULT_DECIMAL_PLACES = void 0;
|
|
16
16
|
const date_fns_1 = require("date-fns");
|
|
17
|
+
const mathjs_1 = require("mathjs");
|
|
18
|
+
exports.DEFAULT_DECIMAL_PLACES = 2;
|
|
17
19
|
function formatValue(value, unitOptions) {
|
|
20
|
+
var _a;
|
|
18
21
|
if (unitOptions === undefined) {
|
|
19
22
|
return value.toString();
|
|
20
23
|
}
|
|
24
|
+
if (isDecimalUnit(unitOptions)) {
|
|
25
|
+
return formatDecimal(value, unitOptions);
|
|
26
|
+
}
|
|
21
27
|
if (isTimeUnit(unitOptions)) {
|
|
22
28
|
return formatTime(value, unitOptions);
|
|
23
29
|
}
|
|
24
30
|
if (isPercentUnit(unitOptions)) {
|
|
25
31
|
return formatPercent(value, unitOptions);
|
|
26
32
|
}
|
|
27
|
-
if (
|
|
28
|
-
|
|
33
|
+
if (isBytesUnit(unitOptions)) {
|
|
34
|
+
const decimals = (_a = unitOptions.decimal_places) !== null && _a !== void 0 ? _a : exports.DEFAULT_DECIMAL_PLACES;
|
|
35
|
+
return formatBytes(value, decimals);
|
|
29
36
|
}
|
|
30
37
|
const exhaustive = unitOptions;
|
|
31
38
|
throw new Error(`Unknown unit options ${exhaustive}`);
|
|
32
39
|
}
|
|
33
40
|
exports.formatValue = formatValue;
|
|
41
|
+
/* Time Unit Conversion */
|
|
34
42
|
const timeUnitKinds = ['Milliseconds', 'Seconds', 'Minutes', 'Hours', 'Days', 'Weeks', 'Months', 'Years'];
|
|
35
43
|
const timeUnitKindsSet = new Set(timeUnitKinds);
|
|
36
44
|
function isTimeUnit(unitOptions) {
|
|
@@ -96,116 +104,81 @@ function formatTime(value, unitOptions) {
|
|
|
96
104
|
}
|
|
97
105
|
return `${years.toFixed()} years`;
|
|
98
106
|
}
|
|
99
|
-
|
|
107
|
+
/* Percent Unit Conversion */
|
|
108
|
+
const percentUnitKinds = ['Percent', 'PercentDecimal', '%'];
|
|
100
109
|
const percentUnitKindsSet = new Set(percentUnitKinds);
|
|
101
110
|
function isPercentUnit(unitOptions) {
|
|
102
111
|
return percentUnitKindsSet.has(unitOptions.kind);
|
|
103
112
|
}
|
|
104
113
|
function formatPercent(value, unitOptions) {
|
|
114
|
+
var _a;
|
|
115
|
+
const decimals = (_a = unitOptions.decimal_places) !== null && _a !== void 0 ? _a : exports.DEFAULT_DECIMAL_PLACES;
|
|
105
116
|
if (unitOptions.kind === 'PercentDecimal') {
|
|
106
117
|
value = value * 100;
|
|
107
118
|
}
|
|
108
|
-
return value.toFixed(
|
|
119
|
+
return value.toFixed(decimals) + '%';
|
|
109
120
|
}
|
|
121
|
+
/* Decimal Unit Conversion */
|
|
110
122
|
const decimalUnitKinds = ['Decimal'];
|
|
111
123
|
const decimalUnitKindsSet = new Set(decimalUnitKinds);
|
|
112
124
|
function isDecimalUnit(unitOptions) {
|
|
113
125
|
return decimalUnitKindsSet.has(unitOptions.kind);
|
|
114
126
|
}
|
|
115
127
|
function formatDecimal(value, unitOptions) {
|
|
116
|
-
var _a
|
|
117
|
-
const
|
|
118
|
-
if (unitOptions.
|
|
119
|
-
|
|
120
|
-
const formatParams = {
|
|
121
|
-
style: 'unit',
|
|
122
|
-
minimumFractionDigits: 0,
|
|
123
|
-
maximumFractionDigits: maximumFractionDigits,
|
|
124
|
-
useGrouping: true,
|
|
125
|
-
unit: unitOptions.suffix,
|
|
126
|
-
unitDisplay: (_b = unitOptions.unitDisplay) !== null && _b !== void 0 ? _b : 'narrow',
|
|
127
|
-
};
|
|
128
|
-
const unitFormatter = new Intl.NumberFormat('en-US', formatParams);
|
|
129
|
-
return unitFormatter.format(value);
|
|
130
|
-
}
|
|
128
|
+
var _a;
|
|
129
|
+
const decimals = (_a = unitOptions.decimal_places) !== null && _a !== void 0 ? _a : exports.DEFAULT_DECIMAL_PLACES;
|
|
130
|
+
if (unitOptions.abbreviate === true) {
|
|
131
|
+
return abbreviateLargeNumber(value, decimals);
|
|
131
132
|
}
|
|
132
133
|
const formatParams = {
|
|
133
134
|
style: 'decimal',
|
|
134
135
|
minimumFractionDigits: 0,
|
|
135
|
-
maximumFractionDigits:
|
|
136
|
+
maximumFractionDigits: decimals,
|
|
136
137
|
useGrouping: true,
|
|
137
138
|
};
|
|
138
139
|
const decimalFormatter = new Intl.NumberFormat('en-US', formatParams);
|
|
139
140
|
return decimalFormatter.format(value);
|
|
140
141
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
/**
|
|
143
|
+
* Takes large numbers and abbreviates them with the appropriate suffix
|
|
144
|
+
* 10123 -> 10.123k
|
|
145
|
+
* 1000000 -> 1M
|
|
146
|
+
*/
|
|
147
|
+
function abbreviateLargeNumber(num, decimals = 2) {
|
|
148
|
+
const modifier = (n) => (0, mathjs_1.round)(n, decimals);
|
|
149
|
+
return formatNumber(num, modifier);
|
|
150
|
+
}
|
|
151
|
+
exports.abbreviateLargeNumber = abbreviateLargeNumber;
|
|
152
|
+
/**
|
|
153
|
+
* Takes large numbers, rounds and abbreviates them with the appropriate suffix
|
|
154
|
+
* Add modifier to run on output value prior to unit being added (defaults to rounding)
|
|
155
|
+
*/
|
|
156
|
+
function formatNumber(num, modifier) {
|
|
157
|
+
const fn = modifier !== null && modifier !== void 0 ? modifier : Math.round;
|
|
144
158
|
return num >= 1e12
|
|
145
|
-
? num / 1e12 + 'T'
|
|
159
|
+
? fn(num / 1e12) + 'T'
|
|
146
160
|
: num >= 1e9
|
|
147
|
-
? num / 1e9 + 'B'
|
|
161
|
+
? fn(num / 1e9) + 'B'
|
|
148
162
|
: num >= 1e6
|
|
149
|
-
? num / 1e6 + 'M'
|
|
163
|
+
? fn(num / 1e6) + 'M'
|
|
150
164
|
: num >= 1e3
|
|
151
|
-
? num / 1e3 + '
|
|
152
|
-
: num;
|
|
165
|
+
? fn(num / 1e3) + 'K'
|
|
166
|
+
: num.toString();
|
|
153
167
|
}
|
|
154
|
-
exports.
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
168
|
+
exports.formatNumber = formatNumber;
|
|
169
|
+
/* Bytes Unit Conversion */
|
|
170
|
+
const bytesUnitKinds = ['Bytes'];
|
|
171
|
+
const bytesUnitKindsSet = new Set(bytesUnitKinds);
|
|
172
|
+
function isBytesUnit(unitOptions) {
|
|
173
|
+
return bytesUnitKindsSet.has(unitOptions.kind);
|
|
158
174
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
'
|
|
166
|
-
|
|
167
|
-
'
|
|
168
|
-
'digital-gigabit',
|
|
169
|
-
'digital-gigabyte',
|
|
170
|
-
'digital-kilobit',
|
|
171
|
-
'digital-kilobyte',
|
|
172
|
-
'digital-megabit',
|
|
173
|
-
'digital-megabyte',
|
|
174
|
-
'digital-petabyte',
|
|
175
|
-
'digital-terabit',
|
|
176
|
-
'digital-terabyte',
|
|
177
|
-
'duration-day',
|
|
178
|
-
'duration-hour',
|
|
179
|
-
'duration-millisecond',
|
|
180
|
-
'duration-minute',
|
|
181
|
-
'duration-month',
|
|
182
|
-
'duration-second',
|
|
183
|
-
'duration-week',
|
|
184
|
-
'duration-year',
|
|
185
|
-
'length-centimeter',
|
|
186
|
-
'length-foot',
|
|
187
|
-
'length-inch',
|
|
188
|
-
'length-kilometer',
|
|
189
|
-
'length-meter',
|
|
190
|
-
'length-mile-scandinavian',
|
|
191
|
-
'length-mile',
|
|
192
|
-
'length-millimeter',
|
|
193
|
-
'length-yard',
|
|
194
|
-
'mass-gram',
|
|
195
|
-
'mass-kilogram',
|
|
196
|
-
'mass-ounce',
|
|
197
|
-
'mass-pound',
|
|
198
|
-
'mass-stone',
|
|
199
|
-
'temperature-celsius',
|
|
200
|
-
'temperature-fahrenheit',
|
|
201
|
-
'volume-fluid-ounce',
|
|
202
|
-
'volume-gallon',
|
|
203
|
-
'volume-liter',
|
|
204
|
-
'volume-milliliter',
|
|
205
|
-
];
|
|
206
|
-
// removes the namespace prefix, ex: duration-hour -> hour
|
|
207
|
-
function removeUnitNamespace(unit) {
|
|
208
|
-
return unit.slice(unit.indexOf('-') + 1);
|
|
175
|
+
// https://stackoverflow.com/questions/15900485/correct-way-to-convert-size-in-bytes-to-kb-mb-gb-in-javascript/18650828#18650828
|
|
176
|
+
function formatBytes(bytes, decimals = 2) {
|
|
177
|
+
if (bytes === 0)
|
|
178
|
+
return '0 Bytes';
|
|
179
|
+
const k = 1024;
|
|
180
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
181
|
+
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
182
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
183
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
|
|
209
184
|
}
|
|
210
|
-
exports.removeUnitNamespace = removeUnitNamespace;
|
|
211
|
-
exports.SIMPLE_UNITS = exports.SANCTIONED_UNITS.map(removeUnitNamespace);
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
17
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
18
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
19
|
+
}
|
|
20
|
+
Object.defineProperty(o, k2, desc);
|
|
21
|
+
}) : (function(o, m, k, k2) {
|
|
22
|
+
if (k2 === undefined) k2 = k;
|
|
23
|
+
o[k2] = m[k];
|
|
24
|
+
}));
|
|
25
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
26
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
__exportStar(require("./render"), exports);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderWithContext = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
// Copyright 2022 The Perses Authors
|
|
6
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
// you may not use this file except in compliance with the License.
|
|
8
|
+
// You may obtain a copy of the License at
|
|
9
|
+
//
|
|
10
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
//
|
|
12
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
// See the License for the specific language governing permissions and
|
|
16
|
+
// limitations under the License.
|
|
17
|
+
const react_1 = require("@testing-library/react");
|
|
18
|
+
const react_query_1 = require("react-query");
|
|
19
|
+
const queryClient = new react_query_1.QueryClient({ defaultOptions: { queries: { refetchOnWindowFocus: false } } });
|
|
20
|
+
/**
|
|
21
|
+
* Test helper to render a React component with some common app-level providers wrapped around it.
|
|
22
|
+
*/
|
|
23
|
+
function renderWithContext(ui, options) {
|
|
24
|
+
return (0, react_1.render)((0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: ui }), options);
|
|
25
|
+
}
|
|
26
|
+
exports.renderWithContext = renderWithContext;
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
// Add testing library assertions
|
|
16
|
+
require("@testing-library/jest-dom/extend-expect");
|
|
17
|
+
// Always mock e-charts during tests since we don't have a proper canvas in jsdom
|
|
18
|
+
jest.mock('echarts/core');
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
17
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
18
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
19
|
+
}
|
|
20
|
+
Object.defineProperty(o, k2, desc);
|
|
21
|
+
}) : (function(o, m, k, k2) {
|
|
22
|
+
if (k2 === undefined) k2 = k;
|
|
23
|
+
o[k2] = m[k];
|
|
24
|
+
}));
|
|
25
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
26
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
__exportStar(require("./combine-sx"), exports);
|
|
30
|
+
__exportStar(require("./theme-gen"), exports);
|
|
@@ -0,0 +1,180 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.generateChartsTheme = void 0;
|
|
19
|
+
const merge_1 = __importDefault(require("lodash/merge"));
|
|
20
|
+
const DEFAULT_TEXT_COLOR = '#222';
|
|
21
|
+
function generateChartsTheme(themeName, muiTheme, echartsTheme) {
|
|
22
|
+
var _a, _b, _c, _d, _e, _f;
|
|
23
|
+
const primaryTextColor = (_b = (_a = muiTheme.palette.text) === null || _a === void 0 ? void 0 : _a.primary) !== null && _b !== void 0 ? _b : DEFAULT_TEXT_COLOR;
|
|
24
|
+
const muiConvertedTheme = {
|
|
25
|
+
title: {
|
|
26
|
+
show: false,
|
|
27
|
+
},
|
|
28
|
+
textStyle: {
|
|
29
|
+
color: primaryTextColor,
|
|
30
|
+
fontFamily: muiTheme.typography.fontFamily,
|
|
31
|
+
fontSize: 12,
|
|
32
|
+
},
|
|
33
|
+
grid: {
|
|
34
|
+
top: 5,
|
|
35
|
+
right: 20,
|
|
36
|
+
bottom: 0,
|
|
37
|
+
left: 20,
|
|
38
|
+
containLabel: true,
|
|
39
|
+
},
|
|
40
|
+
color: ['#8dd3c7', '#bebada', '#fb8072', '#80b1d3', '#fdb462'],
|
|
41
|
+
categoryAxis: {
|
|
42
|
+
show: true,
|
|
43
|
+
axisLabel: {
|
|
44
|
+
show: true,
|
|
45
|
+
color: primaryTextColor,
|
|
46
|
+
margin: 15,
|
|
47
|
+
},
|
|
48
|
+
axisTick: {
|
|
49
|
+
show: false,
|
|
50
|
+
length: 6,
|
|
51
|
+
lineStyle: {
|
|
52
|
+
color: muiTheme.palette.grey[600],
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
axisLine: {
|
|
56
|
+
show: true,
|
|
57
|
+
lineStyle: {
|
|
58
|
+
color: muiTheme.palette.grey[600],
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
splitLine: {
|
|
62
|
+
show: true,
|
|
63
|
+
lineStyle: {
|
|
64
|
+
width: 0.5,
|
|
65
|
+
color: muiTheme.palette.grey[300],
|
|
66
|
+
opacity: 0.6,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
splitArea: {
|
|
70
|
+
show: false,
|
|
71
|
+
areaStyle: {
|
|
72
|
+
color: [muiTheme.palette.grey[300]],
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
valueAxis: {
|
|
77
|
+
show: true,
|
|
78
|
+
axisLabel: {
|
|
79
|
+
color: primaryTextColor,
|
|
80
|
+
margin: 12,
|
|
81
|
+
},
|
|
82
|
+
axisLine: {
|
|
83
|
+
show: false,
|
|
84
|
+
},
|
|
85
|
+
splitLine: {
|
|
86
|
+
show: true,
|
|
87
|
+
lineStyle: {
|
|
88
|
+
width: 0.5,
|
|
89
|
+
color: muiTheme.palette.grey[300],
|
|
90
|
+
opacity: 0.6,
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
legend: {
|
|
95
|
+
orient: 'horizontal',
|
|
96
|
+
textStyle: {
|
|
97
|
+
color: primaryTextColor,
|
|
98
|
+
},
|
|
99
|
+
pageTextStyle: {
|
|
100
|
+
color: muiTheme.palette.grey[600],
|
|
101
|
+
},
|
|
102
|
+
pageIconColor: (_d = (_c = muiTheme === null || muiTheme === void 0 ? void 0 : muiTheme.palette) === null || _c === void 0 ? void 0 : _c.action) === null || _d === void 0 ? void 0 : _d.active,
|
|
103
|
+
pageIconInactiveColor: (_f = (_e = muiTheme === null || muiTheme === void 0 ? void 0 : muiTheme.palette) === null || _e === void 0 ? void 0 : _e.action) === null || _f === void 0 ? void 0 : _f.disabled,
|
|
104
|
+
},
|
|
105
|
+
toolbox: {
|
|
106
|
+
show: true,
|
|
107
|
+
top: 10,
|
|
108
|
+
right: 10,
|
|
109
|
+
iconStyle: {
|
|
110
|
+
borderColor: primaryTextColor,
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
tooltip: {},
|
|
114
|
+
line: {
|
|
115
|
+
showSymbol: false,
|
|
116
|
+
symbol: 'circle',
|
|
117
|
+
symbolSize: 4,
|
|
118
|
+
smooth: false,
|
|
119
|
+
lineStyle: {
|
|
120
|
+
width: 1,
|
|
121
|
+
},
|
|
122
|
+
emphasis: {
|
|
123
|
+
lineStyle: {
|
|
124
|
+
width: 1.5,
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
bar: {
|
|
129
|
+
barMaxWidth: 150,
|
|
130
|
+
itemStyle: {
|
|
131
|
+
borderWidth: 0,
|
|
132
|
+
borderColor: muiTheme.palette.grey[300],
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
gauge: {
|
|
136
|
+
detail: {
|
|
137
|
+
fontSize: 18,
|
|
138
|
+
fontWeight: 600,
|
|
139
|
+
valueAnimation: false,
|
|
140
|
+
},
|
|
141
|
+
splitLine: {
|
|
142
|
+
distance: 0,
|
|
143
|
+
length: 4,
|
|
144
|
+
lineStyle: {
|
|
145
|
+
width: 1,
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
splitNumber: 12,
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
return {
|
|
152
|
+
themeName,
|
|
153
|
+
echartsTheme: (0, merge_1.default)(muiConvertedTheme, echartsTheme),
|
|
154
|
+
noDataOption: {
|
|
155
|
+
title: {
|
|
156
|
+
show: true,
|
|
157
|
+
textStyle: {
|
|
158
|
+
color: primaryTextColor,
|
|
159
|
+
fontSize: 16,
|
|
160
|
+
fontWeight: 400,
|
|
161
|
+
},
|
|
162
|
+
text: 'No data',
|
|
163
|
+
left: 'center',
|
|
164
|
+
top: 'center',
|
|
165
|
+
},
|
|
166
|
+
xAxis: {
|
|
167
|
+
show: false,
|
|
168
|
+
},
|
|
169
|
+
yAxis: {
|
|
170
|
+
show: false,
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
sparkline: {
|
|
174
|
+
width: 2,
|
|
175
|
+
color: '#1976d2',
|
|
176
|
+
},
|
|
177
|
+
// TODO: add thresholdColors to theme
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
exports.generateChartsTheme = generateChartsTheme;
|