echarts 常见组件合集

news2025/4/8 21:19:31

仪表盘组件

在这里插入图片描述

<template>
  <div class="w100 h100" ref="chart"></div>
</template>

<script>
import resize from "./mixins/resize";
export default {
  mixins: [resize],
  props: ["list"],
  watch: {
    list: {
      // 深度监听没有旧值
      handler(val) {
        var shiji = 60;
        var seriesData = [];

        seriesData.push({
          value: shiji,
          itemStyle: {
            color: new this.$echarts.graphic.LinearGradient(0, 0, 1, 0, [
              {
                offset: 0,
                color: "#ffffff",
              },
              {
                offset: 1,
                color: "yellow",
              },
            ]),
          },
        });
        let option = {
          series: [
            {},
            {
              detail: {
                show: true,
              },
              data: seriesData,
            },
            {
              endAngle: 220 - (260 * shiji) / 100,
            },
          ],
        };
        this.chart.setOption(option);
      },
      // 这里是关键,代表递归监听的变化
      deep: true,
    },
  },

  data() {
    return {
      chart: null,
    };
  },
  mounted() {
    this.$nextTick(() => {
      this.initChart(); // 体温
    });
  },
  beforeDestroy() {
    if (!this.chart) {
      return;
    }
    this.chart = null;
    clearInterval(this.timeId);
    this.timeId = null;
  },
  methods: {
    // 体温
    initChart() {
      this.chart = this.$echarts.init(this.$refs.chart);
      this.chart.setOption({
        tooltip: {
          show: false,
          trigger: "item",
          axisPointer: {
            type: "line",
          },
          formatter: "{b} : {c}",
          textStyle: {
            fontSize: 20,
          },
          borderWidth: 10,
        },
        series: [
          {
            name: "刻度",
            type: "gauge",
            center: ["50%", "50%"],
            radius: "82%",
            min: 0, //最小刻度
            max: 100, //最大刻度
            splitNumber: 4, //刻度数量
            startAngle: 220,
            endAngle: -40,
            axisLine: {
              show: true,
              lineStyle: {
                width: 10,
                color: [[1, "rgba(0,0,0,0)"]],
              },
            }, //仪表盘轴线
            axisLabel: {
              show: true,
              color: "#8D98A6",
              fontSize: 10,
              distance: 5,
            }, //刻度标签。
            axisTick: {
              show: true,
              splitNumber: 10,
              lineStyle: {
                color: new this.$echarts.graphic.LinearGradient(0, 0, 1, 0, [
                  {
                    offset: 0,
                    color: "#ee9003",
                  },
                  {
                    offset: 1,
                    color: "#00ffff",
                  },
                ]),
                width: 1,
                // length:10
              },
              length: 5,
            }, //刻度样式
            splitLine: {
              show: true,
              length: 0,
              lineStyle: {
                color: "#00ffff",
                width: 0,
              },
            }, //分隔线样式
          },
          {
            type: "gauge",
            radius: "100%",
            center: ["50%", "50%"],
            min: 0, //最小刻度
            max: 100, //最大刻度
            splitNumber: 0, //刻度数量
            startAngle: 220,
            endAngle: -40,
            axisLine: {
              show: true,
              lineStyle: {
                width: 10,
                color: [
                  [
                    1,
                    new this.$echarts.graphic.LinearGradient(0, 0, 1, 0, [
                      {
                        offset: 0,
                        color: "rgba(59,128,226,.2)",
                      },
                      {
                        offset: 1,
                        color: "rgba(59,128,226,.2)",
                      },
                    ]),
                  ],
                ],
              },
            },

            //分隔线样式。
            splitLine: {
              show: false,
            },
            axisLabel: {
              show: false,
            },
            axisTick: {
              show: false,
            },
            pointer: {
              show: true,
              length: "60%",
              width: "2%",
            },
            title: {
              show: false,
            },
            detail: {
              show: false,
              offsetCenter: [0, 30],
              color: "#00ffff",
              formatter: function (params) {
                return params + "%";
              },
              textStyle: {
                fontSize: this.fontSize(0.2),
                fontWeight: 700,
              },
            },
            // data: seriesData,
          },
          {
            type: "gauge",
            radius: "100%",
            center: ["50%", "50%"],
            min: 0, //最小刻度
            max: 100, //最大刻度
            splitNumber: 0, //刻度数量
            startAngle: 220,
            // endAngle: 220 - 260 * shiji / 100,
            axisLine: {
              show: true,
              lineStyle: {
                width: 10,
                color: [
                  [
                    1,
                    new this.$echarts.graphic.LinearGradient(0, 0, 1, 0, [
                      {
                        offset: 0,
                        color: "rgba(255, 51, 0, 1)",
                      },
                      {
                        offset: 0.5,
                        color: "rgba(254, 219, 101, 1)",
                      },
                      {
                        offset: 1,
                        color: "rgba(100, 222, 202, 1)",
                      },
                    ]),
                  ],
                ],
              },
            },

            //分隔线样式。
            splitLine: {
              show: false,
            },
            axisLabel: {
              show: false,
            },
            axisTick: {
              show: false,
            },
            pointer: {
              show: true,
              length: "60%",
              width: "2%",
            },
            title: {
              show: false,
            },
            detail: {
              show: true,
              offsetCenter: [0, 55],
              color: "#62ddc2",
              formatter: function (params) {
                return "参与战斗率";
              },
              textStyle: {
                fontSize: this.fontSize(0.12),
                fontWeight: 700,
              },
            },
            // data: seriesData,
          },
        ],
      });
    },
  },
};
</script>
<style lang="scss" scoped>
@import "./css/rem.scss";

.item {
  width: 33%;
}
</style>

立体柱状图——根据type更换颜色,数据大于6个自动切换

在这里插入图片描述

<template>
  <div class="w100 h100" ref="chart7"></div>
</template>
 
<script>
import resize from "./mixins/resize";
let color = [];
var color1 = ["rgba(47,102,192,.40)", "#00f562", "#a9f8c9"];
var color2 = ["rgba(47,102,192,.40)", "#f39800", "#f0e693"];

