//data是传进来的数据
function charts(data) {
var myChart = echarts.init(document.getElementById('main'));
option = {
width: '650px',
height: '410px',
title: {
text: '这是标题',
right: '20%',
top: 10,
//副标题
subtext: data.subtext,
subtextStyle: {
color: '#000',
align: 'center',
verticalAlign: 'top',
},
textAlign: 'center',
},
tooltip: {
trigger: 'axis'
},
legend: {
bottom: '0%',
data: ['横坐标', '纵坐标']
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
toolbox: {
feature: {
saveAsImage: {}
}
},
//x轴坐标
xAxis: {
type: 'category',
boundaryGap: false,
},
//y轴坐标
yAxis: {
type: 'value',
name: '纵坐标名称',
nameLocation: 'middle',
nameGap: '20'
},
series: [{
name: '折线图的名称',
//图的类型
type: 'line',
//平滑的折线
smooth: true,
//折线拐点的大小
symbolSize: 10,
//折线拐点的类型
symbol: 'star',
//数据
data: data.line,
},
{
symbolSize: 20,
name: '点图的名称',
data: data.spot,
//散点图
type: 'scatter',
symbolSize: 8,
},
],
};
myChart.setOption(option);
}
echarts——折线图、散点图、拐点类型、拐点大小
最新推荐文章于 2023-10-22 21:06:24 发布