<template>
  <div class="app-container home">
    <h1 style="text-align: center ;color: #0072c6 ; font-size: 50px;font-weight: bold"> Ⅷ  智汇车联 </h1>
    <h2 style="text-align: right ;color: #1f2d3d; font-size: 20px">开发小组:八组</h2>

    <div>
      <el-chart :options="chartOptions"></el-chart>
    </div>

    <div style="height: 400px">
      <el-row>
        <el-col :span="6" v-for="module in modules" :key="module.id">
          <div class="big-module" @click="navigateToPage(module.pageUrl)">
            {{ module.content }}
          </div>
        </el-col>
      </el-row>
    </div>

  </div>
</template>

<script>
import { Chart as Echarts } from 'echarts';
import 'echarts-gl';
import { ElChart } from 'element-ui';
//引入 echarts
import echarts from 'echarts'

export default {
  components: {
    ElChart
  },
  data() {
    return {
      modules: [
        { id: 1, content: '车辆系统管理', pageUrl: '/car/information' },
        { id: 2, content: '车辆故障管理', pageUrl: '/page2-url' },
        { id: 3, content: '电子围栏管理', pageUrl: '/page3-url' },
        { id: 4, content: '车辆预警管理', pageUrl: '/page4-url' }
      ],
      myChart: '',
      chartOptions(){
        opinionData2: [
          { value: 1, name: '在线车辆', itemStyle: '#1FC48D' },
          { value: 45, name: '离线车辆', itemStyle: '#e77e46' },
          { value: 3, name: '故障车辆', itemStyle: '#3F8FFF' }
        ]
      }

    };

  },
  mounted() {
    // 初始化图表
    this.drawLine();
  },
  methods: {
    navigateToPage(url) {
      this.$router.push(url);
    },
    drawLine () {
      this.myChart = this.$echarts.init(document.getElementById('myChart'))
      this.myChart.setOption({
        title: {
          text: '车辆分析', // 主标题
            x: 'left' // x轴方向对齐方式
        },
        grid: { containLabel: true },
        tooltip: {
          trigger: 'item',
          formatter: '{a} <br/>{b} : {d}%'
        },
        // color: ['#1FC48D', '#F5A60A', '#6DC8EC', '#3F8FFF'],
        color: ['#1FC48D', '#e77e46', '#3F8FFF'],
        // backgroundColor: '#ffffff',
        legend: {
          orient: 'vertical',
          icon: 'circle',
          align: 'left',
          x: 'right',
          y: 'bottom',
          data: ['在线车辆','离线车辆','故障车辆']
        },   series: [
          {
            name: '课堂行为',
            type: 'pie',
            radius: ['50%', '70%'],
            avoidLabelOverlap: false,
            center: ['40%', '50%'],
            itemStyle: {
              emphasis: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              },
              color: function (params) {
                // 自定义颜色
                var colorList = ['#1FC48D', '#e77e46', '#3F8FFF']
                return colorList[params.dataIndex]
              }
            },
            data: this.opinionData2
          }
        ]
      })
    }
  }
};
</script>

<style lang="scss" scoped>
.big-module {
  height: 250px;
  background-color: #8492a6;
  text-align: center;
  line-height: 250px;
  margin: 20px;
  font-weight: bold;
  color: white;
  font-size: 20px;
}
.home {
  blockquote {
    padding: 10px 20px;
    margin: 0 0 20px;
    font-size: 17.5px;
    border-left: 5px solid #eee;
  }

  hr {
    margin-top: 20px;
    margin-bottom: 20px;
    border: 0;
    border-top: 1px solid #eee;
  }

  .col-item {
    margin-bottom: 20px;
  }

  ul {
    padding: 0;
    margin: 0;
  }

  font-family: "open sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: #676a6c;
  overflow-x: hidden;

  ul {
    list-style-type: none;
  }

  h4 {
    margin-top: 0px;
  }

  h2 {
    margin-top: 10px;
    font-size: 26px;
    font-weight: 100;
  }

  p {
    margin-top: 10px;

    b {
      font-weight: 700;
    }
  }

  .update-log {
    ol {
      display: block;
      list-style-type: decimal;
      margin-block-start: 1em;
      margin-block-end: 1em;
      margin-inline-start: 0;
      margin-inline-end: 0;
      padding-inline-start: 40px;
    }
  }
}
</style>