export default {
  mixins: [resize],
  props: ["list", "type"],
  watch: {
    list: {
      handler(val) {
        // const xAxisData = val.map(r => r.companyName); // x轴数据
        // const MAX = val.map(r => r.containCount); // 总人数
        // const VALUE = val.map(r => r.liveInCount); // 出勤人数
        const xAxisData = [
          "啥建档立卡九省联考解决解决",
          "1月订单-13",
          "1月订单-14",
          "1月订单-3",
          "1月订单-5",
          "1月订单-6",
        ];
        const MAX = [100, 100, 100, 100, 100, 100];
        const VALUE = [70 - 11, 70 - 13, 70 - 14, 70 - 3, 70 - 5, 70 - 6];

        // 深度监听没有旧值
        let option = {
          tooltip: {
            show: true,
            trigger: "axis", // 触发类型为坐标轴触发
          },
          xAxis: [
            {
              data: xAxisData,
            },
          ],
          series: [
            {
              data: MAX, // 总床位数
            },
            {
              data: VALUE, // 在住人数
            },
          ],
        };
        this.chart.setOption(option);
        if (xAxisData.length > this.maxNum) {
          let num = 0;
          if (!this.timeId) {
            this.timeId = setInterval(() => {
              if (num + this.maxNum == xAxisData.length) {
                num = 0;
              } else {
                num += 1;
              }

              let option = {
                dataZoom: [
                  {
                    startValue: num, // 从头开始。
                    endValue: num + this.maxNum - 1, // 一次性展示几个
                  },
                ],
              };
              this.chart.setOption(option);
            }, 2000);
          }
        }
        if (val && val.length) {
          // this.autoHover(this.chart, option, 6); // 参数分别为:容器,配置,轮播数量,轮播间隔时间
        }
      },
      // 这里是关键,代表递归监听的变化
      deep: true,
    },
  },

  data() {
    return {
      chart: null,
      timeTicket: null, //定时器
      maxNum: 6, // 一次性展示几个。
      timeId: null,
    };
  },
  mounted() {
    console.log(123);
    this.$nextTick(() => {
      this.initChart();
    });
  },
  beforeDestroy() {
    if (!this.chart) {
      return;
    }
    this.chart = null;
    clearInterval(this.timeId);
    this.timeId = null;
  },
  methods: {
    autoHover(myChart, option, num, time = 2000) {
      var count = 0; //计数器
      if (this.timeTicket) {
        clearInterval(this.timeTicket);
        this.timeTicket = null;
      }
      this.timeTicket = setInterval(function () {
        myChart.dispatchAction({
          type: "downplay",
          seriesIndex: 0, // serieIndex的索引值   可以触发多个
        });
        myChart.dispatchAction({
          type: "highlight",
          seriesIndex: 0,
          dataIndex: count,
        });
        myChart.dispatchAction({
          type: "showTip",
          seriesIndex: 0,
          dataIndex: count,
        });
        count++;
        if (count >= num) {
          count = 0;
        }
      }, time);
      // myChart.on("mouseover", function(params) {
      //   // clearInterval(this.timeTicket);
      //   myChart.dispatchAction({
      //     type: "downplay",
      //     seriesIndex: 0
      //   });
      //   myChart.dispatchAction({
      //     type: "highlight",
      //     seriesIndex: 0,
      //     dataIndex: params.dataIndex
      //   });
      //   myChart.dispatchAction({
      //     type: "showTip",
      //     seriesIndex: 0,
      //     dataIndex: params.dataIndex
      //   });
      // });

      // myChart.on("mouseout", function() {
      //   // this.timeTicket && clearInterval(this.timeTicket);
      //   this.timeTicket = setInterval(function() {
      //     myChart.dispatchAction({
      //       type: "downplay",
      //       seriesIndex: 0 // serieIndex的索引值   可以触发多个
      //     });
      //     myChart.dispatchAction({
      //       type: "highlight",
      //       seriesIndex: 0,
      //       dataIndex: count
      //     });
      //     myChart.dispatchAction({
      //       type: "showTip",
      //       seriesIndex: 0,
      //       dataIndex: count
      //     });
      //     count++;
      //     if (count >= 17) {
      //       count = 0;
      //     }
      //   }, 3000);
      // });
    },
    initChart() {
      this.chart = this.$echarts.init(this.$refs.chart7);
      const CubeLeft = this.$echarts.graphic.extendShape({
        shape: {
          x: 0,
          y: 0,
        },
        buildPath: function (ctx, shape) {
          const xAxisPoint = shape.xAxisPoint;
          const c0 = [shape.x, shape.y];
          const c1 = [shape.x - 9, shape.y - 9];
          const c2 = [xAxisPoint[0] - 9, xAxisPoint[1] - 9];
          const c3 = [xAxisPoint[0], xAxisPoint[1]];
          ctx
            .moveTo(c0[0], c0[1])
            .lineTo(c1[0], c1[1])
            .lineTo(c2[0], c2[1])
            .lineTo(c3[0], c3[1])
            .closePath();
        },
      });
      const CubeRight = this.$echarts.graphic.extendShape({
        shape: {
          x: 0,
          y: 0,
        },
        buildPath: function (ctx, shape) {
          const xAxisPoint = shape.xAxisPoint;
          const c1 = [shape.x, shape.y];
          const c2 = [xAxisPoint[0], xAxisPoint[1]];
          const c3 = [xAxisPoint[0] + 18, xAxisPoint[1] - 9];
          const c4 = [shape.x + 18, shape.y - 9];
          ctx
            .moveTo(c1[0], c1[1])
            .lineTo(c2[0], c2[1])
            .lineTo(c3[0], c3[1])
            .lineTo(c4[0], c4[1])
            .closePath();
        },
      });
      const CubeTop = this.$echarts.graphic.extendShape({
        shape: {
          x: 0,
          y: 0,
        },
        buildPath: function (ctx, shape) {
          const c1 = [shape.x, shape.y];
          const c2 = [shape.x + 18, shape.y - 9];
          const c3 = [shape.x + 9, shape.y - 18];
          const c4 = [shape.x - 9, shape.y - 9];
          ctx
            .moveTo(c1[0], c1[1])
            .lineTo(c2[0], c2[1])
            .lineTo(c3[0], c3[1])
            .lineTo(c4[0], c4[1])
            .closePath();
        },
      });
      this.$echarts.graphic.registerShape("CubeLeft", CubeLeft);
      this.$echarts.graphic.registerShape("CubeRight", CubeRight);
      this.$echarts.graphic.registerShape("CubeTop", CubeTop);
      let option = {
        color: this.type == 1 ? color1 : color2,
        legend: {
          show: true,
          type: "plain",
          top: 0,
          right: "5%",
          itemHeight: this.fontSize(0.13), //图例图标的高度
          itemWidth: this.fontSize(0.15), //图例图标的宽度
          itemGap: this.fontSize(0.23), //图例图标与文字间的间距
          orient: "horizontal",
          textStyle: {
            color: "rgba(255,255,255,0.7)",
            fontSize: this.fontSize(0.13), // 字体大小
          },
        },
        tooltip: {
          show: true,
          trigger: "axis", // 触发类型为坐标轴触发
          textStyle: {
            fontSize: this.fontSize(0.14), // 字体大小
          },
          formatter: function (params) {
            // console.log(params, 798789);
            let result = params[0].name + "<br>"; // 获取横轴对应的数据作为提示信息的标题
            params.forEach(function (item) {
              result += `${item.marker}${item.seriesName}${Math.abs(
                item.value
              )}<br>`;
              // + ' <br>' + + ': ' + formatNumber() + + ' ' // 对柱状图数据进行格式化
            });
            return result;
          },
          axisPointer: {
            type: "none",
          },
        },
        grid: {
          top: 50,
          bottom: 70,
          left: 60,
          right: 50,
          // containLabel: true,
        },
        dataZoom: [
          {
            xAxisIndex: 0, //这里是从X轴的0刻度开始
            show: false, //是否显示滑动条,不影响使用
            type: "inside", // 这个 dataZoom 组件是 slider 型 dataZoom 组件
            startValue: 0, // 从头开始。
            endValue: this.maxNum - 1, // 一次性展示几个
          },
        ],
        xAxis: {
          type: "category",
          // data: ["德州","德城区","陵城区","禹城市","乐陵市","临邑县","平原县","夏津县","武城县","庆云县","宁津县","齐河县"],
          axisLine: {
            show: true,
            lineStyle: {
              color: "#2384B1", //横轴颜色
              width: this.fontSize(0.02), //横轴粗细
            },
          },
          axisLabel: {
            interval: 0,
            rotate: 30,
            formatter: function (params) {
              var index = 7; // 当字符数超过6个时开始省略
              return params.length > index
                ? params.substring(0, index) + "..."
                : params;
            },
            textStyle: {
              color: "#fff", // 横坐标颜色
              fontSize: this.fontSize(0.12),
            },
          },
          // offset: 20,
          axisTick: {
            show: false,
            length: 9,
            alignWithLabel: true,
            lineStyle: {
              color: "#7DFFFD",
            },
          },
        },
        yAxis: {
          type: "value",
          // min: 0,
          minInterval: 1,
          // 网格线
          splitLine: {
            show: true,
            lineStyle: {
              color: "#023052",
              type: "dotted",
            },
          },
          axisLine: {
            show: false,
          },
          //坐标值标注
          axisLabel: {
            textStyle: {
              color: "#fff",
              fontSize: this.fontSize(0.15),
            },
            formatter: (value) => {
              return Math.abs(value);
            },
          },
        },
        series: [
          {
            name: this.type == 1 ? "总人数" : "总车辆数",
            type: "custom",
            renderItem: function (params, api) {
              const location = api.coord([api.value(0), api.value(1)]);
              return {
                type: "group",
                children: [
                  {
                    type: "CubeLeft",
                    shape: {
                      api,
                      xValue: api.value(0),
                      yValue: api.value(1),
                      x: location[0],
                      y: location[1],
                      xAxisPoint: api.coord([api.value(0), 0]),
                    },
                    style: {
                      fill: "rgba(47,102,192,.40)",
                    },
                  },
                  {
                    type: "CubeRight",
                    shape: {
                      api,
                      xValue: api.value(0),
                      yValue: api.value(1),
                      x: location[0],
                      y: location[1],
                      xAxisPoint: api.coord([api.value(0), 0]),
                    },
                    style: {
                      fill: "rgba(59,128,226,.40)",
                    },
                  },
                  {
                    type: "CubeTop",
                    shape: {
                      api,
                      xValue: api.value(0),
                      yValue: api.value(1),
                      x: location[0],
                      y: location[1],
                      xAxisPoint: api.coord([api.value(0), 0]),
                    },
                    style: {
                      fill: "rgba(72,156,221,.40)",
                    },
                  },
                ],
              };
            },
            // data: MAX,
          },
          {
            name: this.type == 1 ? "出勤人数" : "出勤车辆",
            type: "custom",
            renderItem: (params, api) => {
              const location = api.coord([api.value(0), api.value(1)]);
              return {
                type: "group",
                children: [
                  {
                    type: "CubeLeft",
                    shape: {
                      api,
                      xValue: api.value(0),
                      yValue: api.value(1),
                      x: location[0],
                      y: location[1],
                      xAxisPoint: api.coord([api.value(0), 0]),
                    },
                    style: {
                      fill: new this.$echarts.graphic.LinearGradient(
                        0,
                        0,
                        0,
                        1,
                        [
                          {
                            offset: 0,
                            color: this.type == 1 ? color1[1] : color2[1],
                          },
                          {
                            offset: 1,
                            color: this.type == 1 ? color1[2] : color2[2],
                          },
                        ]
                      ),
                    },
                  },
                  {
                    type: "CubeRight",
                    shape: {
                      api,
                      xValue: api.value(0),
                      yValue: api.value(1),
                      x: location[0],
                      y: location[1],
                      xAxisPoint: api.coord([api.value(0), 0]),
                    },
                    style: {
                      fill: new this.$echarts.graphic.LinearGradient(
                        0,
                        0,
                        0,
                        1,
                        [
                          {
                            offset: 0,
                            color: this.type == 1 ? color1[1] : color2[1],
                          },
                          {
                            offset: 1,
                            color: this.type == 1 ? color1[2] : color2[2],
                          },
                        ]
                      ),
                    },
                  },
                  {
                    type: "CubeTop",
                    shape: {
                      api,
                      xValue: api.value(0),
                      yValue: api.value(1),
                      x: location[0],
                      y: location[1],
                      xAxisPoint: api.coord([api.value(0), 0]),
                    },
                    style: {
                      fill: new this.$echarts.graphic.LinearGradient(
                        0,
                        0,
                        0,
                        1,
                        [
                          {
                            offset: 0,
                            color: this.type == 1 ? color1[1] : color2[1],
                          },
                          {
                            offset: 1,
                            color: this.type == 1 ? color1[2] : color2[2],
                          },
                        ]
                      ),
                    },
                  },
                ],
              };
            },
            // data: VALUE,
          },
        ],
      };
      this.chart.setOption(option);
    },
  },
};
</script>
<style lang="sass" scoped>
@import "./css/rem.scss"
</style>

