@classic-homes/charts-core 0.1.1
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/dist/chunk-ZRG25JNX.js +277 -0
- package/dist/index.cjs +425 -0
- package/dist/index.d.cts +67 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.js +133 -0
- package/dist/theme/index.cjs +284 -0
- package/dist/theme/index.d.cts +143 -0
- package/dist/theme/index.d.ts +143 -0
- package/dist/theme/index.js +1 -0
- package/dist/types/index.cjs +2 -0
- package/dist/types/index.d.cts +488 -0
- package/dist/types/index.d.ts +488 -0
- package/dist/types/index.js +1 -0
- package/package.json +49 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export { EChartsTheme, THEME_DARK, THEME_LIGHT, darkTheme, generateDarkTheme, generateLightTheme, lightTheme } from './theme/index.cjs';
|
|
2
|
+
import { LineChartData, BarChartData, PieSliceData, ScatterChartData } from './types/index.cjs';
|
|
3
|
+
export { AreaChartData, AreaChartProps, AreaSeriesData, BarChartProps, BarSeriesData, BaseChartProps, CandlestickChartProps, CandlestickData, CandlestickEventParams, CandlestickItem, DataPointEventParams, DonutChartProps, FunnelChartProps, FunnelSliceData, GaugeChartProps, HeatmapChartProps, HeatmapData, HeatmapEventParams, LineChartProps, LineSeriesData, PieChartProps, RadarChartData, RadarChartProps, RadarIndicator, RadarSeriesData, SankeyChartProps, SankeyData, SankeyEventParams, SankeyLink, SankeyNode, ScatterChartProps, ScatterSeriesData, SliceEventParams, TreemapChartProps, TreemapEventParams, TreemapLevel, TreemapNode } from './types/index.cjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Formatting utilities for chart values
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Format a number with thousand separators
|
|
10
|
+
*/
|
|
11
|
+
declare function formatNumber(value: number, options?: Intl.NumberFormatOptions): string;
|
|
12
|
+
/**
|
|
13
|
+
* Format a number as currency
|
|
14
|
+
*/
|
|
15
|
+
declare function formatCurrency(value: number, currency?: string, locale?: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Format a number as percentage
|
|
18
|
+
*/
|
|
19
|
+
declare function formatPercent(value: number, decimals?: number, locale?: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Format a date for display
|
|
22
|
+
*/
|
|
23
|
+
declare function formatDate(date: Date | string, options?: Intl.DateTimeFormatOptions, locale?: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Abbreviate large numbers (e.g., 1000 -> 1K, 1000000 -> 1M)
|
|
26
|
+
*/
|
|
27
|
+
declare function abbreviateNumber(value: number, decimals?: number): string;
|
|
28
|
+
/**
|
|
29
|
+
* Create a tooltip formatter for ECharts
|
|
30
|
+
*/
|
|
31
|
+
declare function createTooltipFormatter(options?: {
|
|
32
|
+
showSeriesName?: boolean;
|
|
33
|
+
valueFormatter?: (value: number) => string;
|
|
34
|
+
showPercent?: boolean;
|
|
35
|
+
}): (params: {
|
|
36
|
+
seriesName?: string;
|
|
37
|
+
name: string;
|
|
38
|
+
value: number | number[];
|
|
39
|
+
percent?: number;
|
|
40
|
+
}[]) => string;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Accessibility utilities for charts
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Generate an accessible description for a line chart
|
|
48
|
+
*/
|
|
49
|
+
declare function generateLineChartDescription(title: string, data: LineChartData): string;
|
|
50
|
+
/**
|
|
51
|
+
* Generate an accessible description for a bar chart
|
|
52
|
+
*/
|
|
53
|
+
declare function generateBarChartDescription(title: string, data: BarChartData): string;
|
|
54
|
+
/**
|
|
55
|
+
* Generate an accessible description for a pie/donut chart
|
|
56
|
+
*/
|
|
57
|
+
declare function generatePieChartDescription(title: string, data: PieSliceData[], isDonut?: boolean): string;
|
|
58
|
+
/**
|
|
59
|
+
* Generate an accessible description for a scatter chart
|
|
60
|
+
*/
|
|
61
|
+
declare function generateScatterChartDescription(title: string, data: ScatterChartData): string;
|
|
62
|
+
/**
|
|
63
|
+
* Generate a data table for screen readers (hidden visually)
|
|
64
|
+
*/
|
|
65
|
+
declare function generateDataTable(headers: string[], rows: (string | number)[][]): string;
|
|
66
|
+
|
|
67
|
+
export { BarChartData, LineChartData, PieSliceData, ScatterChartData, abbreviateNumber, createTooltipFormatter, formatCurrency, formatDate, formatNumber, formatPercent, generateBarChartDescription, generateDataTable, generateLineChartDescription, generatePieChartDescription, generateScatterChartDescription };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export { EChartsTheme, THEME_DARK, THEME_LIGHT, darkTheme, generateDarkTheme, generateLightTheme, lightTheme } from './theme/index.js';
|
|
2
|
+
import { LineChartData, BarChartData, PieSliceData, ScatterChartData } from './types/index.js';
|
|
3
|
+
export { AreaChartData, AreaChartProps, AreaSeriesData, BarChartProps, BarSeriesData, BaseChartProps, CandlestickChartProps, CandlestickData, CandlestickEventParams, CandlestickItem, DataPointEventParams, DonutChartProps, FunnelChartProps, FunnelSliceData, GaugeChartProps, HeatmapChartProps, HeatmapData, HeatmapEventParams, LineChartProps, LineSeriesData, PieChartProps, RadarChartData, RadarChartProps, RadarIndicator, RadarSeriesData, SankeyChartProps, SankeyData, SankeyEventParams, SankeyLink, SankeyNode, ScatterChartProps, ScatterSeriesData, SliceEventParams, TreemapChartProps, TreemapEventParams, TreemapLevel, TreemapNode } from './types/index.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Formatting utilities for chart values
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Format a number with thousand separators
|
|
10
|
+
*/
|
|
11
|
+
declare function formatNumber(value: number, options?: Intl.NumberFormatOptions): string;
|
|
12
|
+
/**
|
|
13
|
+
* Format a number as currency
|
|
14
|
+
*/
|
|
15
|
+
declare function formatCurrency(value: number, currency?: string, locale?: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Format a number as percentage
|
|
18
|
+
*/
|
|
19
|
+
declare function formatPercent(value: number, decimals?: number, locale?: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Format a date for display
|
|
22
|
+
*/
|
|
23
|
+
declare function formatDate(date: Date | string, options?: Intl.DateTimeFormatOptions, locale?: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Abbreviate large numbers (e.g., 1000 -> 1K, 1000000 -> 1M)
|
|
26
|
+
*/
|
|
27
|
+
declare function abbreviateNumber(value: number, decimals?: number): string;
|
|
28
|
+
/**
|
|
29
|
+
* Create a tooltip formatter for ECharts
|
|
30
|
+
*/
|
|
31
|
+
declare function createTooltipFormatter(options?: {
|
|
32
|
+
showSeriesName?: boolean;
|
|
33
|
+
valueFormatter?: (value: number) => string;
|
|
34
|
+
showPercent?: boolean;
|
|
35
|
+
}): (params: {
|
|
36
|
+
seriesName?: string;
|
|
37
|
+
name: string;
|
|
38
|
+
value: number | number[];
|
|
39
|
+
percent?: number;
|
|
40
|
+
}[]) => string;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Accessibility utilities for charts
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Generate an accessible description for a line chart
|
|
48
|
+
*/
|
|
49
|
+
declare function generateLineChartDescription(title: string, data: LineChartData): string;
|
|
50
|
+
/**
|
|
51
|
+
* Generate an accessible description for a bar chart
|
|
52
|
+
*/
|
|
53
|
+
declare function generateBarChartDescription(title: string, data: BarChartData): string;
|
|
54
|
+
/**
|
|
55
|
+
* Generate an accessible description for a pie/donut chart
|
|
56
|
+
*/
|
|
57
|
+
declare function generatePieChartDescription(title: string, data: PieSliceData[], isDonut?: boolean): string;
|
|
58
|
+
/**
|
|
59
|
+
* Generate an accessible description for a scatter chart
|
|
60
|
+
*/
|
|
61
|
+
declare function generateScatterChartDescription(title: string, data: ScatterChartData): string;
|
|
62
|
+
/**
|
|
63
|
+
* Generate a data table for screen readers (hidden visually)
|
|
64
|
+
*/
|
|
65
|
+
declare function generateDataTable(headers: string[], rows: (string | number)[][]): string;
|
|
66
|
+
|
|
67
|
+
export { BarChartData, LineChartData, PieSliceData, ScatterChartData, abbreviateNumber, createTooltipFormatter, formatCurrency, formatDate, formatNumber, formatPercent, generateBarChartDescription, generateDataTable, generateLineChartDescription, generatePieChartDescription, generateScatterChartDescription };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
export { THEME_DARK, THEME_LIGHT, darkTheme, generateDarkTheme, generateLightTheme, lightTheme } from './chunk-ZRG25JNX.js';
|
|
2
|
+
|
|
3
|
+
// src/utils/format.ts
|
|
4
|
+
function formatNumber(value, options) {
|
|
5
|
+
return new Intl.NumberFormat("en-US", options).format(value);
|
|
6
|
+
}
|
|
7
|
+
function formatCurrency(value, currency = "USD", locale = "en-US") {
|
|
8
|
+
return new Intl.NumberFormat(locale, {
|
|
9
|
+
style: "currency",
|
|
10
|
+
currency
|
|
11
|
+
}).format(value);
|
|
12
|
+
}
|
|
13
|
+
function formatPercent(value, decimals = 1, locale = "en-US") {
|
|
14
|
+
return new Intl.NumberFormat(locale, {
|
|
15
|
+
style: "percent",
|
|
16
|
+
minimumFractionDigits: decimals,
|
|
17
|
+
maximumFractionDigits: decimals
|
|
18
|
+
}).format(value);
|
|
19
|
+
}
|
|
20
|
+
function formatDate(date, options, locale = "en-US") {
|
|
21
|
+
const d = typeof date === "string" ? new Date(date) : date;
|
|
22
|
+
return new Intl.DateTimeFormat(locale, options).format(d);
|
|
23
|
+
}
|
|
24
|
+
function abbreviateNumber(value, decimals = 1) {
|
|
25
|
+
const suffixes = ["", "K", "M", "B", "T"];
|
|
26
|
+
let suffixIndex = 0;
|
|
27
|
+
let abbreviated = value;
|
|
28
|
+
while (Math.abs(abbreviated) >= 1e3 && suffixIndex < suffixes.length - 1) {
|
|
29
|
+
abbreviated /= 1e3;
|
|
30
|
+
suffixIndex++;
|
|
31
|
+
}
|
|
32
|
+
return abbreviated.toFixed(decimals).replace(/\.0+$/, "") + suffixes[suffixIndex];
|
|
33
|
+
}
|
|
34
|
+
function createTooltipFormatter(options = {}) {
|
|
35
|
+
const { showSeriesName = true, valueFormatter = formatNumber } = options;
|
|
36
|
+
return (params) => {
|
|
37
|
+
if (!Array.isArray(params)) {
|
|
38
|
+
params = [
|
|
39
|
+
params
|
|
40
|
+
];
|
|
41
|
+
}
|
|
42
|
+
return params.map((param) => {
|
|
43
|
+
const value = Array.isArray(param.value) ? param.value[1] : param.value;
|
|
44
|
+
const formatted = valueFormatter(value);
|
|
45
|
+
const percent = param.percent ? ` (${param.percent.toFixed(1)}%)` : "";
|
|
46
|
+
if (showSeriesName && param.seriesName) {
|
|
47
|
+
return `${param.seriesName}: ${formatted}${percent}`;
|
|
48
|
+
}
|
|
49
|
+
return `${param.name}: ${formatted}${percent}`;
|
|
50
|
+
}).join("<br/>");
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// src/utils/accessibility.ts
|
|
55
|
+
function generateLineChartDescription(title, data) {
|
|
56
|
+
const seriesCount = data.series.length;
|
|
57
|
+
const categoryCount = data.categories.length;
|
|
58
|
+
const seriesNames = data.series.map((s) => s.name).join(", ");
|
|
59
|
+
let description = `${title}. Line chart with ${categoryCount} data points`;
|
|
60
|
+
if (seriesCount > 1) {
|
|
61
|
+
description += ` across ${seriesCount} series: ${seriesNames}`;
|
|
62
|
+
}
|
|
63
|
+
data.series.forEach((series) => {
|
|
64
|
+
if (series.data.length >= 2) {
|
|
65
|
+
const first = series.data[0];
|
|
66
|
+
const last = series.data[series.data.length - 1];
|
|
67
|
+
const trend = last > first ? "increasing" : last < first ? "decreasing" : "stable";
|
|
68
|
+
description += `. ${series.name} shows ${trend} trend from ${first} to ${last}`;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return description;
|
|
72
|
+
}
|
|
73
|
+
function generateBarChartDescription(title, data) {
|
|
74
|
+
const categoryCount = data.categories.length;
|
|
75
|
+
const seriesCount = data.series.length;
|
|
76
|
+
let description = `${title}. Bar chart with ${categoryCount} categories`;
|
|
77
|
+
if (seriesCount > 1) {
|
|
78
|
+
description += ` and ${seriesCount} series`;
|
|
79
|
+
}
|
|
80
|
+
let maxValue = -Infinity;
|
|
81
|
+
let maxCategory = "";
|
|
82
|
+
let minValue = Infinity;
|
|
83
|
+
let minCategory = "";
|
|
84
|
+
data.series.forEach((series) => {
|
|
85
|
+
series.data.forEach((value, index) => {
|
|
86
|
+
if (value > maxValue) {
|
|
87
|
+
maxValue = value;
|
|
88
|
+
maxCategory = data.categories[index];
|
|
89
|
+
}
|
|
90
|
+
if (value < minValue) {
|
|
91
|
+
minValue = value;
|
|
92
|
+
minCategory = data.categories[index];
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
description += `. Highest value is ${maxValue} for ${maxCategory}. Lowest value is ${minValue} for ${minCategory}`;
|
|
97
|
+
return description;
|
|
98
|
+
}
|
|
99
|
+
function generatePieChartDescription(title, data, isDonut = false) {
|
|
100
|
+
const total = data.reduce((sum, slice) => sum + slice.value, 0);
|
|
101
|
+
const chartType = isDonut ? "Donut" : "Pie";
|
|
102
|
+
let description = `${title}. ${chartType} chart with ${data.length} segments`;
|
|
103
|
+
const sorted = [...data].sort((a, b) => b.value - a.value);
|
|
104
|
+
const topSegments = sorted.slice(0, 3);
|
|
105
|
+
const percentages = topSegments.map((segment) => {
|
|
106
|
+
const percent = (segment.value / total * 100).toFixed(1);
|
|
107
|
+
return `${segment.name} at ${percent}%`;
|
|
108
|
+
});
|
|
109
|
+
description += `. Top segments: ${percentages.join(", ")}`;
|
|
110
|
+
return description;
|
|
111
|
+
}
|
|
112
|
+
function generateScatterChartDescription(title, data) {
|
|
113
|
+
const totalPoints = data.series.reduce((sum, s) => sum + s.data.length, 0);
|
|
114
|
+
const seriesCount = data.series.length;
|
|
115
|
+
let description = `${title}. Scatter plot with ${totalPoints} data points`;
|
|
116
|
+
if (seriesCount > 1) {
|
|
117
|
+
const seriesNames = data.series.map((s) => s.name).join(", ");
|
|
118
|
+
description += ` across ${seriesCount} series: ${seriesNames}`;
|
|
119
|
+
}
|
|
120
|
+
return description;
|
|
121
|
+
}
|
|
122
|
+
function generateDataTable(headers, rows) {
|
|
123
|
+
const headerRow = headers.map((h) => `<th scope="col">${h}</th>`).join("");
|
|
124
|
+
const bodyRows = rows.map((row) => `<tr>${row.map((cell) => `<td>${cell}</td>`).join("")}</tr>`).join("");
|
|
125
|
+
return `
|
|
126
|
+
<table class="sr-only">
|
|
127
|
+
<thead><tr>${headerRow}</tr></thead>
|
|
128
|
+
<tbody>${bodyRows}</tbody>
|
|
129
|
+
</table>
|
|
130
|
+
`;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export { abbreviateNumber, createTooltipFormatter, formatCurrency, formatDate, formatNumber, formatPercent, generateBarChartDescription, generateDataTable, generateLineChartDescription, generatePieChartDescription, generateScatterChartDescription };
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var themeTokens = require('@classic-homes/theme-tokens');
|
|
4
|
+
|
|
5
|
+
// src/theme/generator.ts
|
|
6
|
+
function generateLightTheme() {
|
|
7
|
+
const chartColors = [
|
|
8
|
+
themeTokens.colors.teal[500],
|
|
9
|
+
// chart.1
|
|
10
|
+
themeTokens.colors.navy[700],
|
|
11
|
+
// chart.2
|
|
12
|
+
themeTokens.colors.plum[700],
|
|
13
|
+
// chart.3
|
|
14
|
+
themeTokens.colors.forest[500],
|
|
15
|
+
// chart.4
|
|
16
|
+
themeTokens.colors.sky[600],
|
|
17
|
+
// chart.5
|
|
18
|
+
// Extended palette for >5 series
|
|
19
|
+
themeTokens.colors.stone[600],
|
|
20
|
+
themeTokens.colors.lavender[700],
|
|
21
|
+
themeTokens.colors.deepTeal[600],
|
|
22
|
+
themeTokens.colors.sage[600],
|
|
23
|
+
themeTokens.colors.red[600]
|
|
24
|
+
];
|
|
25
|
+
return {
|
|
26
|
+
color: chartColors,
|
|
27
|
+
backgroundColor: "transparent",
|
|
28
|
+
textStyle: {
|
|
29
|
+
fontFamily: themeTokens.fontFamily.sans.join(", "),
|
|
30
|
+
color: themeTokens.semanticColors.light.foreground
|
|
31
|
+
},
|
|
32
|
+
title: {
|
|
33
|
+
textStyle: {
|
|
34
|
+
color: themeTokens.semanticColors.light.foreground,
|
|
35
|
+
fontWeight: 600,
|
|
36
|
+
fontSize: 16
|
|
37
|
+
},
|
|
38
|
+
subtextStyle: {
|
|
39
|
+
color: themeTokens.semanticColors.light.mutedForeground,
|
|
40
|
+
fontSize: 14
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
legend: {
|
|
44
|
+
textStyle: {
|
|
45
|
+
color: themeTokens.semanticColors.light.foreground
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
tooltip: {
|
|
49
|
+
backgroundColor: themeTokens.semanticColors.light.popover,
|
|
50
|
+
borderColor: themeTokens.semanticColors.light.border,
|
|
51
|
+
borderWidth: 1,
|
|
52
|
+
borderRadius: parseInt(themeTokens.borderRadius.md) || 6,
|
|
53
|
+
textStyle: {
|
|
54
|
+
color: themeTokens.semanticColors.light.popoverForeground
|
|
55
|
+
},
|
|
56
|
+
extraCssText: "box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);"
|
|
57
|
+
},
|
|
58
|
+
xAxis: {
|
|
59
|
+
axisLine: {
|
|
60
|
+
show: true,
|
|
61
|
+
lineStyle: {
|
|
62
|
+
color: themeTokens.colors.gray[300]
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
axisTick: {
|
|
66
|
+
show: true,
|
|
67
|
+
lineStyle: {
|
|
68
|
+
color: themeTokens.colors.gray[300]
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
axisLabel: {
|
|
72
|
+
color: themeTokens.semanticColors.light.mutedForeground
|
|
73
|
+
},
|
|
74
|
+
splitLine: {
|
|
75
|
+
show: true,
|
|
76
|
+
lineStyle: {
|
|
77
|
+
color: themeTokens.colors.gray[200],
|
|
78
|
+
type: "dashed"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
yAxis: {
|
|
83
|
+
axisLine: {
|
|
84
|
+
show: false,
|
|
85
|
+
lineStyle: {
|
|
86
|
+
color: themeTokens.colors.gray[300]
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
axisTick: {
|
|
90
|
+
show: false,
|
|
91
|
+
lineStyle: {
|
|
92
|
+
color: themeTokens.colors.gray[300]
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
axisLabel: {
|
|
96
|
+
color: themeTokens.semanticColors.light.mutedForeground
|
|
97
|
+
},
|
|
98
|
+
splitLine: {
|
|
99
|
+
show: true,
|
|
100
|
+
lineStyle: {
|
|
101
|
+
color: themeTokens.colors.gray[200],
|
|
102
|
+
type: "dashed"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
line: {
|
|
107
|
+
smooth: false,
|
|
108
|
+
symbol: "circle",
|
|
109
|
+
symbolSize: 4
|
|
110
|
+
},
|
|
111
|
+
bar: {
|
|
112
|
+
barMaxWidth: 50,
|
|
113
|
+
itemStyle: {
|
|
114
|
+
borderRadius: [4, 4, 0, 0]
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
pie: {
|
|
118
|
+
itemStyle: {
|
|
119
|
+
borderColor: themeTokens.semanticColors.light.card,
|
|
120
|
+
borderWidth: 2
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
scatter: {
|
|
124
|
+
symbolSize: 10
|
|
125
|
+
},
|
|
126
|
+
gauge: {
|
|
127
|
+
axisLine: {
|
|
128
|
+
lineStyle: {
|
|
129
|
+
color: [
|
|
130
|
+
[0.3, themeTokens.colors.teal[400]],
|
|
131
|
+
[0.7, themeTokens.colors.teal[500]],
|
|
132
|
+
[1, themeTokens.colors.teal[600]]
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function generateDarkTheme() {
|
|
140
|
+
const chartColors = [
|
|
141
|
+
themeTokens.colors.teal[400],
|
|
142
|
+
// chart.1
|
|
143
|
+
themeTokens.colors.navy[400],
|
|
144
|
+
// chart.2
|
|
145
|
+
themeTokens.colors.plum[400],
|
|
146
|
+
// chart.3
|
|
147
|
+
themeTokens.colors.forest[400],
|
|
148
|
+
// chart.4
|
|
149
|
+
themeTokens.colors.sky[400],
|
|
150
|
+
// chart.5
|
|
151
|
+
// Extended palette for >5 series
|
|
152
|
+
themeTokens.colors.stone[400],
|
|
153
|
+
themeTokens.colors.lavender[400],
|
|
154
|
+
themeTokens.colors.deepTeal[400],
|
|
155
|
+
themeTokens.colors.sage[400],
|
|
156
|
+
themeTokens.colors.red[400]
|
|
157
|
+
];
|
|
158
|
+
return {
|
|
159
|
+
color: chartColors,
|
|
160
|
+
backgroundColor: "transparent",
|
|
161
|
+
textStyle: {
|
|
162
|
+
fontFamily: themeTokens.fontFamily.sans.join(", "),
|
|
163
|
+
color: themeTokens.semanticColors.dark.foreground
|
|
164
|
+
},
|
|
165
|
+
title: {
|
|
166
|
+
textStyle: {
|
|
167
|
+
color: themeTokens.semanticColors.dark.foreground,
|
|
168
|
+
fontWeight: 600,
|
|
169
|
+
fontSize: 16
|
|
170
|
+
},
|
|
171
|
+
subtextStyle: {
|
|
172
|
+
color: themeTokens.semanticColors.dark.mutedForeground,
|
|
173
|
+
fontSize: 14
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
legend: {
|
|
177
|
+
textStyle: {
|
|
178
|
+
color: themeTokens.semanticColors.dark.foreground
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
tooltip: {
|
|
182
|
+
backgroundColor: themeTokens.semanticColors.dark.popover,
|
|
183
|
+
borderColor: themeTokens.semanticColors.dark.border,
|
|
184
|
+
borderWidth: 1,
|
|
185
|
+
borderRadius: parseInt(themeTokens.borderRadius.md) || 6,
|
|
186
|
+
textStyle: {
|
|
187
|
+
color: themeTokens.semanticColors.dark.popoverForeground
|
|
188
|
+
},
|
|
189
|
+
extraCssText: "box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3);"
|
|
190
|
+
},
|
|
191
|
+
xAxis: {
|
|
192
|
+
axisLine: {
|
|
193
|
+
show: true,
|
|
194
|
+
lineStyle: {
|
|
195
|
+
color: themeTokens.colors.gray[600]
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
axisTick: {
|
|
199
|
+
show: true,
|
|
200
|
+
lineStyle: {
|
|
201
|
+
color: themeTokens.colors.gray[600]
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
axisLabel: {
|
|
205
|
+
color: themeTokens.semanticColors.dark.mutedForeground
|
|
206
|
+
},
|
|
207
|
+
splitLine: {
|
|
208
|
+
show: true,
|
|
209
|
+
lineStyle: {
|
|
210
|
+
color: themeTokens.colors.gray[700],
|
|
211
|
+
type: "dashed"
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
yAxis: {
|
|
216
|
+
axisLine: {
|
|
217
|
+
show: false,
|
|
218
|
+
lineStyle: {
|
|
219
|
+
color: themeTokens.colors.gray[600]
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
axisTick: {
|
|
223
|
+
show: false,
|
|
224
|
+
lineStyle: {
|
|
225
|
+
color: themeTokens.colors.gray[600]
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
axisLabel: {
|
|
229
|
+
color: themeTokens.semanticColors.dark.mutedForeground
|
|
230
|
+
},
|
|
231
|
+
splitLine: {
|
|
232
|
+
show: true,
|
|
233
|
+
lineStyle: {
|
|
234
|
+
color: themeTokens.colors.gray[700],
|
|
235
|
+
type: "dashed"
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
line: {
|
|
240
|
+
smooth: false,
|
|
241
|
+
symbol: "circle",
|
|
242
|
+
symbolSize: 4
|
|
243
|
+
},
|
|
244
|
+
bar: {
|
|
245
|
+
barMaxWidth: 50,
|
|
246
|
+
itemStyle: {
|
|
247
|
+
borderRadius: [4, 4, 0, 0]
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
pie: {
|
|
251
|
+
itemStyle: {
|
|
252
|
+
borderColor: themeTokens.semanticColors.dark.card,
|
|
253
|
+
borderWidth: 2
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
scatter: {
|
|
257
|
+
symbolSize: 10
|
|
258
|
+
},
|
|
259
|
+
gauge: {
|
|
260
|
+
axisLine: {
|
|
261
|
+
lineStyle: {
|
|
262
|
+
color: [
|
|
263
|
+
[0.3, themeTokens.colors.teal[500]],
|
|
264
|
+
[0.7, themeTokens.colors.teal[400]],
|
|
265
|
+
[1, themeTokens.colors.teal[300]]
|
|
266
|
+
]
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
var lightTheme = generateLightTheme();
|
|
273
|
+
var darkTheme = generateDarkTheme();
|
|
274
|
+
|
|
275
|
+
// src/theme/index.ts
|
|
276
|
+
var THEME_LIGHT = "classic-light";
|
|
277
|
+
var THEME_DARK = "classic-dark";
|
|
278
|
+
|
|
279
|
+
exports.THEME_DARK = THEME_DARK;
|
|
280
|
+
exports.THEME_LIGHT = THEME_LIGHT;
|
|
281
|
+
exports.darkTheme = darkTheme;
|
|
282
|
+
exports.generateDarkTheme = generateDarkTheme;
|
|
283
|
+
exports.generateLightTheme = generateLightTheme;
|
|
284
|
+
exports.lightTheme = lightTheme;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ECharts theme generator
|
|
3
|
+
*
|
|
4
|
+
* Generates ECharts-compatible themes from Classic Theme design tokens
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* ECharts theme configuration type
|
|
8
|
+
*/
|
|
9
|
+
interface EChartsTheme {
|
|
10
|
+
color: string[];
|
|
11
|
+
backgroundColor: string;
|
|
12
|
+
textStyle: {
|
|
13
|
+
fontFamily: string;
|
|
14
|
+
color: string;
|
|
15
|
+
};
|
|
16
|
+
title: {
|
|
17
|
+
textStyle: {
|
|
18
|
+
color: string;
|
|
19
|
+
fontWeight: number;
|
|
20
|
+
fontSize: number;
|
|
21
|
+
};
|
|
22
|
+
subtextStyle: {
|
|
23
|
+
color: string;
|
|
24
|
+
fontSize: number;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
legend: {
|
|
28
|
+
textStyle: {
|
|
29
|
+
color: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
tooltip: {
|
|
33
|
+
backgroundColor: string;
|
|
34
|
+
borderColor: string;
|
|
35
|
+
borderWidth: number;
|
|
36
|
+
borderRadius: number;
|
|
37
|
+
textStyle: {
|
|
38
|
+
color: string;
|
|
39
|
+
};
|
|
40
|
+
extraCssText: string;
|
|
41
|
+
};
|
|
42
|
+
xAxis: {
|
|
43
|
+
axisLine: {
|
|
44
|
+
show: boolean;
|
|
45
|
+
lineStyle: {
|
|
46
|
+
color: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
axisTick: {
|
|
50
|
+
show: boolean;
|
|
51
|
+
lineStyle: {
|
|
52
|
+
color: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
axisLabel: {
|
|
56
|
+
color: string;
|
|
57
|
+
};
|
|
58
|
+
splitLine: {
|
|
59
|
+
show: boolean;
|
|
60
|
+
lineStyle: {
|
|
61
|
+
color: string;
|
|
62
|
+
type: string;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
yAxis: {
|
|
67
|
+
axisLine: {
|
|
68
|
+
show: boolean;
|
|
69
|
+
lineStyle: {
|
|
70
|
+
color: string;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
axisTick: {
|
|
74
|
+
show: boolean;
|
|
75
|
+
lineStyle: {
|
|
76
|
+
color: string;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
axisLabel: {
|
|
80
|
+
color: string;
|
|
81
|
+
};
|
|
82
|
+
splitLine: {
|
|
83
|
+
show: boolean;
|
|
84
|
+
lineStyle: {
|
|
85
|
+
color: string;
|
|
86
|
+
type: string;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
line: {
|
|
91
|
+
smooth: boolean;
|
|
92
|
+
symbol: string;
|
|
93
|
+
symbolSize: number;
|
|
94
|
+
};
|
|
95
|
+
bar: {
|
|
96
|
+
barMaxWidth: number;
|
|
97
|
+
itemStyle: {
|
|
98
|
+
borderRadius: number[];
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
pie: {
|
|
102
|
+
itemStyle: {
|
|
103
|
+
borderColor: string;
|
|
104
|
+
borderWidth: number;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
scatter: {
|
|
108
|
+
symbolSize: number;
|
|
109
|
+
};
|
|
110
|
+
gauge: {
|
|
111
|
+
axisLine: {
|
|
112
|
+
lineStyle: {
|
|
113
|
+
color: [number, string][];
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Generate light theme from design tokens
|
|
120
|
+
*/
|
|
121
|
+
declare function generateLightTheme(): EChartsTheme;
|
|
122
|
+
/**
|
|
123
|
+
* Generate dark theme from design tokens
|
|
124
|
+
*/
|
|
125
|
+
declare function generateDarkTheme(): EChartsTheme;
|
|
126
|
+
/**
|
|
127
|
+
* Pre-generated light theme
|
|
128
|
+
*/
|
|
129
|
+
declare const lightTheme: EChartsTheme;
|
|
130
|
+
/**
|
|
131
|
+
* Pre-generated dark theme
|
|
132
|
+
*/
|
|
133
|
+
declare const darkTheme: EChartsTheme;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Chart theme exports
|
|
137
|
+
*/
|
|
138
|
+
|
|
139
|
+
/** Theme name constants */
|
|
140
|
+
declare const THEME_LIGHT = "classic-light";
|
|
141
|
+
declare const THEME_DARK = "classic-dark";
|
|
142
|
+
|
|
143
|
+
export { type EChartsTheme, THEME_DARK, THEME_LIGHT, darkTheme, generateDarkTheme, generateLightTheme, lightTheme };
|