简单的分时图

<template>
  <div class="market-linechart">
    <e-charts
      :options="deptChartOption"
      style="width:100%;height:100%"
    ></e-charts>
  </div>
</template>

<script>
import ECharts from "vue-echarts/components/ECharts";
require("echarts/lib/chart/line");
require("echarts/lib/component/tooltip");
require("echarts/lib/component/legendScroll");
export default {
  components: { ECharts },
  props: {
    chartlist: Array
  },

  data() {
    return {
      deptChartOption: {},

      dateList: [],
      valueList: []
    };
  },
  mounted() {
    this.$nextTick(() => {
      this.init();
    });
  },
  watch: {
    chartlist(value) {
      console.log(value);
      this.init();
    }
  },
  methods: {
    init() {
      this.dateList = this.chartlist.map(item => {
        return item.split("|")[5] - 0;
      });
      this.valueList = this.chartlist.map(item => {
        return item.split("|")[3] - 0;
      });

      this.deptChartOption = {
        // Make gradient line here

        visualMap: [
          {
            show: false,
            type: "continuous",
            seriesIndex: 0,
            dimension: 0,
            min: 0,
            max: this.dateList.length - 1
          }
        ],

        xAxis: [
          {
            type: "category",
            boundaryGap: false,
            axisLine: { onZero: false },
            data: this.dateList,
            show: false
          }
        ],
        yAxis: [
          {
            type: "value",
            scale: true,
            show: false
          }
        ],
        grid: {
          top: 0,
          left: 0,
          right: 0,
          bottom: 0,
          containLabel: false
        },

        series: [
          {
            type: "line",
            animation: false,
            symbol: "none",
            lineStyle: {
              width: 1
            },
            color: "#357ce1",
            areaStyle: {
              color: new ECharts.graphic.LinearGradient(0, 0, 0, 1, [
                {
                  offset: 0,
                  color: "#90b3f4"
                },
                {
                  offset: 1,
                  color: "#f1f3fd"
                }
              ])
            },
            data: this.valueList
          }
        ]
      };
    }
  }
};
</script>

<style lang="scss">
.market-line-chart {
}
</style>
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容