立体柱状图——多色渐变底部波纹动画

在这里插入图片描述

let xData = ["2018年", "2019年", "2020年", "2021年"];

let color = [
  "rgba(253, 221, 97,  1)",
  "rgba(107, 255, 243,  1)",
  "rgba(119, 191, 255, 1)",
  "rgba(0, 72, 203,1)",
];
let data = [22, 33, 44, 55];

option = {
  backgroundColor: "#000",
  grid: {
    top: "5%",
    left: "10%",
    right: "9%",
    bottom: "40%",
  },

  xAxis: {
    offset: 20,
    data: xData,
    axisTick: {
      show: false,
    },
    axisLine: {
      show: false,
    },
    axisLabel: {
      textStyle: {
        color: "#fff",
        fontSize: 16,
      },
    },
  },
  yAxis: {
    splitLine: {
      show: false,
    },
    axisTick: {
      show: false,
    },
    axisLine: {
      show: false,
    },
    axisLabel: {
      show: false,
    },
  },
  series: [
    //'最低下的圆片',
    {
      name: "最低下的圆片",
      stack: "a",
      type: "effectScatter",
      symbolSize: [62, 12],
      symbolOffset: [0, 0],
      z: 22,
      data: [
        {
          name: "",
          value: "0",
          itemStyle: {
            normal: {
              color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                {
                  offset: 0,
                  color: "rgba(253, 221, 97,  1)",
                },
                {
                  offset: 1,
                  color: "rgba(251, 171, 88,   1)",
                },
              ]),
            },
          },
        },
        {
          name: "",
          value: "0",
          itemStyle: {
            normal: {
              color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                {
                  offset: 0,
                  color: "rgba(107, 255, 243,  1)",
                },
                {
                  offset: 1,
                  color: "rgba(8, 177, 255, 1)",
                },
              ]),
            },
          },
        },
        {
          name: "",
          value: "0",
          itemStyle: {
            normal: {
              color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                {
                  offset: 0,
                  color: "rgba(119, 191, 255, 1)",
                },
                {
                  offset: 1,
                  color: "rgba(102, 155, 255, 1)",
                },
              ]),
            },
          },
        },
        {
          name: "",
          value: "0",
          itemStyle: {
            normal: {
              color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                {
                  offset: 0,
                  color: "rgba(14, 195, 255, 1)",
                },
                {
                  offset: 1,
                  color: "rgba(0, 72, 203,  1)",
                },
              ]),
            },
          },
        },
      ],
    },
    //下半截柱状图
    {
      name: "下半截柱状图",
      stack: "a",
      type: "bar",
      barWidth: 66,
      z: 2,
      barGap: "-100%",
      data: [
        {
          name: "",
          value: data[0],
          itemStyle: {
            normal: {
              color: {
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                type: "linear",
                global: false,
                colorStops: [
                  {
                    //第一节下面
                    offset: 0,
                    color: "rgba(251, 171, 88, 0.8)",
                  },
                  {
                    offset: 1,
                    color: "rgba(253, 227, 100,0.8)",
                  },
                ],
              },
            },
          },
        },
        {
          name: "",
          value: data[1],
          itemStyle: {
            normal: {
              color: {
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                type: "linear",
                global: false,
                colorStops: [
                  {
                    //第二个柱状图下面

                    offset: 0,
                    color: "rgba(8, 177, 255, 0.8)",
                  },
                  {
                    offset: 1,
                    color: "rgba(107, 255, 243, 0.8)",
                  },
                ],
              },
            },
          },
        },
        {
          name: "",
          value: data[2],
          itemStyle: {
            normal: {
              color: {
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                type: "linear",
                global: false,
                colorStops: [
                  {
                    //第三个柱状图下半截
                    offset: 0,
                    color: "rgba(119, 191, 255, 0.8)",
                  },
                  {
                    offset: 1,
                    color: "rgba(102, 155, 255, 0.8)",
                  },
                ],
              },
            },
          },
        },
        {
          name: "",
          value: data[3],
          itemStyle: {
            normal: {
              color: {
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                type: "linear",
                global: false,
                colorStops: [
                  {
                    //第三个柱状图下半截
                    offset: 0,
                    color: "rgba(0, 72, 203,0.8)",
                  },
                  {
                    offset: 1,
                    color: "rgba(14, 195, 255, 0.8)",
                  },
                ],
              },
            },
          },
        },
      ],
    },
    //头部1
    {
      name: "头部1",
      stack: "a",
      type: "pictorialBar",
      symbolSize: [66, 12],
      symbolOffset: [0, -6],
      z: 22,
      data: [
        {
          name: "",
          value: data[0],
          symbolPosition: "end",
          label: {
            formatter: "{c} ",
            color: "#fff",
            offset: [0, -5],
            show: true,
            position: "top",
            fontSize: 18,
            fontWeight: 400,
            fontFamily: "zcool-gdh",
          },
          itemStyle: {
            normal: {
              color: new echarts.graphic.LinearGradient(
                0,
                0,
                0,
                1,
                [
                  {
                    offset: 0,
                    color: "rgba(251, 171, 88, 1)",
                  },
                  {
                    offset: 1,
                    color: "rgba(253, 227, 100,  1)",
                  },
                ],
                false
              ),
            },
          },
        },
        {
          name: "",
          value: data[1],
          symbolPosition: "end",
          label: {
            formatter: "{c}",
            color: "#fff",
            offset: [0, -5],
            show: true,
            position: "top",
            fontSize: 18,
            fontWeight: 400,
            fontFamily: "zcool-gdh",
          },
          itemStyle: {
            normal: {
              color: new echarts.graphic.LinearGradient(
                0,
                0,
                0,
                1,
                [
                  {
                    offset: 0,
                    color: "rgba(8, 177, 255,   1)",
                  },
                  {
                    offset: 1,
                    color: "rgba(107, 255, 243,    1)",
                  },
                ],
                false
              ),
            },
          },
        },
        {
          name: "",
          value: data[2],
          symbolPosition: "end",
          label: {
            formatter: "{c}",
            color: "#fff",
            offset: [0, -5],
            show: true,
            position: "top",
            fontSize: 18,
            fontWeight: 400,
            fontFamily: "zcool-gdh",
          },
          itemStyle: {
            normal: {
              color: new echarts.graphic.LinearGradient(
                0,
                0,
                0,
                1,
                [
                  {
                    offset: 0,
                    color: "rgba(119, 191, 255,  1)",
                  },
                  {
                    offset: 1,
                    color: "rgba(102, 155, 255,    1)",
                  },
                ],
                false
              ),
            },
          },
        },
        {
          name: "",
          value: data[3],
          symbolPosition: "end",
          label: {
            formatter: "{c}",
            color: "#fff",
            offset: [0, -5],
            show: true,
            position: "top",
            fontSize: 18,
            fontWeight: 400,
            fontFamily: "zcool-gdh",
          },
          itemStyle: {
            normal: {
              color: new echarts.graphic.LinearGradient(
                0,
                0,
                0,
                1,
                [
                  {
                    offset: 0,
                    color: "rgba(0, 72, 203,  1)",
                  },
                  {
                    offset: 1,
                    color: "rgba(14, 195, 255,  1)",
                  },
                ],
                false
              ),
            },
          },
        },
      ],
    },
  ],
};

