123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- <template>
- <el-row>
- <div id="index4" ref="echartD" style="width:110%;margin-left:-5%;height:110%;"></div>
- </el-row>
- </template>
- <script>
- import * as echarts from "echarts";
- export default {
- props: ["resData"],
- data() {
- return {};
- },
- watch: {
- resData() {
- this.getData();
- }
- },
- mounted() {
- this.getData();
- },
- methods: {
- getData() {
- let myChart = echarts.init(document.getElementById("index4"));
- let data = this.resData;
- let option = {
- legend: {
- itemGap: 20, // 图例每项之间的间隔。
- icon: "stack",
- right: 40,
- top:6,
- padding: 0, // 图例内边距
- textStyle: {
- color: "#000",
- align: "center"
- }
- },
- title: {
- x:'center',
- text: data[2].name,
- textStyle:{ //设置主标题风格
- color:data[2].color,//设置主标题字体颜色
- },
- },
- tooltip: {
- trigger: "axis",
- confine: true,
- textStyle: {
- fontSize: 12
- }
- },
- color: ["#FF0087" , "#80FFA5" ],
- xAxis: {
- show:true,//false
- boundaryGap:false,// true | ['30%', '20%'],x轴两边是否留白,true留白,false不留白
- axisLabel:{//x坐标轴刻度标签
- show:true,
- color:'#ccc',//'#ccc',设置标签颜色
- // rotate: -45,
- },
- axisLine:{//x坐标轴轴线
- show:true,
- lineStyle:{//x坐标轴轴线样式
- color:'#ccc',//'#ccc' | 'rgb(128, 128, 128)' | 'rgba(128, 128, 128, 0.5)',设置标签颜色
- }
- },
- data:data[3]
- },
- yAxis: [{
- // min:0, //取0为最小刻度
- // max: 100,
- name:"无\n线\n信\n号",
- type: 'value',
- splitLine:{
- show:false
- },
- nameLocation: 'left',
- nameTextStyle: {
- fontSize: 14,
- padding: [0, 80, 0, 0]
- },
- axisLine: {
- lineStyle: {
- type: 'solid' ,
- color: '#FF0087' , //左边线的颜色
- width: '1' //坐标线的宽度
- }
- },
- axisLabel: {
- textStyle: {
- color: '#FF0087' , //坐标值得具体的颜色
- }
- },
- }, {
- // min:0, //取0为最小刻度
- // max: 5,
- name:"剩\n余\n电\n量",
- type: 'value',
- splitLine:{
- show:false
- },
- nameLocation: 'left',
- nameTextStyle: {
- fontSize: 14,
- padding: [0, 0, 0, 80]
- },
- axisLine: {
- lineStyle: {
- type: 'solid' ,
- color: '#80FFA5' , //左边线的颜色
- width: '1' //坐标线的宽度
- }
- },
- axisLabel: {
- textStyle: {
- color: '#80FFA5' , //坐标值得具体的颜色
- }
- },
- }],
- series: [{
- name: "信号",
- type: 'line',
- stack: 'Total',
- smooth: true,
- axisLine: {
- lineStyle: {
- color: 'red',
- width: 0, //这里是为了突出显示加上的
- }
- },
- areaStyle: {
- opacity: 0.8,
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
- {
- offset: 0,
- color: 'rgb(128, 255, 165)'
- },
- {
- offset: 1,
- color: 'rgb(1, 191, 236)'
- }
- ])
- },
- showSymbol: false,
- emphasis: {
- focus: 'series'
- },
- data: data[1],
- yAxisIndex: 0, // 通过这个判断左右
- }, {
- name: "剩余电量",
- type: 'line',
- stack: 'Total',
- smooth: true,
- axisLine: {
- lineStyle: {
- color: '#ccc',
- width: 0, //这里是为了突出显示加上的
- }
- },
- areaStyle: {
- opacity: 0.8,
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
- {
- offset: 0,
- color: 'rgb(255, 0, 135)'
- },
- {
- offset: 1,
- color: 'rgb(135, 0, 157)'
- }
- ])
- },
- showSymbol: false,
- emphasis: {
- focus: 'series'
- },
- data: data[0],
- yAxisIndex: 1,
- }]
- };
- myChart.setOption(option);
- window.addEventListener("resize", function() {
- myChart.resize();
- });
- }
- }
- };
- </script>
- <style lang="scss" scoped></style>
|