Highcharts可拖动列和单击设置值

时间:2018-05-21 23:21:53

标签: angular typescript highcharts angular5

我想创建我的图表,可以选择在点击和拖动后设置值。拖拽可以工作,但点击事件使问题变得复杂,因为拖拽然后变得疯狂,因为它在移动之前移除了点。

我的活动代码。在那里我尝试先删除现有点,然后添加新值

events: {
          click: function (e) {
            // find the clicked values and the series
            let x = Math.round(e.xAxis[0].value),
              y = Math.round(e.yAxis[0].value),
              series = this.series[0];

            console.log("values",x,y,series);

            // Add it
            if(e.yAxis[0].value <= 16){
              series.data[x].remove();
              series.addPoint([x, y]);

            }
          }
        }

draggable来自插件。

1 个答案:

答案 0 :(得分:1)

我解决了这个问题:

events: {
          click: function (e) {
            // find the clicked values and the series
            let x = Math.round(e.xAxis[0].value),
              y = Math.round(e.yAxis[0].value),
              series = this.series[0];

            console.log("values",x,y,series);

            // Add it
            if(e.yAxis[0].value <= 16){
              series.data[x].update(y);

            }
          }
        }