样式优化添加echarts

ds1.0
fanluyan 2 years ago
parent c50d9597a0
commit a8c6a339c5

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,337 @@
<template>
<div class="echartsBox">
<div class="gropName">
<el-checkbox-group v-model="checkList">
<el-checkbox
v-for="item in qtOption"
:label="item.groupName"
:key="item.groupName"
><span v-if="item.groupName == 'H2'">{{ item.groupName }}()</span>
<span v-if="item.groupName == 'CO'"
>{{ item.groupName }}(一氧化碳)</span
>
<span v-if="item.groupName == 'CH4'">{{ item.groupName }}()</span>
<span v-if="item.groupName == 'C2H4'"
>{{ item.groupName }}(乙烯)</span
>
<span v-if="item.groupName == 'C2H6'"
>{{ item.groupName }}(乙烷)</span
>
<span v-if="item.groupName == 'C2H2'"
>{{ item.groupName }}(乙炔)</span
></el-checkbox
>
</el-checkbox-group>
</div>
<div id="demo1"></div>
<div id="demo2"></div>
<div id="demo3"></div>
</div>
</template>
<script>
import axios from "axios";
export default {
name: "",
data() {
return {
checkList: [], //
qtOption: [], //
myChart: "",
xData1: [], //
lineData1: [], //
yMax1: "", //y
xData2: [], //
lineData2: [], //
yMax2: "", //y
xData3: [], //
lineData3: [], //
yMax3: "", //y
};
},
created() {
this.getMenuData1();
this.getMenuData2();
this.getMenuData3();
},
mounted() {},
watch: {},
methods: {
//1
getMenuData1() {
axios
.get("/aa.json")
.then((res) => {
console.log("getMenuData", res);
// this.qtOption = res.data.config.channels[0].crests;//
// console.log(this.qtOption);
this.lineData1 = res.data.data[0]; //
this.yMax1 = res.data.config.yMax; //y
var timeSpan = 1; //
for (
var i = 0;
i < res.data.config.numberOfData * timeSpan;
i = i + timeSpan
) {
console.log(i);
this.xData1.push(i);
}
//
this.getEchart1();
})
.catch((error) => {
console.log(error);
});
},
//2
getMenuData2() {
axios
.get("/bb.json")
.then((res) => {
this.lineData2 = res.data.data[0]; //
this.yMax2 = res.data.config.yMax; //y
var timeSpan = 1; //
for (
var i = 0;
i < res.data.config.numberOfData * timeSpan;
i = i + timeSpan
) {
console.log(i);
this.xData2.push(i);
}
//
this.getEchart2();
})
.catch((error) => {
console.log(error);
});
},
//3
getMenuData3() {
axios
.get("/cc.json")
.then((res) => {
this.lineData3 = res.data.data[0]; //
this.yMax3 = res.data.config.yMax; //y
var timeSpan = 1; //
for (
var i = 0;
i < res.data.config.numberOfData * timeSpan;
i = i + timeSpan
) {
console.log(i);
this.xData3.push(i);
}
//
this.getEchart3();
})
.catch((error) => {
console.log(error);
});
},
//
getEchart1() {
this.$nextTick(() => {
let that = this;
that.myChart = this.$echarts.init(document.getElementById("demo1"));
let option = {
title: {
text: "图表一",
left: "center",
},
tooltip: {
trigger: "axis",
axisPointer: {
animation: false,
},
},
dataZoom: [
{
type: "inside",
start: 0,
end: 100,
},
{
start: 0,
end: 100,
},
],
xAxis: {
type: "category",
data: this.xData1, // x
boundaryGap: false,
showMaxLabel: true,
},
yAxis: {
type: "value",
// min: 20000,
//max: this.yMax1,
},
series: [
{
data: this.lineData1,
type: "line",
smooth: true,
symbol: "none",
sampling: "lttb",
itemStyle: {
color: "rgb(255, 70, 131)",
},
},
],
};
that.myChart.setOption(option);
window.addEventListener("resize", () => {
that.myChart.resize();
});
});
},
//
getEchart2() {
this.$nextTick(() => {
let that = this;
that.myChart = this.$echarts.init(document.getElementById("demo2"));
let option = {
title: {
text: "图表二",
left: "center",
},
tooltip: {
trigger: "axis",
axisPointer: {
animation: false,
},
},
dataZoom: [
{
type: "slider",
start: 0,
end: 100,
},
{
start: 0,
end: 100,
},
],
xAxis: {
type: "category",
data: this.xData2, // x
boundaryGap: false,
showMaxLabel: true,
},
yAxis: {
type: "value",
// min: 20000,
// max: this.yMax2,
},
series: [
{
data: this.lineData2,
type: "line",
smooth: true,
symbol: "none",
sampling: "lttb",
itemStyle: {
color: "rgb(255, 70, 131)",
},
},
],
};
that.myChart.setOption(option);
window.addEventListener("resize", () => {
that.myChart.resize();
});
});
},
//
getEchart3() {
this.$nextTick(() => {
let that = this;
that.myChart = this.$echarts.init(document.getElementById("demo3"));
let option = {
title: {
text: "图表三",
left: "center",
},
tooltip: {
trigger: "axis",
axisPointer: {
animation: false,
},
},
dataZoom: [
{
type: "inside",
start: 0,
end: 100,
},
{
start: 0,
end: 100,
},
],
xAxis: {
type: "category",
data: this.xData3, // x
boundaryGap: false,
showMaxLabel: true,
},
yAxis: {
type: "value",
boundaryGap: [0, "100%"],
// min: 20000,
//max: this.yMax3,
},
series: [
{
data: this.lineData3,
type: "line",
showAllSymbol: true,
smooth: true,
symbol: "none",
sampling: "lttb",
itemStyle: {
color: "rgb(255, 70, 131)",
},
},
],
};
that.myChart.setOption(option);
window.addEventListener("resize", () => {
that.myChart.resize();
});
});
},
},
};
</script>
<style lang="less">
.echartsBox {
height: calc(100% - 32px);
padding: 16px;
display: flex;
flex-direction: column;
// justify-content: space-around;
#demo1,
#demo2,
#demo3 {
height: 400px;
width: 80%;
}
.gropName {
.el-checkbox-group {
display: flex;
flex-direction: column;
.el-checkbox {
height: 40px;
line-height: 40px;
}
}
}
}
</style>

@ -132,6 +132,12 @@ const routes = [
import(/* webpackChunkName: "tabs" */ "../views/waterMark/index.vue"),
meta: { title: "水印下发", icon: "" },
},
{
path: "/echarts",
component: () =>
import(/* webpackChunkName: "tabs" */ "../echartsDemo.vue"),
meta: { title: "echarts图表", icon: "" },
},
],
},

Loading…
Cancel
Save