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

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日

悬赏问题

  • ¥15 CST2023安装报错
  • ¥15 使用diffusionbert生成文字 结果是PAD和UNK怎么办
  • ¥15 有人懂怎么做大模型的客服系统吗?卡住了卡住了
  • ¥20 firefly-rk3399上启动卡住了
  • ¥15 如何删除这个虚拟音频
  • ¥50 hyper默认的default switch
  • ¥15 网站打不开,提示502 Bad Gateway
  • ¥20 基于MATLAB的绝热压缩空气储能系统代码咨询
  • ¥15 R语言建立随机森林模型出现的问题
  • ¥15 中级微观经济学,生产可能性边界问题