You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
1.6 KiB
71 lines
1.6 KiB
10 months ago
|
import * as echarts from '../../ec-canvas/echarts';
|
||
|
function initLineChart(canvas, width, height, dpr, xData) {
|
||
|
const chart = echarts.init(canvas, null, {
|
||
|
width: width,
|
||
|
height: height,
|
||
|
devicePixelRatio: dpr // new
|
||
|
});
|
||
|
|
||
|
canvas.setChart(chart);
|
||
|
var option = {
|
||
|
title: {
|
||
|
text: '线状图',
|
||
|
left: 'center'
|
||
|
},
|
||
|
legend: {
|
||
|
data: ['A', 'B', 'C'],
|
||
|
top: 30,
|
||
|
left: 'center',
|
||
|
z: 100
|
||
|
},
|
||
|
grid: {
|
||
|
containLabel: true
|
||
|
},
|
||
|
tooltip: {
|
||
|
show: true,
|
||
|
trigger: 'axis'
|
||
|
},
|
||
|
xAxis: {
|
||
|
type: 'category',
|
||
|
boundaryGap: false,
|
||
|
data: xData
|
||
|
// show: false
|
||
|
},
|
||
|
|
||
|
yAxis: {
|
||
|
x: 'center',
|
||
|
type: 'value',
|
||
|
splitLine: {
|
||
|
lineStyle: {
|
||
|
type: 'dashed'
|
||
|
}
|
||
|
}
|
||
|
// show: false
|
||
|
},
|
||
|
|
||
|
series: [
|
||
|
{
|
||
|
name: 'A',
|
||
|
type: 'line',
|
||
|
smooth: true,
|
||
|
data: [18, 36, 65, 30, 78, 40, 33]
|
||
|
},
|
||
|
{
|
||
|
name: 'B',
|
||
|
type: 'line',
|
||
|
smooth: true,
|
||
|
data: [12, 50, 51, 35, 70, 30, 20]
|
||
|
},
|
||
|
{
|
||
|
name: 'C',
|
||
|
type: 'line',
|
||
|
smooth: true,
|
||
|
data: [10, 30, 31, 50, 40, 20, 10]
|
||
|
}
|
||
|
]
|
||
|
};
|
||
|
chart.setOption(option);
|
||
|
return chart;
|
||
|
}
|
||
|
export { initLineChart };
|