自动滚动表格

在这里插入图片描述

<template>
  <dv-scroll-board :config="type == 1 ? config : type == 2 ? config1 : config2" ref="scrollBoard" class="w100 h100" />
</template>
<script>
export default {
  props: ["list", "type"],
  watch: {
    list: {
      handler(val) {
        console.log("list", val, this.type);
        if (this.type == 3) {

        }
      },
      // 这里是关键,代表递归监听的变化
      deep: true
    },

  },
  data() {
    return {
      config: {
        header: ['所在单位', '车辆名称', '车辆属性', '车牌号', '车辆状态'],
        data: [
          ['邗江支队', '50米水罐消防车', '水罐消防车', '苏K12345应急', '<span class="green1">正常</span>'],
          ['邗江支队', '50米水罐消防车', '水罐消防车', '苏K12345应急', '<span class="red1">维修</span>'],
          ['邗江支队', '50米水罐消防车', '水罐消防车', '苏K12345应急', '<span class="green1">正常</span>'],
          ['邗江支队', '50米水罐消防车', '水罐消防车', '苏K12345应急', '<span class="green1">正常</span>'],
        ],
        align: ['center', 'center', 'center', 'center', 'center', 'center'],
        rowNum: 7,
        evenRowBGC: 'rgba(33, 78, 133,.5)',
        oddRowBGC: 'transparent',
        headerBGC: '',
        headerHeight: '45'
      },
      config1: {
        header: ['所在单位', '人员姓名', '职位', '联系方式', '人员状态'],
        data: [
          ['邗江支队', '50米水罐消防车', '水罐消防车', '苏K12345应急', '<span class="green1">在岗</span>'],
          ['邗江支队', '50米水罐消防车', '水罐消防车', '苏K12345应急', '<span class="red1">其他</span>'],
          ['邗江支队', '50米水罐消防车', '水罐消防车', '苏K12345应急', '<span class="green1">在岗</span>'],
          ['邗江支队', '50米水罐消防车', '水罐消防车', '苏K12345应急', '<span class="yellow1">休假</span>'],
          ['邗江支队', '50米水罐消防车', '水罐消防车', '苏K12345应急', '<span class="blue1">出差</span>'],
          ['邗江支队', '50米水罐消防车', '水罐消防车', '苏K12345应急', '<span class="blue1">培训</span>'],
          ['邗江支队', '50米水罐消防车', '水罐消防车', '苏K12345应急', '<span class="green1">在岗</span>'],
          ['邗江支队', '50米水罐消防车', '水罐消防车', '苏K12345应急', '<span class="green1">在岗</span>'],
        ],
        align: ['center', 'center', 'center', 'center', 'center', 'center'],
        rowNum: 7,
        evenRowBGC: 'rgba(33, 78, 133,.5)',
        oddRowBGC: 'transparent',
        headerBGC: '',
        headerHeight: '45'
      },
      config2: {
        header: ['值班类型', '姓名', '联系电话'],
        data: [
          ['邗江支队', '50米水罐消防车', '水罐消防车'],
          ['邗江支队', '50米水罐消防车', '水罐消防车'],
          ['邗江支队', '50米水罐消防车', '水罐消防车'],
          ['邗江支队', '50米水罐消防车', '水罐消防车'],
        ],
        align: ['center', 'center', 'center'],
        rowNum: '',
        evenRowBGC: 'rgba(0, 238, 255, 0.123)',
        oddRowBGC: 'transparent',
        headerBGC: '',
        headerHeight: '40'
      },
    };
  },

  mounted() {

  },
  // 销毁定时器
  beforeDestroy() {
  },

  methods: {
    getTableData(arr) {
      this.config.data = arr;
      this.$refs['scrollBoard'].updateRows(arr, 0)
    },
  },
};
</script>
<style lang="scss" scoped>
@import "../components/css/rem.scss";

::v-deep.dv-scroll-board .header .header-item {
  // color: #f39800;
  // color: cyan;
  color: #6fddc2;
  font-weight: 700;
}

::v-deep.dv-scroll-board.solo .rows {
  border: 1px solid rgba(0, 238, 255, 0.123);
}

::v-deep.dv-scroll-board .green1,
::v-deep.dv-scroll-board .red1,
::v-deep.dv-scroll-board .yellow1,
::v-deep.dv-scroll-board .blue1 {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
}

::v-deep.dv-scroll-board .green1 {
  border: 1px solid cyan;
  background: rgba(0, 255, 255, .2);
}

::v-deep.dv-scroll-board .red1 {
  border: 1px solid rgb(250, 13, 84);
  background: rgba(250, 13, 84, .2);
}

::v-deep.dv-scroll-board .blue1 {
  border: 1px solid rgb(0, 89, 255);
  background: rgba(0, 89, 255, .2);
}

::v-deep.dv-scroll-board .yellow1 {
  border: 1px solid rgb(250, 213, 2);
  background: rgba(250, 213, 2, .2);
}
</style>

双折线图

在这里插入图片描述

<template>
  <div class="w100 h100" ref="chart"></div>
</template>

<script>
import resize from "./mixins/resize";
export default {
  mixins: [resize],
  props: ["list"],
  watch: {
    list: {
      // 深度监听没有旧值
      handler(val) {
        var shiji = 60;
        var seriesData = [];

        seriesData.push({
          value: shiji,
          itemStyle: {
            color: new this.$echarts.graphic.LinearGradient(0, 0, 1, 0, [
              {
                offset: 0,
                color: "#ffffff",
              },
              {
                offset: 1,
                color: "yellow",
              },
            ]),
          },
        });
        let option = {
          series: [
            {},
            {
              detail: {
                show: true,
              },
              data: seriesData,
            },
            {
              endAngle: 220 - (260 * shiji) / 100,
            },
          ],
        };
        this.chart.setOption(option);
      },
      // 这里是关键,代表递归监听的变化
      deep: true,
    },
  },

  data() {
    return {
      chart: null,
    };
  },
  mounted() {
    this.$nextTick(() => {
      this.initChart(); // 体温
    });
  },
  beforeDestroy() {
    if (!this.chart) {
      return;
    }
    this.chart = null;
    clearInterval(this.timeId);
    this.timeId = null;
  },
  methods: {
    // 体温
    initChart() {
      this.chart = this.$echarts.init(this.$refs.chart);
      this.chart.setOption({
        tooltip: {
          show: false,
          trigger: "item",
          axisPointer: {
            type: "line",
          },
          formatter: "{b} : {c}",
          textStyle: {
            fontSize: 20,
          },
          borderWidth: 10,
        },
        series: [
          {
            name: "刻度",
            type: "gauge",
            center: ["50%", "50%"],
            radius: "82%",
            min: 0, //最小刻度
            max: 100, //最大刻度
            splitNumber: 4, //刻度数量
            startAngle: 220,
            endAngle: -40,
            axisLine: {
              show: true,
              lineStyle: {
                width: 10,
                color: [[1, "rgba(0,0,0,0)"]],
              },
            }, //仪表盘轴线
            axisLabel: {
              show: true,
              color: "#8D98A6",
              fontSize: 10,
              distance: 5,
            }, //刻度标签。
            axisTick: {
              show: true,
              splitNumber: 10,
              lineStyle: {
                color: new this.$echarts.graphic.LinearGradient(0, 0, 1, 0, [
                  {
                    offset: 0,
                    color: "#ee9003",
                  },
                  {
                    offset: 1,
                    color: "#00ffff",
                  },
                ]),
                width: 1,
                // length:10
              },
              length: 5,
            }, //刻度样式
            splitLine: {
              show: true,
              length: 0,
              lineStyle: {
                color: "#00ffff",
                width: 0,
              },
            }, //分隔线样式
          },
          {
            type: "gauge",
            radius: "100%",
            center: ["50%", "50%"],
            min: 0, //最小刻度
            max: 100, //最大刻度
            splitNumber: 0, //刻度数量
            startAngle: 220,
            endAngle: -40,
            axisLine: {
              show: true,
              lineStyle: {
                width: 10,
                color: [
                  [
                    1,
                    new this.$echarts.graphic.LinearGradient(0, 0, 1, 0, [
                      {
                        offset: 0,
                        color: "rgba(59,128,226,.2)",
                      },
                      {
                        offset: 1,
                        color: "rgba(59,128,226,.2)",
                      },
                    ]),
                  ],
                ],
              },
            },

            //分隔线样式。
            splitLine: {
              show: false,
            },
            axisLabel: {
              show: false,
            },
            axisTick: {
              show: false,
            },
            pointer: {
              show: true,
              length: "60%",
              width: "2%",
            },
            title: {
              show: false,
            },
            detail: {
              show: false,
              offsetCenter: [0, 30],
              color: "#00ffff",
              formatter: function (params) {
                return params + "%";
              },
              textStyle: {
                fontSize: this.fontSize(0.2),
                fontWeight: 700,
              },
            },
            // data: seriesData,
          },
          {
            type: "gauge",
            radius: "100%",
            center: ["50%", "50%"],
            min: 0, //最小刻度
            max: 100, //最大刻度
            splitNumber: 0, //刻度数量
            startAngle: 220,
            // endAngle: 220 - 260 * shiji / 100,
            axisLine: {
              show: true,
              lineStyle: {
                width: 10,
                color: [
                  [
                    1,
                    new this.$echarts.graphic.LinearGradient(0, 0, 1, 0, [
                      {
                        offset: 0,
                        color: "rgba(255, 51, 0, 1)",
                      },
                      {
                        offset: 0.5,
                        color: "rgba(254, 219, 101, 1)",
                      },
                      {
                        offset: 1,
                        color: "rgba(100, 222, 202, 1)",
                      },
                    ]),
                  ],
                ],
              },
            },

            //分隔线样式。
            splitLine: {
              show: false,
            },
            axisLabel: {
              show: false,
            },
            axisTick: {
              show: false,
            },
            pointer: {
              show: true,
              length: "60%",
              width: "2%",
            },
            title: {
              show: false,
            },
            detail: {
              show: true,
              offsetCenter: [0, 55],
              color: "#62ddc2",
              formatter: function (params) {
                return "参与战斗率";
              },
              textStyle: {
                fontSize: this.fontSize(0.12),
                fontWeight: 700,
              },
            },
            // data: seriesData,
          },
        ],
      });
    },
  },
};
</script>
<style lang="scss" scoped>
@import "./css/rem.scss";

