Plotly.js: Dragging point on a line chart

Created on 30 Mar 2017  路  11Comments  路  Source: plotly/plotly.js

Is it possible in plotly.js to drag points to change their location (vertically) in a line chart similar to draggable points in highcharts (http://www.highcharts.com/plugin-registry/single/3/Draggable%20Points)

Thanks.

Most helpful comment

I'm not sure how this would jive with the overall design/mission of plotly.js, but I think a drag-and-drop event for elements would be a fantastic addition, not just in line charts.

Use cases:

  • data entry
  • especially for surveys
  • network plots
  • ...

All 11 comments

You can probably do this using plotly_click and restyle. But no, we don't expose that functionality at a high-level similar to what Highcharts does at the moment.

I'm not sure how this would jive with the overall design/mission of plotly.js, but I think a drag-and-drop event for elements would be a fantastic addition, not just in line charts.

Use cases:

  • data entry
  • especially for surveys
  • network plots
  • ...

I'm not sure how this would jive with the overall design/mission of plotly.js,

Probably not to be honest. At least, not in the foreseeable future.

Closing this issue (for now).

This feature would take plotly to a whole new level!

I'm late to the party here, but for anyone else who needs this functionality ...

Draggable points are certainly possibly with the current version of Plotly, you just build on d3.behavior.drag(). The only problem is that Plotly by default disables mouse pointer events on the SVG paths that make up the plot points, but you can override that with a line of CSS. I have a working demo here with a brief explanation of the CSS trick. Full source code here.

Hello @niclasmattsson, thank you very much for your working demo and explanation. It was really helpful for me. But there is one problem with your demo. It is doen't work on IE 11/EDGE browsers. May be you have solution for that browsers?

I needed draggable points in an Electron app (i.e. Chromium only) so didn't test my code on Microsoft's browsers. But I think I found the problem. Apparently SVG attributes have comma-separated coordinates in Firefox & Chrome but Microsoft just has to do its own thing and uses space-separation.

So in the function startDragBehavior(), change this line:

var translate = transform.substring(10, transform.length-1).split(",");

to this:

var translate = transform.substring(10, transform.length-1).split(/,| /);

That should work with either comma or space separation. I fixed it in the Gist, so just reload my demo to get the fixed version which seems to work in Edge. I'm not gonna bother with IE, too much of a headache. :)

@niclasmattsson, thank you very much. Yes, now it works on EDGE, but there is performance issue with all browsers except Chrome. Especially in EDGE. Did you faced with this problem?

UPD: I found another example. There is a pure D3-based drag-and-drop example on page: https://bl.ocks.org/denisemauldin/538bfab8378ac9c3a32187b4d7aed2c2
How do you think, Is plotly is a reason of performance issue?

any plans to add this feature in the future???

So, there was no moving in that direction for ~2 years. I'll not be sure for this =) As i remember, actually i used direct D3 invocation for d'n'd functionality

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mithi picture mithi  路  3Comments

tim-sauchuk picture tim-sauchuk  路  3Comments

hashimmoosavi picture hashimmoosavi  路  3Comments

deecay picture deecay  路  3Comments

maxwell8888 picture maxwell8888  路  3Comments