美酒没故事° 2020-07-17 16:04 采纳率: 37.8%
浏览 668
已采纳

vue中echarts柱状图怎么让其中的柱可以拖动?

如图:


vue中echarts柱状图怎么让其中的柱可以拖动?

  • 写回答

2条回答 默认 最新

  • 美酒没故事° 2021-09-26 16:56
    关注

    img

    // 电量调整试算器 - 鼠标事件:拖动
        mouseEvents() {
          let histogram = this.$refs.histogram;
          const that = this;
    
          this.testChart.on("mousedown", function (params) {
            console.log("按下:", params);
            that.moveValue.oldPrice = params.seriesName;
            /* histogram.style.backgroundColor = params.color;
            histogram.style.width = params.event.target.shape.width + "px";
            histogram.style.height = Math.abs(params.event.target.shape.height) + "px"; */
            histogram.style.display = "block";
            histogram.style.top = params.event.offsetY + "px";
            histogram.style.left = params.event.offsetX + "px";
            that.testDialogTitle.start = params.seriesName.slice(0, 1);
            that.testDialogTitle.startBg = params.color;
            that.startMoveIndex = params.seriesIndex + 1;
            if (that.testType === "electric") {
              that.moveValue.electricMax = params.data[params.seriesIndex + 1];
            } else {
              that.moveValue.loadMax = params.data[params.seriesIndex + 1];
              that.moveValue.timeMax = 12; // 赋假数据
            }
          });
          this.testChart.on("mousemove", function (params) {
            // console.log("移动:", params);
            histogram.style.top = params.event.offsetY + "px";
            histogram.style.left = params.event.offsetX + "px";
          });
          this.testChart.on("mouseup", function (params) {
            console.log("松开:", params);
            that.moveValue.nowPrice = params.seriesName;
            that.testDialogTitle.end = params.seriesName.slice(0, 1);
            that.testDialogTitle.endBg = params.color;
            if (that.testDialogTitle.start === params.seriesName.slice(0, 1)) {
              // that.$message.warning("调节错误!");
            } else {
              that.endMoveIndex = params.seriesIndex + 1;
              that.dialogVisible = true;
              that.moveValue.electric = 0;
              that.moveValue.load = 0;
              that.moveValue.time = 0;
            }
            histogram.style.display = "none";
            // let pattern = /[1-9][0-9]*([.][0-9]+)/g;
            that.moveValue.oldPrice = parseFloat(
              that.moveValue.oldPrice.replace(/[^\d.]/g, "")
            );
            that.moveValue.nowPrice = parseFloat(
              that.moveValue.nowPrice.replace(/[^\d.]/g, "")
            );
            console.log(that.moveValue.oldPrice, that.moveValue.nowPrice);
          });
        },
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 已采纳回答 9月26日

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站