.item {
  width: 33%;
}
</style>

单条折线图

<template>
  <div class="w100 h100" ref="chart7"></div>
</template>
 
<script>
import resize from "./mixins/resize";
let color = [];
var color1 = ["rgba(47,102,192,.40)", "#00f562", "#a9f8c9"];
var color2 = ["rgba(47,102,192,.40)", "#f39800", "#f0e693"];

export default {
  mixins: [resize],
  props: ["list", "type"],
  watch: {
    list: {
      handler(val) {
        // const xAxisData = val.map(r => r.companyName); // x轴数据
        // const MAX = val.map(r => r.containCount); // 总人数
        // const VALUE = val.map(r => r.liveInCount); // 出勤人数
        const xAxisData = [
          "啥建档立卡九省联考解决解决",
          "1月订单-13",
          "1月订单-14",
          "1月订单-3",
          "1月订单-5",
          "1月订单-6",
        ];
        const MAX = [100, 100, 100, 100, 100, 100];
        const VALUE = [70 - 11, 70 - 13, 70 - 14, 70 - 3, 70 - 5, 70 - 6];

        // 深度监听没有旧值
        let option = {
          tooltip: {
            show: true,
            trigger: "axis", // 触发类型为坐标轴触发
          },
          xAxis: [
            {
              data: xAxisData,
            },
          ],
          series: [
            {
              data: MAX, // 总床位数
            },
            {
              data: VALUE, // 在住人数
            },
          ],
        };
        this.chart.setOption(option);
        if (xAxisData.length > this.maxNum) {
          let num = 0;
          if (!this.timeId) {
            this.timeId = setInterval(() => {
              if (num + this.maxNum == xAxisData.length) {
                num = 0;
              } else {
                num += 1;
              }

              let option = {
                dataZoom: [
                  {
                    startValue: num, // 从头开始。
                    endValue: num + this.maxNum - 1, // 一次性展示几个
                  },
                ],
              };
              this.chart.setOption(option);
            }, 2000);
          }
        }
        if (val && val.length) {
          // this.autoHover(this.chart, option, 6); // 参数分别为:容器,配置,轮播数量,轮播间隔时间
        }
      },
      // 这里是关键,代表递归监听的变化
      deep: true,
    },
  },

  data() {
    return {
      chart: null,
      timeTicket: null, //定时器
      maxNum: 6, // 一次性展示几个。
      timeId: null,
    };
  },
  mounted() {
    console.log(123);
    this.$nextTick(() => {
      this.initChart();
    });
  },
  beforeDestroy() {
    if (!this.chart) {
      return;
    }
    this.chart = null;
    clearInterval(this.timeId);
    this.timeId = null;
  },
  methods: {
    autoHover(myChart, option, num, time = 2000) {
      var count = 0; //计数器
      if (this.timeTicket) {
        clearInterval(this.timeTicket);
        this.timeTicket = null;
      }
      this.timeTicket = setInterval(function () {
        myChart.dispatchAction({
          type: "downplay",
          seriesIndex: 0, // serieIndex的索引值   可以触发多个
        });
        myChart.dispatchAction({
          type: "highlight",
          seriesIndex: 0,
          dataIndex: count,
        });
        myChart.dispatchAction({
          type: "showTip",
          seriesIndex: 0,
          dataIndex: count,
        });
        count++;
        if (count >= num) {
          count = 0;
        }
      }, time);
      // myChart.on("mouseover", function(params) {
      //   // clearInterval(this.timeTicket);
      //   myChart.dispatchAction({
      //     type: "downplay",
      //     seriesIndex: 0
      //   });
      //   myChart.dispatchAction({
      //     type: "highlight",
      //     seriesIndex: 0,
      //     dataIndex: params.dataIndex
      //   });
      //   myChart.dispatchAction({
      //     type: "showTip",
      //     seriesIndex: 0,
      //     dataIndex: params.dataIndex
      //   });
      // });

      // myChart.on("mouseout", function() {
      //   // this.timeTicket && clearInterval(this.timeTicket);
      //   this.timeTicket = setInterval(function() {
      //     myChart.dispatchAction({
      //       type: "downplay",
      //       seriesIndex: 0 // serieIndex的索引值   可以触发多个
      //     });
      //     myChart.dispatchAction({
      //       type: "highlight",
      //       seriesIndex: 0,
      //       dataIndex: count
      //     });
      //     myChart.dispatchAction({
      //       type: "showTip",
      //       seriesIndex: 0,
      //       dataIndex: count
      //     });
      //     count++;
      //     if (count >= 17) {
      //       count = 0;
      //     }
      //   }, 3000);
      // });
    },
    initChart() {
      this.chart = this.$echarts.init(this.$refs.chart7);
      const CubeLeft = this.$echarts.graphic.extendShape({
        shape: {
          x: 0,
          y: 0,
        },
        buildPath: function (ctx, shape) {
          const xAxisPoint = shape.xAxisPoint;
          const c0 = [shape.x, shape.y];
          const c1 = [shape.x - 9, shape.y - 9];
          const c2 = [xAxisPoint[0] - 9, xAxisPoint[1] - 9];
          const c3 = [xAxisPoint[0], xAxisPoint[1]];
          ctx
            .moveTo(c0[0], c0[1])
            .lineTo(c1[0], c1[1])
            .lineTo(c2[0], c2[1])
            .lineTo(c3[0], c3[1])
            .closePath();
        },
      });
      const CubeRight = this.$echarts.graphic.extendShape({
        shape: {
          x: 0,
          y: 0,
        },
        buildPath: function (ctx, shape) {
          const xAxisPoint = shape.xAxisPoint;
          const c1 = [shape.x, shape.y];
          const c2 = [xAxisPoint[0], xAxisPoint[1]];
          const c3 = [xAxisPoint[0] + 18, xAxisPoint[1] - 9];
          const c4 = [shape.x + 18, shape.y - 9];
          ctx
            .moveTo(c1[0], c1[1])
            .lineTo(c2[0], c2[1])
            .lineTo(c3[0], c3[1])
            .lineTo(c4[0], c4[1])
            .closePath();
        },
      });
      const CubeTop = this.$echarts.graphic.extendShape({
        shape: {
          x: 0,
          y: 0,
        },
        buildPath: function (ctx, shape) {
          const c1 = [shape.x, shape.y];
          const c2 = [shape.x + 18, shape.y - 9];
          const c3 = [shape.x + 9, shape.y - 18];
          const c4 = [shape.x - 9, shape.y - 9];
          ctx
            .moveTo(c1[0], c1[1])
            .lineTo(c2[0], c2[1])
            .lineTo(c3[0], c3[1])
            .lineTo(c4[0], c4[1])
            .closePath();
        },
      });
      this.$echarts.graphic.registerShape("CubeLeft", CubeLeft);
      this.$echarts.graphic.registerShape("CubeRight", CubeRight);
      this.$echarts.graphic.registerShape("CubeTop", CubeTop);
      let option = {
        color: this.type == 1 ? color1 : color2,
        legend: {
          show: true,
          type: "plain",
          top: 0,
          right: "5%",
          itemHeight: this.fontSize(0.13), //图例图标的高度
          itemWidth: this.fontSize(0.15), //图例图标的宽度
          itemGap: this.fontSize(0.23), //图例图标与文字间的间距
          orient: "horizontal",
          textStyle: {
            color: "rgba(255,255,255,0.7)",
            fontSize: this.fontSize(0.13), // 字体大小
          },
        },
        tooltip: {
          show: true,
          trigger: "axis", // 触发类型为坐标轴触发
          textStyle: {
            fontSize: this.fontSize(0.14), // 字体大小
          },
          formatter: function (params) {
            // console.log(params, 798789);
            let result = params[0].name + "<br>"; // 获取横轴对应的数据作为提示信息的标题
            params.forEach(function (item) {
              result += `${item.marker}${item.seriesName}${Math.abs(
                item.value
              )}<br>`;
              // + ' <br>' + + ': ' + formatNumber() + + ' ' // 对柱状图数据进行格式化
            });
            return result;
          },
          axisPointer: {
            type: "none",
          },
        },
        grid: {
          top: 50,
          bottom: 70,
          left: 60,
          right: 50,
          // containLabel: true,
        },
        dataZoom: [
          {
            xAxisIndex: 0, //这里是从X轴的0刻度开始
            show: false, //是否显示滑动条,不影响使用
            type: "inside", // 这个 dataZoom 组件是 slider 型 dataZoom 组件
            startValue: 0, // 从头开始。
            endValue: this.maxNum - 1, // 一次性展示几个
          },
        ],
        xAxis: {
          type: "category",
          // data: ["德州","德城区","陵城区","禹城市","乐陵市","临邑县","平原县","夏津县","武城县","庆云县","宁津县","齐河县"],
          axisLine: {
            show: true,
            lineStyle: {
              color: "#2384B1", //横轴颜色
              width: this.fontSize(0.02), //横轴粗细
            },
          },
          axisLabel: {
            interval: 0,
            rotate: 30,
            formatter: function (params) {
              var index = 7; // 当字符数超过6个时开始省略
              return params.length > index
                ? params.substring(0, index) + "..."
                : params;
            },
            textStyle: {
              color: "#fff", // 横坐标颜色
              fontSize: this.fontSize(0.12),
            },
          },
          // offset: 20,
          axisTick: {
            show: false,
            length: 9,
            alignWithLabel: true,
            lineStyle: {
              color: "#7DFFFD",
            },
          },
        },
        yAxis: {
          type: "value",
          // min: 0,
          minInterval: 1,
          // 网格线
          splitLine: {
            show: true,
            lineStyle: {
              color: "#023052",
              type: "dotted",
            },
          },
          axisLine: {
            show: false,
          },
          //坐标值标注
          axisLabel: {
            textStyle: {
              color: "#fff",
              fontSize: this.fontSize(0.15),
            },
            formatter: (value) => {
              return Math.abs(value);
            },
          },
        },
        series: [
          {
            name: this.type == 1 ? "总人数" : "总车辆数",
            type: "custom",
            renderItem: function (params, api) {
              const location = api.coord([api.value(0), api.value(1)]);
              return {
                type: "group",
                children: [
                  {
                    type: "CubeLeft",
                    shape: {
                      api,
                      xValue: api.value(0),
                      yValue: api.value(1),
                      x: location[0],
                      y: location[1],
                      xAxisPoint: api.coord([api.value(0), 0]),
                    },
                    style: {
                      fill: "rgba(47,102,192,.40)",
                    },
                  },
                  {
                    type: "CubeRight",
                    shape: {
                      api,
                      xValue: api.value(0),
                      yValue: api.value(1),
                      x: location[0],
                      y: location[1],
                      xAxisPoint: api.coord([api.value(0), 0]),
                    },
                    style: {
                      fill: "rgba(59,128,226,.40)",
                    },
                  },
                  {
                    type: "CubeTop",
                    shape: {
                      api,
                      xValue: api.value(0),
                      yValue: api.value(1),
                      x: location[0],
                      y: location[1],
                      xAxisPoint: api.coord([api.value(0), 0]),
                    },
                    style: {
                      fill: "rgba(72,156,221,.40)",
                    },
                  },
                ],
              };
            },
            // data: MAX,
          },
          {
            name: this.type == 1 ? "出勤人数" : "出勤车辆",
            type: "custom",
            renderItem: (params, api) => {
              const location = api.coord([api.value(0), api.value(1)]);
              return {
                type: "group",
                children: [
                  {
                    type: "CubeLeft",
                    shape: {
                      api,
                      xValue: api.value(0),
                      yValue: api.value(1),
                      x: location[0],
                      y: location[1],
                      xAxisPoint: api.coord([api.value(0), 0]),
                    },
                    style: {
                      fill: new this.$echarts.graphic.LinearGradient(
                        0,
                        0,
                        0,
                        1,
                        [
                          {
                            offset: 0,
                            color: this.type == 1 ? color1[1] : color2[1],
                          },
                          {
                            offset: 1,
                            color: this.type == 1 ? color1[2] : color2[2],
                          },
                        ]
                      ),
                    },
                  },
                  {
                    type: "CubeRight",
                    shape: {
                      api,
                      xValue: api.value(0),
                      yValue: api.value(1),
                      x: location[0],
                      y: location[1],
                      xAxisPoint: api.coord([api.value(0), 0]),
                    },
                    style: {
                      fill: new this.$echarts.graphic.LinearGradient(
                        0,
                        0,
                        0,
                        1,
                        [
                          {
                            offset: 0,
                            color: this.type == 1 ? color1[1] : color2[1],
                          },
                          {
                            offset: 1,
                            color: this.type == 1 ? color1[2] : color2[2],
                          },
                        ]
                      ),
                    },
                  },
                  {
                    type: "CubeTop",
                    shape: {
                      api,
                      xValue: api.value(0),
                      yValue: api.value(1),
                      x: location[0],
                      y: location[1],
                      xAxisPoint: api.coord([api.value(0), 0]),
                    },
                    style: {
                      fill: new this.$echarts.graphic.LinearGradient(
                        0,
                        0,
                        0,
                        1,
                        [
                          {
                            offset: 0,
                            color: this.type == 1 ? color1[1] : color2[1],
                          },
                          {
                            offset: 1,
                            color: this.type == 1 ? color1[2] : color2[2],
                          },
                        ]
                      ),
                    },
                  },
                ],
              };
            },
            // data: VALUE,
          },
        ],
      };
      this.chart.setOption(option);
    },
  },
};
</script>
<style lang="sass" scoped>
@import "./css/rem.scss"
</style>

