折线图的 线条的样式怎么控制
option = {title: {text: 'Stacked Line'},tooltip: {trigger: 'axis'},legend: {data: ['Email', 'Union Ads', 'Video Ads', 'Direct', 'Search Engine']},grid: {left: '3%',right: '4%',bottom: '3%',containLabel: true},toolbox: {feature: {saveAsImage: {}}},xAxis: {type: 'category',boundaryGap: false,data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']},yAxis: {type: 'value'},series: [{name: 'Email',type: 'line',stack: 'Total',data: [120, 132, 101, 134, 90, 230, 210]},{name: 'Union Ads',type: 'line',stack: 'Total',data: [220, 182, 191, 234, 290, 330, 310]},{name: 'Video Ads',type: 'line',stack: 'Total',data: [150, 232, 201, 154, 190, 330, 410]},{name: 'Direct',type: 'line',stack: 'Total',data: [320, 332, 301, 334, 390, 330, 320]},{name: 'Search Engine',type: 'line',stack: 'Total',data: [820, 932, 901, 934, 1290, 1330, 1320]}]
};
- 基础线条样式控制
在 series 的每个系列中添加 lineStyle 配置:
series: [{name: 'Email',type: 'line',data: [120, 132, 101, 134, 90, 230, 210],lineStyle: {color: '#FF0000', width: 3, type: 'solid', opacity: 0.8, shadowColor: 'rgba(0, 0, 0, 0.5)', shadowBlur: 10, shadowOffsetY: 5 }}
]
- 数据点样式控制
通过 itemStyle 配置折线上数据点的样式:
series: [{name: 'Email',type: 'line',data: [120, 132, 101, 134, 90, 230, 210],itemStyle: {color: '#36A2EF', borderColor: '#FFF', borderWidth: 2, borderType: 'solid', opacity: 1,shadowBlur: 5},symbol: 'circle', symbolSize: 8 }
]
- 平滑曲线与区域填充
series: [{name: 'Email',type: 'line',smooth: true, areaStyle: { color: {type: 'linear', x: 0, y: 0, x2: 0, y2: 1,colorStops: [{ offset: 0, color: 'rgba(58, 77, 233, 0.8)' },{ offset: 1, color: 'rgba(58, 77, 233, 0.1)' }]}}}
]
- 动态效果配置
series: [{name: 'Email',type: 'line',animation: true,animationDuration: 2000, animationEasing: 'elasticOut', emphasis: {lineStyle: {width: 5},itemStyle: {color: '#FF0000',symbolSize: 12}}}
]
- 完整示例
option = {series: [{name: 'Email',type: 'line',data: [120, 132, 101, 134, 90, 230, 210],lineStyle: {color: '#EE6666',width: 3,type: 'dashed'},itemStyle: {color: '#EE6666',borderColor: '#FFF',borderWidth: 2},symbol: 'diamond',symbolSize: 10,smooth: true,areaStyle: {opacity: 0.1}}]
};