123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- <!--
- * @Author: your name
- * @Date: 2021-10-08 17:24:29
- * @LastEditTime: 2021-12-21 10:07:31
- * @LastEditors: Please set LastEditors
- * @Description: 存栏结构 - 存栏变动折线图
- * @FilePath: \hyyfClient\src\views\PdcData\analysis\ChartInventoryLines.vue
- -->
- <template>
- <div class="chart-inventory-lines">
- <div id="chartElecLines"></div>
- </div>
- </template>
- <script>
- export default {
- data() {
- return {
- myChart: null,
- };
- },
- props: {
- data: {
- type: Object,
- required: true,
- default: () => ({}),
- },
- },
- methods: {
- init() {
- let flag = "";
- if (this.data.month.length === 0) {
- flag = "暂无数据";
- }
- let options = {
- title: {
- text: "近七日重量统计",
- x: 30,
- y: 15,
- subtext: flag,
- },
- tooltip: {
- trigger: "axis",
- },
- // legend: {
- // data: ['头']
- // },
- color: ["#3aa0ff", "#4dcb73", "#fad337", "#f2637b", "#975fe4"],
- grid: {
- top: "20%",
- left: "10%",
- bottom: "10%",
- right: "10%",
- },
- xAxis: [
- {
- type: "category",
- // name: "月",
- data: this.data.month,
- axisPointer: {
- type: "shadow",
- },
- axisLine: {
- show: true,
- lineStyle: {
- color: "#6e7079",
- },
- },
- axisTick: {
- show: true,
- },
- },
- ],
- //[
- yAxis: {
- type: "value",
- name: "kg",
- // axisLabel: {
- // formatter: '{value} °C'
- // },
- axisLine: {
- show: true,
- lineStyle: {
- color: "#6e7079",
- },
- },
- axisTick: {
- show: false,
- },
- splitLine: {
- show: false,
- },
- },
- // {
- // type: 'value',
- // name: '湿度',
- // axisLabel: {
- // formatter: '{value} RH'
- // },
- // axisLine: {
- // show: false,
- // lineStyle: {
- // color: '#6e7079',
- // }
- // },
- // axisTick:{
- // show:false
- // },
- // // splitLine:{
- // // show:false
- // // }
- // }
- //],
- series: [
- {
- name: "重量",
- type: "line",
- smooth: false,
- data: this.data.elecList,
- itemStyle: {
- normal: {
- color: "#3aa0ff",
- lineStyle: {
- color: "#3aa0ff",
- },
- },
- },
- },
- // {
- // name: '湿度',
- // type: 'line',
- // smooth: false,
- // yAxisIndex: 1,
- // data: [20, 22, 33, 45, 63, 102, 23, 24, 23, 65, 50, 62]
- // }
- ],
- };
- this.myChart.setOption(options);
- },
- },
- mounted() {
- this.myChart = this.$echarts.init(
- document.getElementById("chartElecLines")
- );
- this.init();
- },
- watch: {
- data: {
- handler(newValue) {
- console.log(newValue);
- this.init();
- },
- deep: true,
- },
- },
- };
- </script>
- <style scoped>
- .chart-inventory-lines {
- /* display: inline-block; */
- width: 100%;
- height: 100%;
- }
- #chartElecLines {
- width: 100%;
- height: 100%;
- }
- </style>
|