饼状图——自动轮训

在这里插入图片描述

<template>
  <div class="w100 h100">
    <div class="w100 h100" ref="chart2Ref" />
  </div>
</template>

<script>
import resize from "./mixins/resize";
let color = [
  "#3f9eff",
  "#04c6c3",
  "#FCBB2A",
  "#8a78ff",
  "#1afcb0",
  "#FF6A7A",
  "#FF9337",
];
export default {
  mixins: [resize],
  props: ["list"],
  watch: {
    list: {
      handler(val) {
        let arr = val.map((item) => {
          return {
            name: item.date,
            value: item.sugarAfterMeal,
          };
        });
        let option = {
          title: {
            text: "起火原因统计(单位:起)", // 主标题文本内容
            textStyle: {
              color: "#fff", // 文本颜色
              fontSize: this.fontSize(0.16), // 字体大小
              fontWeight: "bold", // 字体粗细
            },
          },
          legend: {
            formatter: function (name) {
              // 根据name获取对应的series数据项
              var data = option.series[0].data.find(
                (item) => item.name === name
              );
              return `${name}  ${data.value}`;
            },
          },
          series: [
            {
              data: arr,
            },
          ],
        };
        this.pieChartData = arr;
        this.chart.setOption(option);
        // this.handleChartLoop(option)
      },
      // 这里是关键,代表递归监听的变化
      deep: true,
    },
  },
  data() {
    return {
      chart: null,
      timer: null,
      count: 0,
      total: 0,
      pieChartData: [],
    };
  },
  mounted() {
    this.$nextTick(() => {
      this.initChart();
    });
  },
  beforeDestroy() {
    if (!this.chart) {
      return;
    }
    this.chart.dispose();
    this.chart = null;
    clearInterval(this.timer);
    this.timer = null;
  },
  methods: {
    init() {},
    initChart() {
      this.chart = this.$echarts.init(this.$refs.chart2Ref);
      this.chart.clear(); // 每次清空上一次
      clearInterval(this.timer); // 首次渲染清空计时器
      this.timer = null;
      this.chart.resize();
      this.chart.setOption({
        color: color,
        tooltip: {
          trigger: "item",
          formatter: "{b} : {c} ({d}%)",
        },
        toolbox: {
          show: false,
        },

        legend: {
          show: true,
          type: "scroll",
          orient: "vertical", //horizontal
          right: "10%", // 设置图例在右侧
          top: "center",
          //   left: "center",
          // top: "right",
          itemWidth: 15,
          itemHeight: 14,

          textStyle: {
            color: "#fff",
          },
        },
        series: [
          {
            name: "",
            type: "pie",
            radius: ["45%", "65%"],
            center: ["40%", "50%"],
            // clockwise: false,
            data: this.list,
            label: {
              show: false,
              position: "center",
            },

            emphasis: {
              label: {
                show: true,
                fontSize: "30",
                fontWeight: "bold",
                formatter: ["{a|{d}%}", "{b|{b}}"].join("\n"),
                rich: {
                  a: {
                    // 中间字的数值样式
                    color: "#fff",
                    fontSize: this.fontSize(0.2),
                    lineHeight: 40,
                    verticalAlign: "bottom",
                  },
                  b: {
                    // 中间字的名称样式
                    color: "#fff",
                    // fontSize: "60%",
                    lineHeight: 28,
                    fontSize: this.fontSize(0.14),
                  },
                },
              },
            },
          },
        ],
      });

      // this.chart.setOption(option)
      this.dysnTime();
      this.chart.on("mouseover", (e) => {
        clearInterval(this.timer);
        this.timer = null;
        this.chart.dispatchAction({
          type: "downplay",
          seriesIndex: 0,
          dataIndex: this.count,
        });
        if (e.dataIndex === this.count) {
          this.chart.dispatchAction({
            type: "highlight", // 启动高亮
            seriesIndex: 0,
            dataIndex: this.count,
          });
        }
      });
      this.chart.on("mouseout", (e) => {
        this.dysnTime();
      });
    },
    dysnTime() {
      this.timer = setInterval(() => {
        this.chart.dispatchAction({
          type: "downplay", // 关闭高亮
          seriesIndex: 0,
          dataIndex: this.count,
        });
        this.count++;
        if (this.count === this.pieChartData.length) {
          this.count = 0;
        }
        this.chart.dispatchAction({
          type: "highlight", // 启动高亮
          seriesIndex: 0,
          dataIndex: this.count,
        });
      }, 2000);
    },
  },
};
</script>
<style lang="scss" scoped>
@import "./css/rem.scss";
</style>

