美酒没故事° 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日

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog