This commit is contained in:
sakuya 2021-04-27 23:18:07 +08:00
parent 15c4f643c4
commit 4c3f7b4815
4 changed files with 193 additions and 40 deletions

View File

@ -0,0 +1,59 @@
const T = {
"color": [
"#409EFF",
"#36CE9E",
"#E6A23C",
"#626c91",
"#F56C6C",
"#909399"
],
'grid': {
'left': '3%',
'right': '3%',
'bottom': '3%',
'top': '40',
'containLabel': true
},
"categoryAxis": {
"axisLine": {
"show": true,
"lineStyle": {
"color": "#999"
}
},
"axisTick": {
"show": false,
"lineStyle": {
"color": "#333"
}
},
"splitLine": {
"show": true,
"lineStyle": {
"color": [
"#eee"
]
}
},
"splitArea": {
"show": false,
"areaStyle": {
"color": [
"rgba(255,255,255,0.01)",
"rgba(0,0,0,0.01)"
]
}
}
},
"valueAxis": {
"axisLine": {
"show": false,
"lineStyle": {
"color": "#999"
}
},
}
}
export default T

View File

@ -0,0 +1,37 @@
<template>
<div ref="scEcharts" :style="{height:height, width:width}"></div>
</template>
<script>
import * as echarts from 'echarts';
import T from './echarts-theme-T.js';
echarts.registerTheme('T', T);
export default {
name: "scEcharts",
props: {
height: { type: String, default: "100%" },
width: { type: String, default: "100%" },
nodata: {type: Boolean, default: false },
option: { type: Object, default: () => {} }
},
data() {
return {}
},
computed: {
myOptions: function() {
return this.option || {};
}
},
mounted(){
this.draw();
},
methods: {
draw(){
let myChart = echarts.init(this.$refs.scEcharts, 'T');
myChart.setOption(this.myOptions);
window.addEventListener('resize', () => myChart.resize() );
}
}
}
</script>

View File

@ -1,15 +1,85 @@
<template> <template>
<el-skeleton /> <div v-loading="loading">
<scEcharts height="300px" :option="option"></scEcharts>
</div>
</template> </template>
<script> <script>
import scEcharts from '@/components/scEcharts';
export default { export default {
title:"模块1", title:"模块1",
props: { components: {
msg: String scEcharts
}, },
mounted(){ data() {
console.log("加载C1"); return {
loading: true,
option: {}
}
},
created() {
var _this = this;
setTimeout(function() {
_this.loading = false
}, 500);
var option = {
tooltip: {
trigger: 'axis'
},
legend: {
data: ['支出', '收入'],
right: 13,
},
xAxis: {
boundaryGap: false,
data: ['周一', '周二', '周三', '周四', '周五', '周六'],
},
yAxis: [{
type: 'value',
name: '价格',
"splitLine": {
"show": false
}
}],
series: [{
name: '支出',
type: 'line',
symbolSize: 6,
smooth: true,
lineStyle: {
normal: {
shadowColor: 'rgba(0,0,0,0.2)',
shadowBlur: 15,
shadowOffsetY: 20
}
},
'areaStyle': {
'opacity': 0.2
},
data: [35, 10, 36, 5, 5, 20],
},
{
name: '收入',
type: 'line',
symbolSize: 6,
smooth: true,
lineStyle: {
normal: {
shadowColor: 'rgba(0,0,0,0.2)',
shadowBlur: 15,
shadowOffsetY: 20
}
},
'areaStyle': {
'opacity': 0.2
},
data: [15, 15, -25, 20, 20, 8],
},
],
};
this.option = option;
} }
} }
</script> </script>

View File

@ -1,41 +1,30 @@
<template> <template>
<div v-loading="loading"> <div v-loading="loading">
<div style="height: 200px" ref="demo"></div> <scEcharts height="220px" :option="option"></scEcharts>
</div> </div>
</template> </template>
<script> <script>
import * as echarts from 'echarts'; import scEcharts from '@/components/scEcharts';
import T from '@/utils/echarts-theme-T.js';
echarts.registerTheme('T', T);
export default { export default {
title:"模块3", title:"模块3",
components: { components: {
echarts scEcharts
},
props: {
msg: String
}, },
data() { data() {
return { return {
loading: true loading: true,
option: {}
} }
}, },
mounted(){ created() {
var _this = this; var _this = this;
setTimeout(function() { setTimeout(function() {
_this.loading = false _this.loading = false
}, 500); }, 500);
const myChart = echarts.init(this.$refs.demo, 'T'); var option = {
const option = {
grid: {
top: 50,
right: 20,
bottom: 30,
left: 30,
},
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
axisPointer: { axisPointer: {
@ -43,33 +32,31 @@
} }
}, },
legend: { legend: {
data: ['预购队列', '最新成交价'], data: ['支出', '收入'],
right: 13, right: 13,
}, },
xAxis: { xAxis: {
data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子'], data: ['周一', '周二', '周三', '周四', '周五'],
}, },
yAxis: [ yAxis: [{
{ type: 'value',
type: 'value', name: '价格',
name: '价格', }, ],
}, series: [{
], name: '支出',
series: [ barWidth: '20%',
{
name: '预购队列',
barWidth: 16,
type: 'bar', type: 'bar',
data: [5, 20, 36, 10, 10, 20], data: [5, 20, 36, 10, 10],
}, },
{ {
name: '最新成交价', name: '收入',
type: 'line', type: 'bar',
data: [15, 20, 16, 20, 30, 8], barWidth: '20%',
data: [15, 20, 16, 20, 30],
}, },
], ],
}; };
myChart.setOption(option); this.option = option;
} }
} }
</script> </script>