堆叠柱状图

在这里插入图片描述

option = {
        // tooltip: {
        //   trigger: 'axis',
        //   axisPointer: {
        //     type: 'shadow'
        //   },
        //   formatter: function (params) {
        //     console.log(params, 6666)
        //     return params[0].seriesName + ':' + params[0].value + '~' + (params[0].value + params[1].value);
        //   }
        // },
        grid: {
          top: '8%',
          left: '5%',
          right: '5%',
          bottom: '3%',
          containLabel: true
        },
        dataZoom: [{
          type: 'inside', // 内置型数据区域缩放
          show: true,
          startValue: 0,
          endValue: 5,
        }],
        xAxis: {
          type: 'category',
          splitLine: {
            show: false
          },
          data: this.data.time
        },
        yAxis: {
          type: 'value',
          min: 40,
        },
        series: [{
            name: '舒张压范围',
            type: 'bar',
            stack: 'Total',
            barWidth: 10,
            itemStyle: {
              borderColor: 'transparent',
              color: 'transparent'
            },
            data: this.data.low1
          },
          {
            name: '',
            type: 'bar',
            stack: 'Total',
            barWidth: 10,
            label: {
              // show: true,
              position: 'inside'
            },
            itemStyle: {
              color: '#2bdc70', // 设置整个系列柱子的颜色为蓝色
              barBorderRadius: 10 // 设置所有柱子的圆角半径为10px
            },
            data: this.data.high1
          },
          {
            name: '收缩压范围',
            type: 'bar',
            stack: 'Total1',
            barWidth: 10,
            itemStyle: {
              borderColor: 'transparent',
              color: 'transparent',
            },
            data: this.data.low2
          },
          {
            name: '',
            type: 'bar',
            stack: 'Total1',
            barWidth: 10,
            label: {
              // show: true,
              position: 'inside'
            },
            itemStyle: {
              color: '#fa5151', // 设置整个系列柱子的颜色为蓝色
              barBorderRadius: 10 // 设置所有柱子的圆角半径为10px
            },
            data: this.data.high2
          }
        ]
      };

散点图 —— 带背景色

在这里插入图片描述

let color = ["#36ceff", "#3ddb68", "#fcdc01", "#f5c577", "#ff7e00", "#f90102"]
option = {
        color: color,
        tooltip: {
          show: false,
        },
        legend: {
          bottom: "0",
          width: '80%',
          itemWidth: 10,
          itemHeight: 10,
          data: [{
              name: "血压水平偏低",
              icon: "roundRect",
            },
            {
              name: "血压水平正常",
              icon: "roundRect",
            },
            {
              name: "血压水平偏高",
              icon: "roundRect",
            },
            {
              name: "1级高血压",
              icon: "roundRect",
            },
            {
              name: "2级高血压",
              icon: "roundRect",
            },
            {
              name: "3级高血压",
              icon: "roundRect",
            },
          ],
        },
        grid: {
          left: "25",
          right: "20",
          bottom: "80",
          top: "30",
          containLabel: true,
        },
        xAxis: [{
          type: "value",
          name: "收缩压(mmHg)",
          nameLocation: "middle",
          nameGap: 30,
          boundaryGap: false,
          splitLine: {
            show: false,
          },
          axisTick: {
            show: false,
          },
          min: 60,
          max: 260
        }, ],
        yAxis: [{
          type: "value",
          name: "舒张压(mmHg)",
          nameLocation: "end",
          splitLine: {
            show: false,
          },
          axisTick: {
            show: false,
          },
          min: 40,
          max: 160
        }, ],
        series: [{
            type: "line",
            name: "血压水平偏低",
            symbol: "none",
            lineStyle: {
              normal: {
                width: 0,
                color: color[0],
              },
            },
            areaStyle: {
              normal: {
                color: color[0],
              },
            },
            z: 10,
            connectNulls: true,
            data: [
              [0, 60],
              [85, 60],
            ],
          },
          {
            type: "line",
            name: "血压水平正常",
            symbol: "none",
            lineStyle: {
              normal: {
                width: 0,
                color: color[1],
              },
            },
            areaStyle: {
              normal: {
                color: color[1],
              },
            },
            itemStyle: {},
            z: 9,
            connectNulls: true,
            step: true,
            data: [
              [0, 80],
              [120, 80],
            ],
          },
          {
            type: "line",
            name: "血压水平偏高",
            symbol: "none",
            lineStyle: {
              normal: {
                width: 0,
                color: color[2],
              },
            },
            areaStyle: {
              normal: {
                color: color[2],
              },
            },
            z: 8,
            data: [
              [0, 90],
              [140, 90],
            ],
          },
          {
            type: "line",
            name: "1级高血压",
            symbol: "none",
            lineStyle: {
              normal: {
                width: 0,
                color: color[3],
              },
            },
            areaStyle: {
              normal: {
                color: color[3],
              },
            },
            z: 7,
            data: [
              [0, 100],
              [160, 100],
            ],
          },
          {
            type: "line",
            name: "2级高血压",
            symbol: "none",
            lineStyle: {
              normal: {
                width: 0,
                color: color[4],
              },
            },
            areaStyle: {
              normal: {
                color: color[4],
              },
            },
            z: 6,
            data: [
              [0, 110],
              [180, 110],
            ],
          },
          {
            type: "line",
            name: "3级高血压",
            symbol: "none",
            lineStyle: {
              normal: {
                width: 0,
                color: color[5],
              },
            },
            areaStyle: {
              normal: {
                color: color[5],
              },
            },
            z: 5,
            data: [
              [0, 160],
              [260, 160],
            ],
          },
          {
            type: "scatter",
            symbol: "circle",
            symbolSize: 5,
            itemStyle: {
              normal: {
                color: "#000",
              },
            },
            z: 20,
            data: this.properties.list
          },
        ],
      };

饼状图——带边框的圆角,5.0以上版本,但是不兼容vue2

在这里插入图片描述

