@lobehub/charts 5.3.1 → 5.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/es/AccuracyBarChart/index.mdx +52 -0
- package/es/AreaChart/index.mdx +49 -0
- package/es/BarChart/index.mdx +73 -0
- package/es/BarList/index.mdx +34 -0
- package/es/BenchmarkColumnChart/index.d.ts +140 -0
- package/es/BenchmarkColumnChart/index.js +686 -0
- package/es/BenchmarkColumnChart/index.mdx +66 -0
- package/es/BenchmarkColumnChart/styles.d.ts +16 -0
- package/es/BenchmarkColumnChart/styles.js +23 -0
- package/es/BenchmarkRankingChart/index.d.ts +87 -0
- package/es/BenchmarkRankingChart/index.js +448 -0
- package/es/BenchmarkRankingChart/index.mdx +59 -0
- package/es/BenchmarkRankingChart/styles.d.ts +33 -0
- package/es/BenchmarkRankingChart/styles.js +41 -0
- package/es/ComposedChart/index.mdx +43 -0
- package/es/DataBars/index.mdx +36 -0
- package/es/DonutChart/index.mdx +48 -0
- package/es/FunnelChart/index.mdx +21 -0
- package/es/Heatmaps/index.mdx +70 -0
- package/es/Legend/index.mdx +13 -0
- package/es/LineChart/index.mdx +49 -0
- package/es/RadarChart/index.mdx +52 -0
- package/es/ScatterChart/index.mdx +49 -0
- package/es/SparkChart/index.mdx +29 -0
- package/es/Tracker/index.mdx +41 -0
- package/es/common/ChartTooltip/ChartTooltipFrame.js +1 -1
- package/es/common/ChartTooltip/ChartTooltipRow.js +3 -1
- package/es/common/ChartTooltip/index.js +2 -0
- package/es/common/benchmark/index.d.ts +2 -0
- package/es/common/benchmark/index.js +1 -0
- package/es/common/benchmark/types.d.ts +117 -0
- package/es/common/benchmark/types.js +1 -0
- package/es/common/benchmark/utils.d.ts +56 -0
- package/es/common/benchmark/utils.js +159 -0
- package/es/index.d.ts +3 -0
- package/es/index.js +2 -0
- package/package.json +1 -2
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import type { NoDataProps } from "../NoData";
|
|
3
|
+
import type { ValueFormatter } from "../../types/charts";
|
|
4
|
+
export interface BenchmarkRecord {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
color?: string;
|
|
7
|
+
error?: number;
|
|
8
|
+
highlighted?: boolean;
|
|
9
|
+
href?: string;
|
|
10
|
+
icon?: ReactNode;
|
|
11
|
+
key?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Secondary line-series value (e.g. Pass¹ overall rate)
|
|
14
|
+
*/
|
|
15
|
+
line?: number;
|
|
16
|
+
name?: ReactNode;
|
|
17
|
+
provider?: ReactNode;
|
|
18
|
+
rank?: number;
|
|
19
|
+
score?: number;
|
|
20
|
+
target?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Place item after a visual separator; line series does not connect into it
|
|
23
|
+
*/
|
|
24
|
+
unranked?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export type BenchmarkRenderIcon = (record: BenchmarkRecord, index: number) => ReactNode;
|
|
27
|
+
export type BenchmarkEventProps = (BenchmarkRecord & {
|
|
28
|
+
eventType: 'bar' | 'row';
|
|
29
|
+
value: number;
|
|
30
|
+
}) | null | undefined;
|
|
31
|
+
export interface BenchmarkFieldKeys {
|
|
32
|
+
/**
|
|
33
|
+
* Per-item bar color field
|
|
34
|
+
* @default 'color'
|
|
35
|
+
*/
|
|
36
|
+
colorKey?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Error / uncertainty field (AccuracyBar-style ± display)
|
|
39
|
+
* @default 'error'
|
|
40
|
+
*/
|
|
41
|
+
errorKey?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Icon field; value should be a ReactNode provided by the consumer
|
|
44
|
+
* @default 'icon'
|
|
45
|
+
*/
|
|
46
|
+
iconKey?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Model / entry name field
|
|
49
|
+
* @default 'name'
|
|
50
|
+
*/
|
|
51
|
+
index?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Secondary line-series field
|
|
54
|
+
* @default 'line'
|
|
55
|
+
*/
|
|
56
|
+
lineKey?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Provider / organization field
|
|
59
|
+
* @default 'provider'
|
|
60
|
+
*/
|
|
61
|
+
providerKey?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Numeric score field
|
|
64
|
+
* @default 'score'
|
|
65
|
+
*/
|
|
66
|
+
valueKey?: string;
|
|
67
|
+
}
|
|
68
|
+
export interface BenchmarkBaseProps extends BenchmarkFieldKeys, Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
69
|
+
/**
|
|
70
|
+
* Accuracy-style value formatter (e.g. `52.0%`). Falls back to `valueFormatter`.
|
|
71
|
+
*/
|
|
72
|
+
accuracyFormatter?: (value: number) => string;
|
|
73
|
+
data?: BenchmarkRecord[];
|
|
74
|
+
/**
|
|
75
|
+
* Formats the ± error segment
|
|
76
|
+
* @default (n) => n.toFixed(1)
|
|
77
|
+
*/
|
|
78
|
+
errorFormatter?: (value: number) => string;
|
|
79
|
+
height?: string | number;
|
|
80
|
+
/**
|
|
81
|
+
* Text accent color when an item has `highlighted: true` (does not change bar fill)
|
|
82
|
+
* @default theme.gold
|
|
83
|
+
*/
|
|
84
|
+
highlightColor?: string;
|
|
85
|
+
loading?: boolean;
|
|
86
|
+
noDataText?: NoDataProps['noDataText'];
|
|
87
|
+
onValueChange?: (value: BenchmarkEventProps) => void;
|
|
88
|
+
/**
|
|
89
|
+
* Optional icon renderer that overrides `iconKey`
|
|
90
|
+
*/
|
|
91
|
+
renderIcon?: BenchmarkRenderIcon;
|
|
92
|
+
showAnimation?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Show AccuracyBar-style ± error next to values / error bars
|
|
95
|
+
* @default true
|
|
96
|
+
*/
|
|
97
|
+
showError?: boolean;
|
|
98
|
+
sortOrder?: 'ascending' | 'descending' | 'none';
|
|
99
|
+
valueFormatter?: ValueFormatter;
|
|
100
|
+
width?: string | number;
|
|
101
|
+
}
|
|
102
|
+
export interface NormalizedBenchmarkItem {
|
|
103
|
+
color?: string;
|
|
104
|
+
error?: number;
|
|
105
|
+
highlighted?: boolean;
|
|
106
|
+
href?: string;
|
|
107
|
+
icon?: ReactNode;
|
|
108
|
+
key: string | number;
|
|
109
|
+
lineValue?: number;
|
|
110
|
+
name: ReactNode;
|
|
111
|
+
original: BenchmarkRecord;
|
|
112
|
+
provider?: ReactNode;
|
|
113
|
+
rank: number;
|
|
114
|
+
target?: string;
|
|
115
|
+
unranked?: boolean;
|
|
116
|
+
value: number;
|
|
117
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { BenchmarkFieldKeys, BenchmarkRecord, BenchmarkRenderIcon, NormalizedBenchmarkItem } from './types';
|
|
3
|
+
export declare const DEFAULT_BENCHMARK_KEYS: {
|
|
4
|
+
readonly colorKey: "color";
|
|
5
|
+
readonly errorKey: "error";
|
|
6
|
+
readonly iconKey: "icon";
|
|
7
|
+
readonly index: "name";
|
|
8
|
+
readonly lineKey: "line";
|
|
9
|
+
readonly providerKey: "provider";
|
|
10
|
+
readonly valueKey: "score";
|
|
11
|
+
};
|
|
12
|
+
export declare const resolveBenchmarkKeys: (keys?: BenchmarkFieldKeys) => {
|
|
13
|
+
colorKey: string;
|
|
14
|
+
errorKey: string;
|
|
15
|
+
iconKey: string;
|
|
16
|
+
index: string;
|
|
17
|
+
lineKey: string;
|
|
18
|
+
providerKey: string;
|
|
19
|
+
valueKey: string;
|
|
20
|
+
};
|
|
21
|
+
export declare const getBenchmarkIcon: (record: BenchmarkRecord, iconKey: string, renderIcon?: BenchmarkRenderIcon, index?: number) => import("react").ReactNode;
|
|
22
|
+
export declare const normalizeBenchmarkData: ({ colorKey, data, errorKey, iconKey, index, lineKey, providerKey, renderIcon, sortOrder, valueKey, }: BenchmarkFieldKeys & {
|
|
23
|
+
data: BenchmarkRecord[];
|
|
24
|
+
renderIcon?: BenchmarkRenderIcon | undefined;
|
|
25
|
+
sortOrder?: "none" | "ascending" | "descending" | undefined;
|
|
26
|
+
}) => NormalizedBenchmarkItem[];
|
|
27
|
+
export declare const getBenchmarkMaxValue: (items: NormalizedBenchmarkItem[], maxValue?: number) => number;
|
|
28
|
+
export declare const getBenchmarkBarPercent: (value: number, maxValue: number, minPercent?: number) => number;
|
|
29
|
+
export declare const defaultBenchmarkValueFormatter: (value: number) => string;
|
|
30
|
+
export declare const defaultBenchmarkAccuracyFormatter: (value: number) => string;
|
|
31
|
+
export declare const defaultBenchmarkErrorFormatter: (value: number) => string;
|
|
32
|
+
export declare const formatBenchmarkAccuracyDisplay: ({ accuracyFormatter, error, errorFormatter, showError, value, valueFormatter, }: {
|
|
33
|
+
accuracyFormatter?: ((value: number) => string) | undefined;
|
|
34
|
+
error?: number | undefined;
|
|
35
|
+
errorFormatter?: ((value: number) => string) | undefined;
|
|
36
|
+
showError?: boolean | undefined;
|
|
37
|
+
value: number;
|
|
38
|
+
valueFormatter?: ((value: number) => string) | undefined;
|
|
39
|
+
}) => {
|
|
40
|
+
errorText: undefined;
|
|
41
|
+
main: string;
|
|
42
|
+
text: string;
|
|
43
|
+
} | {
|
|
44
|
+
errorText: string;
|
|
45
|
+
main: string;
|
|
46
|
+
text: string;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Split a label into lines. Supports `\n` / `\r\n`.
|
|
50
|
+
*/
|
|
51
|
+
export declare const splitBenchmarkLabel: (label: unknown) => string[];
|
|
52
|
+
export declare const getBenchmarkLabelMetrics: (label: unknown) => {
|
|
53
|
+
lineCount: number;
|
|
54
|
+
lines: string[];
|
|
55
|
+
longestWidth: number;
|
|
56
|
+
};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
7
|
+
import { getTextWidth } from "../../utils/getMaxLabelLength";
|
|
8
|
+
export var DEFAULT_BENCHMARK_KEYS = {
|
|
9
|
+
colorKey: 'color',
|
|
10
|
+
errorKey: 'error',
|
|
11
|
+
iconKey: 'icon',
|
|
12
|
+
index: 'name',
|
|
13
|
+
lineKey: 'line',
|
|
14
|
+
providerKey: 'provider',
|
|
15
|
+
valueKey: 'score'
|
|
16
|
+
};
|
|
17
|
+
export var resolveBenchmarkKeys = function resolveBenchmarkKeys() {
|
|
18
|
+
var _keys$colorKey, _keys$errorKey, _keys$iconKey, _keys$index, _keys$lineKey, _keys$providerKey, _keys$valueKey;
|
|
19
|
+
var keys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
20
|
+
return {
|
|
21
|
+
colorKey: (_keys$colorKey = keys.colorKey) !== null && _keys$colorKey !== void 0 ? _keys$colorKey : DEFAULT_BENCHMARK_KEYS.colorKey,
|
|
22
|
+
errorKey: (_keys$errorKey = keys.errorKey) !== null && _keys$errorKey !== void 0 ? _keys$errorKey : DEFAULT_BENCHMARK_KEYS.errorKey,
|
|
23
|
+
iconKey: (_keys$iconKey = keys.iconKey) !== null && _keys$iconKey !== void 0 ? _keys$iconKey : DEFAULT_BENCHMARK_KEYS.iconKey,
|
|
24
|
+
index: (_keys$index = keys.index) !== null && _keys$index !== void 0 ? _keys$index : DEFAULT_BENCHMARK_KEYS.index,
|
|
25
|
+
lineKey: (_keys$lineKey = keys.lineKey) !== null && _keys$lineKey !== void 0 ? _keys$lineKey : DEFAULT_BENCHMARK_KEYS.lineKey,
|
|
26
|
+
providerKey: (_keys$providerKey = keys.providerKey) !== null && _keys$providerKey !== void 0 ? _keys$providerKey : DEFAULT_BENCHMARK_KEYS.providerKey,
|
|
27
|
+
valueKey: (_keys$valueKey = keys.valueKey) !== null && _keys$valueKey !== void 0 ? _keys$valueKey : DEFAULT_BENCHMARK_KEYS.valueKey
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export var getBenchmarkIcon = function getBenchmarkIcon(record, iconKey, renderIcon) {
|
|
31
|
+
var index = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
32
|
+
if (renderIcon) return renderIcon(record, index);
|
|
33
|
+
return record[iconKey];
|
|
34
|
+
};
|
|
35
|
+
export var normalizeBenchmarkData = function normalizeBenchmarkData(_ref) {
|
|
36
|
+
var colorKey = _ref.colorKey,
|
|
37
|
+
data = _ref.data,
|
|
38
|
+
errorKey = _ref.errorKey,
|
|
39
|
+
iconKey = _ref.iconKey,
|
|
40
|
+
index = _ref.index,
|
|
41
|
+
lineKey = _ref.lineKey,
|
|
42
|
+
providerKey = _ref.providerKey,
|
|
43
|
+
renderIcon = _ref.renderIcon,
|
|
44
|
+
_ref$sortOrder = _ref.sortOrder,
|
|
45
|
+
sortOrder = _ref$sortOrder === void 0 ? 'descending' : _ref$sortOrder,
|
|
46
|
+
valueKey = _ref.valueKey;
|
|
47
|
+
var keys = resolveBenchmarkKeys({
|
|
48
|
+
colorKey: colorKey,
|
|
49
|
+
errorKey: errorKey,
|
|
50
|
+
iconKey: iconKey,
|
|
51
|
+
index: index,
|
|
52
|
+
lineKey: lineKey,
|
|
53
|
+
providerKey: providerKey,
|
|
54
|
+
valueKey: valueKey
|
|
55
|
+
});
|
|
56
|
+
var sorted = sortOrder === 'none' ? _toConsumableArray(data) : _toConsumableArray(data).sort(function (a, b) {
|
|
57
|
+
var _a$keys$valueKey, _b$keys$valueKey;
|
|
58
|
+
var aUnranked = Boolean(a.unranked);
|
|
59
|
+
var bUnranked = Boolean(b.unranked);
|
|
60
|
+
if (aUnranked !== bUnranked) return aUnranked ? 1 : -1;
|
|
61
|
+
var aValue = Number((_a$keys$valueKey = a[keys.valueKey]) !== null && _a$keys$valueKey !== void 0 ? _a$keys$valueKey : 0);
|
|
62
|
+
var bValue = Number((_b$keys$valueKey = b[keys.valueKey]) !== null && _b$keys$valueKey !== void 0 ? _b$keys$valueKey : 0);
|
|
63
|
+
return sortOrder === 'ascending' ? aValue - bValue : bValue - aValue;
|
|
64
|
+
});
|
|
65
|
+
return sorted.map(function (record, idx) {
|
|
66
|
+
var _ref2, _record$keys$index, _record$keys$valueKey, _record$keys$lineKey, _record$keys$colorKey, _record$key, _record$keys$provider;
|
|
67
|
+
var name = (_ref2 = (_record$keys$index = record[keys.index]) !== null && _record$keys$index !== void 0 ? _record$keys$index : record.name) !== null && _ref2 !== void 0 ? _ref2 : '';
|
|
68
|
+
var value = Number((_record$keys$valueKey = record[keys.valueKey]) !== null && _record$keys$valueKey !== void 0 ? _record$keys$valueKey : 0);
|
|
69
|
+
var rank = typeof record.rank === 'number' ? record.rank : idx + 1;
|
|
70
|
+
var rawError = record[keys.errorKey];
|
|
71
|
+
var error = rawError === undefined || rawError === null || rawError === '' ? undefined : Number(rawError);
|
|
72
|
+
var rawLine = (_record$keys$lineKey = record[keys.lineKey]) !== null && _record$keys$lineKey !== void 0 ? _record$keys$lineKey : record.line;
|
|
73
|
+
var lineValue = rawLine === undefined || rawLine === null || rawLine === '' ? undefined : Number(rawLine);
|
|
74
|
+
return {
|
|
75
|
+
color: (_record$keys$colorKey = record[keys.colorKey]) !== null && _record$keys$colorKey !== void 0 ? _record$keys$colorKey : record.color,
|
|
76
|
+
error: Number.isFinite(error) ? error : undefined,
|
|
77
|
+
highlighted: Boolean(record.highlighted),
|
|
78
|
+
href: record.href,
|
|
79
|
+
icon: getBenchmarkIcon(record, keys.iconKey, renderIcon, idx),
|
|
80
|
+
key: (_record$key = record.key) !== null && _record$key !== void 0 ? _record$key : name === '' || name === undefined || name === null ? idx : String(name),
|
|
81
|
+
lineValue: Number.isFinite(lineValue) ? lineValue : undefined,
|
|
82
|
+
name: name,
|
|
83
|
+
original: record,
|
|
84
|
+
provider: (_record$keys$provider = record[keys.providerKey]) !== null && _record$keys$provider !== void 0 ? _record$keys$provider : record.provider,
|
|
85
|
+
rank: rank,
|
|
86
|
+
target: record.target,
|
|
87
|
+
unranked: Boolean(record.unranked),
|
|
88
|
+
value: value
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
export var getBenchmarkMaxValue = function getBenchmarkMaxValue(items, maxValue) {
|
|
93
|
+
if (typeof maxValue === 'number') return maxValue;
|
|
94
|
+
return Math.max.apply(Math, _toConsumableArray(items.flatMap(function (item) {
|
|
95
|
+
var _item$lineValue;
|
|
96
|
+
return [item.value, (_item$lineValue = item.lineValue) !== null && _item$lineValue !== void 0 ? _item$lineValue : 0];
|
|
97
|
+
})).concat([0]));
|
|
98
|
+
};
|
|
99
|
+
export var getBenchmarkBarPercent = function getBenchmarkBarPercent(value, maxValue) {
|
|
100
|
+
var minPercent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2;
|
|
101
|
+
if (maxValue <= 0 || value <= 0) return 0;
|
|
102
|
+
return Math.max(value / maxValue * 100, minPercent);
|
|
103
|
+
};
|
|
104
|
+
export var defaultBenchmarkValueFormatter = function defaultBenchmarkValueFormatter(value) {
|
|
105
|
+
if (Number.isInteger(value)) return String(value);
|
|
106
|
+
return value.toFixed(1);
|
|
107
|
+
};
|
|
108
|
+
export var defaultBenchmarkAccuracyFormatter = function defaultBenchmarkAccuracyFormatter(value) {
|
|
109
|
+
return "".concat(value.toFixed(1), "%");
|
|
110
|
+
};
|
|
111
|
+
export var defaultBenchmarkErrorFormatter = function defaultBenchmarkErrorFormatter(value) {
|
|
112
|
+
return value.toFixed(1);
|
|
113
|
+
};
|
|
114
|
+
export var formatBenchmarkAccuracyDisplay = function formatBenchmarkAccuracyDisplay(_ref3) {
|
|
115
|
+
var accuracyFormatter = _ref3.accuracyFormatter,
|
|
116
|
+
error = _ref3.error,
|
|
117
|
+
_ref3$errorFormatter = _ref3.errorFormatter,
|
|
118
|
+
errorFormatter = _ref3$errorFormatter === void 0 ? defaultBenchmarkErrorFormatter : _ref3$errorFormatter,
|
|
119
|
+
_ref3$showError = _ref3.showError,
|
|
120
|
+
showError = _ref3$showError === void 0 ? true : _ref3$showError,
|
|
121
|
+
value = _ref3.value,
|
|
122
|
+
_ref3$valueFormatter = _ref3.valueFormatter,
|
|
123
|
+
valueFormatter = _ref3$valueFormatter === void 0 ? defaultBenchmarkValueFormatter : _ref3$valueFormatter;
|
|
124
|
+
var formatValue = accuracyFormatter !== null && accuracyFormatter !== void 0 ? accuracyFormatter : valueFormatter;
|
|
125
|
+
var main = formatValue(value);
|
|
126
|
+
if (!showError || error === undefined || error === null || Number.isNaN(error)) {
|
|
127
|
+
return {
|
|
128
|
+
errorText: undefined,
|
|
129
|
+
main: main,
|
|
130
|
+
text: main
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
var errorText = errorFormatter(error);
|
|
134
|
+
return {
|
|
135
|
+
errorText: errorText,
|
|
136
|
+
main: main,
|
|
137
|
+
text: "".concat(main, " \xB1 ").concat(errorText)
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Split a label into lines. Supports `\n` / `\r\n`.
|
|
143
|
+
*/
|
|
144
|
+
export var splitBenchmarkLabel = function splitBenchmarkLabel(label) {
|
|
145
|
+
var text = String(label !== null && label !== void 0 ? label : '');
|
|
146
|
+
if (!text) return [''];
|
|
147
|
+
return text.split(/\r?\n/);
|
|
148
|
+
};
|
|
149
|
+
export var getBenchmarkLabelMetrics = function getBenchmarkLabelMetrics(label) {
|
|
150
|
+
var lines = splitBenchmarkLabel(label);
|
|
151
|
+
var longestWidth = lines.reduce(function (max, line) {
|
|
152
|
+
return Math.max(max, getTextWidth(line));
|
|
153
|
+
}, 0);
|
|
154
|
+
return {
|
|
155
|
+
lineCount: Math.max(lines.length, 1),
|
|
156
|
+
lines: lines,
|
|
157
|
+
longestWidth: longestWidth
|
|
158
|
+
};
|
|
159
|
+
};
|
package/es/index.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ export { default as AccuracyBarChart, type AccuracyBarChartProps } from './Accur
|
|
|
2
2
|
export { default as AreaChart, type AreaChartProps } from './AreaChart';
|
|
3
3
|
export { default as BarChart, type BarChartProps } from './BarChart';
|
|
4
4
|
export { type Bar, default as BarList, type BarListProps } from './BarList';
|
|
5
|
+
export { default as BenchmarkColumnChart, type BenchmarkColumnChartProps, } from './BenchmarkColumnChart';
|
|
6
|
+
export { default as BenchmarkRankingChart, type BenchmarkRankingChartProps, } from './BenchmarkRankingChart';
|
|
7
|
+
export type { BenchmarkEventProps, BenchmarkFieldKeys, BenchmarkRecord, BenchmarkRenderIcon, } from './common/benchmark';
|
|
5
8
|
export { default as ChartTooltip, type ChartTooltipProps } from './common/ChartTooltip';
|
|
6
9
|
export { default as ChartTooltipFrame } from './common/ChartTooltip/ChartTooltipFrame';
|
|
7
10
|
export { default as ChartTooltipRow } from './common/ChartTooltip/ChartTooltipRow';
|
package/es/index.js
CHANGED
|
@@ -2,6 +2,8 @@ export { default as AccuracyBarChart } from "./AccuracyBarChart";
|
|
|
2
2
|
export { default as AreaChart } from "./AreaChart";
|
|
3
3
|
export { default as BarChart } from "./BarChart";
|
|
4
4
|
export { default as BarList } from "./BarList";
|
|
5
|
+
export { default as BenchmarkColumnChart } from "./BenchmarkColumnChart";
|
|
6
|
+
export { default as BenchmarkRankingChart } from "./BenchmarkRankingChart";
|
|
5
7
|
export { default as ChartTooltip } from "./common/ChartTooltip";
|
|
6
8
|
export { default as ChartTooltipFrame } from "./common/ChartTooltip/ChartTooltipFrame";
|
|
7
9
|
export { default as ChartTooltipRow } from "./common/ChartTooltip/ChartTooltipRow";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/charts",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.0",
|
|
4
4
|
"description": "React modern charts components built on recharts",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lobehub",
|
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
"dayjs": "^1.11.21",
|
|
34
34
|
"fast-deep-equal": "^3.1.3",
|
|
35
35
|
"lucide-react": "^0.562.0",
|
|
36
|
-
"polished": "^4.3.1",
|
|
37
36
|
"recharts": "^2.15.4"
|
|
38
37
|
},
|
|
39
38
|
"peerDependencies": {
|