城阳工作端uniH5前端代码
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.

116 lines
2.6 KiB

10 months ago
<template>
<!-- pages/information/information.wxml -->
<view class="containers">
<ec-canvas data canvas-id="mychart-line" :ec="ec" style="width: 100%; height: 500rpx"></ec-canvas>
</view>
</template>
<script>
import ecCanvas from '@/ec-canvas/ec-canvas';
import * as echarts from '../../static/echarts.js';
10 months ago
function initChart(canvas, width, height, dpr) {
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: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
// 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 default {
components: {
ecCanvas
},
data() {
return {
ec: {
onInit: initChart
}
};
},
onShareAppMessage: function (res) {
return {
title: 'ECharts 可以在微信小程序中使用啦!',
path: '/pages/index/index',
success: function () {},
fail: function () {}
};
},
onLoad() {
console.log(this.initChart);
},
onReady() {},
methods: {}
};
</script>
<style>
/* pages/information/information.wxss */
.containers {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
}
</style>