option = {
  tooltip: {
    trigger: 'item'
  },
  legend: {
    top: '5%',
    left: 'center'
  },
  series: [
    {
      name: 'Access From',
      type: 'pie',
      radius: ['40%', '70%'],
      avoidLabelOverlap: false,
      itemStyle: {
        borderRadius: 10,
        borderColor: '#fff',
        borderWidth: 2
      },
      label: {
        show: false,
        position: 'center'
      },
      emphasis: {
        label: {
          show: true,
          fontSize: 40,
          fontWeight: 'bold'
        }
      },
      labelLine: {
        show: false
      },
      data: [
        { value: 1048, name: 'Search Engine' },
        { value: 735, name: 'Direct' },
        { value: 580, name: 'Email' },
        { value: 484, name: 'Union Ads' },
        { value: 300, name: 'Video Ads' }
      ]
    }
  ]
};

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2260906.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

C/C++代码性能优化技巧的书籍及资料

使用C/C开发的场景&#xff0c;大多对代码的执行的速度&#xff0c;实时性有较高的要求&#xff0c;像嵌入式系统的开发&#xff0c;资源还受限。在算力存储空间有限的MCU上写出简洁又高效的代码实际是一种艺术。软件工程师在代码设计上的这种差距&#xff0c;会反映在产品的性…

FlightAD 解读

一 文章相关信息 出处&#xff1a;ICPADS CCF C 会议&#xff08;代码未开源&#xff09;&#xff0c;COUTA 研究团队的另一研究 二 Methodology 1. 整体架构&#xff1a; 2. Multi-Scale Sampling&#xff08;多尺度&#xff09; 实际上&#xff0c;就是对每个单通道作 “多…

20241216软考架构-------软考案例23答案

每日打卡题案例23 23.【2015年真题】 难度&#xff1a;一般 阅读以下关于系统设计建模的说明&#xff0c;回答下列问题。&#xff08;共25分&#xff09; 【说明】 某公司拟研制一款高空监视无人直升机&#xff0c;该无人机采用遥控一自主复合型控制实现垂直升降。该直升机飞行…

170页ppt解读如何进行大型集团信息安全管理体系优化咨询

文档为甲方集团信息安全管理体系优化咨询项目的信息安全建设规划报告&#xff0c;重点围绕信息安全建设的规划与设计展开。报告首先进行了信息安全建设需求分析&#xff0c;明确了当前信息安全现况存在的问题、信息安全发展趋势及具体需求汇整&#xff0c;为后续建设提供了坚实…

RK3576 Android14,内存大于4G时UVC应用无法申请内存

最近有个项目需要将Linux虚拟成UVC摄像头&#xff0c;开发过程中遇到一个奇怪的事情&#xff0c;通过V4l2框架接口申请内存时&#xff0c;相同的板子&#xff0c;只是内存一个4G一个8G。4G的内存可以申请成功&#xff0c;8G就不行。提示“内存不足” 内存更大反而内存不足&…

TimesFM(Time Series Foundation Model)时间序列预测股市价格的数据研究(4)

TimesFM&#xff08;Time Series Foundation Model&#xff09;时间序列预测的数据研究(3)-CSDN博客文章浏览阅读846次&#xff0c;点赞19次&#xff0c;收藏12次。1. **表示预测区间**&#xff1a;在很多预测任务中&#xff0c;模型给出的不只是一个单一的预测值&#xff08;比…

opencv所有常见函数

一、opencv图像操作 二、opencv图像的数值运算 三、opencv图像的放射变换 四、opencv空间域图像滤波 五、图像灰度化与直方图 六、形态学图像处理 七、阈值处理与边缘检测 八、轮廓和模式匹配

常见漏洞—SSRF_FastCGI

FastCGI协议 简介 Fast CGI源自旧版本的CGI 路由/结构图 # 访问url --> 浏览器生成HTTP请求报文 --> web server解析请求&#xff08;例如nginx&#xff09; web server 是内容的分发者 当访问静态页面时&#xff0c;web server 会直接返回资源&#xff0c;例如index.htm…

【游戏设计原理】10 - 科斯特的游戏理论

科斯特的游戏理论强调了游戏与学习之间的关系&#xff0c;认为“玩得开心”与“学习”是紧密相连的。换句话说&#xff0c;游戏的核心魅力在于通过适当的挑战和不断的学习进程激发玩家的内啡肽循环&#xff0c;这让玩家在不断的探索和进步中找到乐趣。 科斯特的理论通过游戏是…

ES-IndexTemplate和DynamicTemplate

IndexTemplate 什么是IndexTemplate 索引模板&#xff0c;帮助你设定Mappings和Settings&#xff0c;并按照一定的规则&#xff0c;自动匹配到新创建的索引之上 模板仅在一个索引被新建的时候&#xff0c;才会产生应用&#xff0c;索引被修改不会影响已创建的索引可以设定多…

【大语言模型】ACL2024论文-27 Mementos:一个全面的多模态大型语言模型在图像序列推理上的基准测试

【大语言模型】ACL2024论文-27 Mementos&#xff1a;一个全面的多模态大型语言模型在图像序列推理上的基准测试 目录 文章目录 【大语言模型】ACL2024论文-27 Mementos&#xff1a;一个全面的多模态大型语言模型在图像序列推理上的基准测试目录文章摘要研究背景问题与挑战如何…

CSS基础与应用详解

​&#x1f308;个人主页&#xff1a;前端青山 &#x1f525;系列专栏&#xff1a;Css篇 &#x1f516;人终将被年少不可得之物困其一生 依旧青山,本期给大家带来Css篇专栏内容:CSS基础与应用详解 前言 CSS&#xff08;层叠样式表&#xff09;是网页设计中不可或缺的一部分&am…

C/S软件授权注册系统(Winform+WebApi+.NET8+EFCore版)

适用软件&#xff1a;C/S系统、Winform桌面应用软件。 运行平台&#xff1a;Windows .NETCore&#xff0c;.NET8 开发工具&#xff1a;Visual Studio 2022&#xff0c;C#语言 数据库&#xff1a;Microsoft SQLServer 2012&#xff0c;Oracle 21c&#xff0c;MySQL8&#xf…

国标GB28181网页直播平台EasyGBS国标EasyGBD对讲音频demo

近年来&#xff0c;随着信息技术的飞速发展&#xff0c;视频监控领域正经历从传统安防向智能化、网络化安防的深刻转变。在此过程中&#xff0c;GB28181标准凭借其强大的功能和灵活性&#xff0c;成为了推动视频监控系统互联互通和高效管理的重要一环。通过支持GB28181协议&…

session 共享服务器

1.安装 kryo-3.0.3.jar asm-5.2.jar objenesis-2.6.jar reflectasm-1.11.9.jar minlog-1.3.1.jar kryo-serializers-0.45.jar msm-kryo-serializer-2.3.2.jar memcached-session-manager-tc9-2.3.2.jar spymemcached-2.12.3.jar memcached-session-manager-2.3.2.jar …

【蓝桥杯国赛真题15】python质因数个数 蓝桥杯青少年组python编程国赛真题详细解析

目录 python质因数个数 一、题目要求 1、编程实现 2、输入输出 二、算法分析 三、程序编写 四、程序说明 五、运行结果 六、考点分析 七、 推荐资料 1、蓝桥杯比赛 2、考级资料 3、其它资料 python质因数个数 第十二届蓝桥杯青少年组python比赛国赛真题详细解析 …

智能硬件「百团大战」:AI驱动的周期来了吗?

要想在竞争激烈的市场中打造出真正的AI硬件“爆款”&#xff0c;并非简单地在现有硬件上堆砌AI功能就能实现&#xff0c;而是需要深刻理解AI的本质&#xff0c;用AI技术从底层逻辑出发&#xff0c;彻底重塑硬件产品的设计、功能与用户体验。 作者|斗斗 编辑|皮爷 出品|产…

Linux核心概念与常用命令

文章目录 一、Linux概述1、常见的操作系统2、Linux发展史3、Linux目录结构 二、文件和目录操作1、pwd - 显示当前目录2、cd - 切换目录3、ls - 列出目录内容4、mkdir - 创建目录5、touch - 创建空文件6、cp - 复制文件或目录7、mv - 移动或重命名文件8、rm - 删除文件或目录9、…

uniappp配置导航栏自定义按钮(解决首次加载图标失败问题)

1.引入iconfont的图标&#xff0c;只保留这两个文件 2.App.vue引入到全局中 import "./static/fonts/iconfont.css"3.pages.json中配置text为图标对应的unicode {"path": "pages/invite/invite","style": {"h5": {"…

vue组件开发:构建响应式快捷导航

前言 快捷导航不仅能够显著提升系统的灵活性和用户交互性&#xff0c;还极大地增强了用户的操作体验。本文将展示如何在 vue 中实现一个既可自定义又具备响应式特性的快捷导航菜单。 一、实现思路 列表页 结构设计 定义页面结构&#xff0c;包含一个导航卡片和一个对话框组件&a…