PS相关学习资料链接:Pink老师的教程分解,O(∩_∩)O哈哈~
效果: html结构:
<div class="pannel trend">
<h2>复杂趋势图</h2>
<div class="chart">
</div>
</div>
css自行设置chart类的宽和高。 js相关逻辑:
(function() {
var myChart = echarts.init(document.querySelector(".trend .chart"));
var option = {
tooltip: {
trigger: 'axis',
},
legend: {
right: '3%',
textStyle: {
color: 'rgba(255, 255, 255, 0.5)'
}
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: [{
type: 'category',
boundaryGap: false,
axisLabel: {
color: 'rgba(255, 255, 255, 0.5)'
},
axisTick: false,
data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
}],
yAxis: [{
type: 'value',
axisLabel: {
color: 'rgba(255, 255, 255, 0.5)'
},
axisTick: false,
splitLine: {
lineStyle: {
color: 'rgba(255, 255, 255, 0.1)'
}
}
}],
series: [{
name: '邮件营销',
type: 'line',
smooth: true,
lineStyle: {
color: "#0184d5",
width: 3
},
areaStyle: {
color: new echarts.graphic.LinearGradient(
0,
0,
0,
1, [{
offset: 0,
color: "rgba(1, 132, 213, 0.4)"
},
{
offset: 0.8,
color: "rgba(1, 132, 213, 0.1)"
}
],
false
),
shadowColor: "rgba(0, 0, 0, 0.1)"
},
symbol: "circle",
symbolSize: 8,
itemStyle: {
color: "#0184d5",
borderColor: "rgba(221, 220, 107, .1)",
borderWidth: 12
},
showSymbol: false,
emphasis: {
focus: 'series'
},
data: [120, 132, 101, 134, 90, 230, 210]
},
{
name: '联盟广告',
type: 'line',
smooth: true,
lineStyle: {
normal: {
color: "#00d887",
width: 3
}
},
areaStyle: {
normal: {
color: new echarts.graphic.LinearGradient(
0,
0,
0,
1, [{
offset: 0,
color: "rgba(0, 216, 135, 0.4)"
},
{
offset: 0.8,
color: "rgba(0, 216, 135, 0.1)"
}
],
false
),
shadowColor: "rgba(0, 0, 0, 0.1)"
}
},
symbol: "circle",
symbolSize: 8,
itemStyle: {
color: "#00d887",
borderColor: "rgba(221, 220, 107, .1)",
borderWidth: 12
},
showSymbol: false,
emphasis: {
focus: 'series'
},
data: [220, 182, 191, 234, 290, 330, 310]
}
]
};
myChart.setOption(option);
window.addEventListener("resize", function() {
myChart.resize();
});
})();
|