chart-visualization
2
总安装量
2
周安装量
#63478
全站排名
安装命令
npx skills add https://github.com/alongor666/targetmanage --skill chart-visualization
Agent 安装分布
trae
2
gemini-cli
2
claude-code
2
github-copilot
2
codex
2
kimi-cli
2
Skill 文档
Chart Visualization Skill
è½åæ¦è¿°
æ¤æè½æä¾è½¦é©ç»è¥æ°æ®å¯è§åè§£å³æ¹æ¡ï¼åºäº ECharts å®ç°æ±ç¶å¾ãæçº¿å¾ãç»åå¾çå¤ç§å¾è¡¨ç±»åï¼æ¯æååºå¼è®¾è®¡ã主é¢éé å交äºåè½ã
æ¯æçå¾è¡¨ç±»å
1. æ±ç¶å¾ï¼Bar Chartï¼
æåº¦ä¿è´¹è§åå¾
{
title: { text: 'æåº¦ä¿è´¹è§å' },
xAxis: {
type: 'category',
data: ['1æ', '2æ', '3æ', '4æ', '5æ', '6æ',
'7æ', '8æ', '9æ', '10æ', '11æ', '12æ']
},
yAxis: [
{
type: 'value',
name: 'ä¿è´¹ï¼ä¸å
ï¼',
position: 'left'
}
],
series: [
{
name: '2026ç®æ ',
type: 'bar',
data: targetMonthlyData,
itemStyle: { color: '#60A5FA' }, // æµ
èè²
barWidth: '60%',
label: {
show: true,
position: 'top',
formatter: '{c}',
fontWeight: 'bold'
}
},
{
name: '2025å®é
',
type: 'bar',
data: actual2025MonthlyData,
itemStyle: { color: '#D1D5DB' }, // æµ
ç°è²
barWidth: '60%',
label: {
show: true,
position: 'top',
formatter: '{c}',
fontWeight: 'bold'
}
}
]
}
å£åº¦ä¿è´¹è§åå¾
{
title: { text: 'å£åº¦ä¿è´¹è§å' },
xAxis: {
type: 'category',
data: ['Q1', 'Q2', 'Q3', 'Q4']
},
series: [
{
name: '2026ç®æ ',
type: 'bar',
data: quarterlyTargetData,
itemStyle: { color: '#60A5FA' }
},
{
name: '2025å®é
',
type: 'bar',
data: quarterlyActual2025Data,
itemStyle: { color: '#D1D5DB' }
}
]
}
2. ç»åå¾ï¼Combo Chartï¼
æåº¦ç»åå¾ï¼æ±ç¶ + æçº¿ï¼
{
title: { text: 'æåº¦ä¿è´¹ä¸å¢é¿ç' },
xAxis: {
type: 'category',
data: months
},
yAxis: [
{
type: 'value',
name: 'ä¿è´¹ï¼ä¸å
ï¼',
position: 'left'
},
{
type: 'value',
name: 'å¢é¿çï¼%ï¼',
position: 'right',
axisLabel: {
formatter: '{value}%'
}
}
],
series: [
// æ±ç¶å¾ï¼å·¦è½´ï¼
{
name: '2026ç®æ ',
type: 'bar',
yAxisIndex: 0,
data: targetMonthlyData
},
{
name: '2025å®é
',
type: 'bar',
yAxisIndex: 0,
data: actual2025MonthlyData
},
// æçº¿å¾ï¼å³è½´ï¼
{
name: '忝å¢é¿ç',
type: 'line',
yAxisIndex: 1,
data: growthRateData,
smooth: true,
lineStyle: { color: '#3B82F6' },
label: {
show: true,
formatter: '{c}%',
color: '#3B82F6'
}
}
]
}
3. å æ¯å¾ï¼Percentage Chartï¼
æåº¦å æ¯è§åå¾
{
title: { text: 'æåº¦ä¿è´¹å æ¯' },
xAxis: {
type: 'category',
data: months
},
yAxis: [
{
type: 'value',
name: 'å æ¯ï¼%ï¼',
position: 'left',
max: 100,
axisLabel: { formatter: '{value}%' }
},
{
type: 'value',
name: 'å¢é¿çï¼%ï¼',
position: 'right',
axisLabel: { formatter: '{value}%' }
}
],
series: [
{
name: '2026è§åå æ¯',
type: 'bar',
yAxisIndex: 0,
data: targetPercentageData
},
{
name: '2025å®é
å æ¯',
type: 'bar',
yAxisIndex: 0,
data: actualPercentageData
},
{
name: '忝å¢é¿ç',
type: 'line',
yAxisIndex: 1,
data: growthRateData
}
]
}
å¾è¡¨æ ·å¼è§è
1. å ¨å±é ç½®
const globalConfig = {
// å»æç½æ ¼çº¿
grid: {
left: '3%',
right: '4%',
bottom: '3%',
top: '10%',
containLabel: true,
show: false // 䏿¾ç¤ºç½æ ¼çº¿
},
// å¾ä¾é
ç½®
legend: {
data: ['2026ç®æ ', '2025å®é
', '忝å¢é¿ç'],
top: '5%',
left: 'center'
},
// æç¤ºæ¡é
ç½®
tooltip: {
trigger: 'axis',
axisPointer: { type: 'shadow' },
formatter: function(params: any) {
let result = params[0].axisValue + '<br/>';
params.forEach((item: any) => {
if (item.seriesType === 'line') {
result += `${item.marker} ${item.seriesName}: ${item.value}%<br/>`;
} else {
result += `${item.marker} ${item.seriesName}: ${item.value} ä¸å
<br/>`;
}
});
return result;
}
},
// å¨ç»é
ç½®
animation: true,
animationDuration: 1000,
animationEasing: 'cubicOut'
};
2. æ±ç¶å¾æ ·å¼
const barStyle = {
barWidth: '60%', // æ±å®½
// æ°å¼æ ç¾
label: {
show: true,
position: 'top',
formatter: '{c}',
fontWeight: 'bold',
fontSize: 12,
// æ ç¾é¢è²
color: '#6B7280' // é»è®¤ç°è²
},
// æ±åé¢è²
itemStyle: {
borderRadius: [4, 4, 0, 0], // åè§
color: '#60A5FA' // 2026ç®æ æµ
è
},
// hover ææ
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowColor: 'rgba(0, 0, 0, 0.3)'
}
}
};
3. æçº¿å¾æ ·å¼
const lineStyle = {
smooth: true, // å¹³æ»æ²çº¿
// çº¿æ¡æ ·å¼
lineStyle: {
width: 2,
color: '#3B82F6' // èè²
},
// æ°æ®ç¹æ ·å¼
symbol: 'circle',
symbolSize: 6,
// æ°å¼æ ç¾
label: {
show: true,
formatter: '{c}%',
color: '#3B82F6', // é»è®¤èè²
fontWeight: 'bold',
fontSize: 12
},
// åºåå¡«å
ï¼å¯éï¼
areaStyle: {
color: {
type: 'linear',
x: 0, y: 0, x2: 0, y2: 1,
colorStops: [
{ offset: 0, color: 'rgba(59, 130, 246, 0.3)' },
{ offset: 1, color: 'rgba(59, 130, 246, 0.05)' }
]
}
}
};
é¢è¦åè½ï¼5% éå¼ï¼
é¢è¦è§¦åæ¡ä»¶
彿/å£åº¦å¢é¿ç < 5% æ¶è§¦åé¢è¦ã
é¢è¦æ ·å¼é ç½®
// é¢è¦æ¶æ±ç¶å¾é¢è²ï¼æ©è²
const warningBarColor = '#FF9500';
// é¢è¦æ¶æ ç¾é¢è²ï¼æ·±çº¢è²
const warningLabelColor = '#8B0000';
// é¢è¦æ¶æçº¿å¾é¢è²ï¼æ·±èè²ï¼ä¿æä¸åï¼
const warningLineColor = '#1E40AF';
// åºç¨é¢è¦æ ·å¼
series.forEach((item: any) => {
const growthRate = item.data;
if (item.seriesType === 'bar' && growthRate < 0.05) {
// æ±ç¶å¾é¢è¦
item.itemStyle.color = warningBarColor;
item.label.color = warningLabelColor;
} else if (item.seriesType === 'line') {
// æçº¿å¾é¢è¦
growthRate.forEach((rate: number, index: number) => {
if (rate < 0.05) {
// æ°æ®ç¹é¢è¦ï¼éè¦ä½¿ç¨ rich ææ¬æ ·å¼ï¼
item.label.formatter = function(params: any) {
const color = params.value < 0.05 ? warningLabelColor : '#3B82F6';
return `{${color}|${params.value}%}`;
};
}
});
}
});
ECharts Rich ææ¬æ ·å¼
const richTextStyle = {
label: {
formatter: function(params: any) {
const growthRate = params.value;
const color = growthRate < 0.05 ? '#8B0000' : '#3B82F6';
return `{warning${growthRate < 0.05 ? '|warning' : '|normal'}|${growthRate.toFixed(1)}%}`;
},
rich: {
normal: { color: '#3B82F6' },
warning: { color: '#8B0000', fontWeight: 'bold' }
}
}
};
ååºå¼éé
大屿¨¡å¼ï¼2400pxï¼
const largeScreenConfig = {
title: { textStyle: { fontSize: 24 } },
xAxis: { axisLabel: { fontSize: 16 } },
yAxis: { axisLabel: { fontSize: 16 } },
legend: { textStyle: { fontSize: 16 } },
grid: { left: '5%', right: '5%' }
};
æ¡é¢æ¨¡å¼ï¼1920pxï¼
const desktopConfig = {
title: { textStyle: { fontSize: 18 } },
xAxis: { axisLabel: { fontSize: 14 } },
yAxis: { axisLabel: { fontSize: 14 } },
legend: { textStyle: { fontSize: 14 } },
grid: { left: '3%', right: '4%' }
};
ç§»å¨æ¨¡å¼ï¼èªéåºï¼
const mobileConfig = {
title: { textStyle: { fontSize: 14 } },
xAxis: { axisLabel: { fontSize: 12, rotate: 45 } },
yAxis: { axisLabel: { fontSize: 12 } },
legend: { textStyle: { fontSize: 12 } },
grid: { left: '10%', right: '10%' }
};
ååºå¼åæ¢
function getResponsiveConfig() {
const width = window.innerWidth;
if (width >= 2400) return largeScreenConfig;
if (width >= 1024) return desktopConfig;
return mobileConfig;
}
é¢è²ç³»ç»
主è²è°
const colors = {
// 2026 ç®æ
target: {
primary: '#60A5FA', // æµ
èè²
hover: '#3B82F6', // èè²
warning: '#FF9500' // æ©è²ï¼é¢è¦ï¼
},
// 2025 å®é
actual2025: {
primary: '#D1D5DB', // æµ
ç°è²
hover: '#9CA3AF' // æ·±ç°è²
},
// å¢é¿ç
growth: {
normal: '#3B82F6', // èè²
warning: '#1E40AF', // æ·±èè²ï¼é¢è¦ï¼
labelNormal: '#3B82F6',// èè²æ ç¾
labelWarning: '#8B0000' // æ·±çº¢è²æ ç¾ï¼é¢è¦ï¼
}
};
æ°æ®æ ¼å¼å
ä¿è´¹æ ¼å¼å
function formatPremium(value: number): string {
if (value >= 10000) {
return (value / 10000).toFixed(2) + 'ä¸';
}
return value.toFixed(0);
}
ç¾åæ¯æ ¼å¼å
function formatPercentage(value: number): string {
return (value * 100).toFixed(1) + '%';
}
å¢é¿çæ ¼å¼å
function formatGrowthRate(value: number | null): string {
if (value === null) return 'â';
const formatted = (value * 100).toFixed(1);
const sign = value >= 0 ? '+' : '';
return sign + formatted + '%';
}
使ç¨ç¤ºä¾
ç¤ºä¾ 1ï¼çææåº¦ä¿è´¹è§åå¾
ç¨æ·è¯·æ±ï¼çææé½åå
¬å¸è½¦é© 2026 å¹´æåº¦ä¿è´¹è§åå¾
AI å¤çæµç¨ï¼
1. è®¡ç®æåº¦ç®æ ï¼æ ¹æ®æ¶é´è¿åº¦å£å¾ï¼
2. è·å 2025 å¹´æåº¦å®é
æ°æ®
3. 计ç®åæ¯å¢é¿ç
4. æ£æ¥é¢è¦æ¡ä»¶ï¼å¢é¿ç < 5%ï¼
5. åºç¨é¢è¦æ ·å¼
6. çæ ECharts é
ç½®
7. 渲æå¾è¡¨
ç¤ºä¾ 2ï¼åæ¢æ¶é´è¿åº¦å£å¾
ç¨æ·è¯·æ±ï¼åæ¢å°æéæ¶é´è¿åº¦æ¨¡å¼
AI å¤çæµç¨ï¼
1. 读å allocation_rules.json ä¸çæé
2. ä½¿ç¨æ°æééæ°è®¡ç®æåº¦ç®æ
3. æ´æ°å¾è¡¨æ°æ®æº
4. éæ°çæå¾è¡¨é
ç½®
5. å·æ°å¾è¡¨æ¾ç¤º
ç¤ºä¾ 3ï¼å¯¼åºå¾è¡¨ä¸ºå¾ç
ç¨æ·è¯·æ±ï¼å¯¼åºå½åå¾è¡¨ä¸º PNG å¾ç
AI å¤çæµç¨ï¼
1. è·å ECharts å®ä¾
2. ä½¿ç¨ getDataURL() çæå¾çæ°æ®
3. ä¸è½½ä¸º PNG æä»¶
4. æ¯æ 2x/3x é«å辨ç
ä¾èµé¡¹
æ ¸å¿åº
echarts: ^5.5.0echarts-for-react: ^3.0.2
é ç½®æä»¶
src/lib/echarts-utils.ts(ECharts å·¥å ·å½æ°)
æä½³å®è·µ
- æ§è½ä¼åï¼å¤§æ°æ®éæ¶ä½¿ç¨æ°æ®éæ ·æå页
- å¯è®¿é®æ§ï¼æä¾é®ç导èªåå±å¹é è¯»å¨æ¯æ
- é误å¤çï¼æ°æ®ç¼ºå¤±æ¶æ¾ç¤ºå好æç¤º
- æµè¯è¦çï¼ä¸åå°ºå¯¸åæ°æ®çå¾è¡¨æ¸²ææµè¯
- çæ¬å ¼å®¹ï¼ä½¿ç¨ ECharts ç¨³å® APIï¼é¿å é¢ç¹æ´æ°
åèææ¡£
- @doc docs/design/å ¨å±è®¾è®¡è§è.md
- @code src/lib/echarts-utils.ts
- @code src/components/charts/ChartContainer.tsx