Granular options for on-chart editing#1895
Conversation
|
|
||
| function setPlotContext(gd, config) { | ||
| if(!gd._context) gd._context = Lib.extendFlat({}, Plotly.defaultConfig); | ||
| if(!gd._context) gd._context = Lib.extendDeep({}, Plotly.defaultConfig); |
There was a problem hiding this comment.
Nice. Maybe config isn't as poorly tested than I thought.
| var legendItem = d[0], | ||
| bg = d3.select(this).select('.legendtoggle'); | ||
|
|
||
| bg.call(Drawing.setRect, |
| .classed('annotation-text-g', true); | ||
|
|
||
| var editTextPosition = edits[options.showarrow ? 'annotationTail' : 'annotationPosition']; | ||
| var textEvents = options.captureevents || edits.annotationText || editTextPosition; |
There was a problem hiding this comment.
No need to address this now, but this seems like the right place to reference #1750
| }); | ||
| }) | ||
| .then(function() { | ||
| return Plotly.newPlot(gd, data, layout, { |
There was a problem hiding this comment.
For completeness, calling Plotly.plot instead of Plotly.newPlot would do the same here?
There was a problem hiding this comment.
yes, I guess since we don't remove gd._context on purge I could omit data and layout here and that would be equivalent, just changing the config. I've just been tending to avoid Plotly.plot since its effects on existing plots are a little strange.
| gd = createGraphDiv(); | ||
| }); | ||
|
|
||
| function initPlot(editFlag) { |
I think so 👍 |
|
💃 |
Adds a new config option
editsthat's an object of all the separate editable interactions you want to enable or disable. The originalconfig.editableshould still be a boolean (defaultfalseas always) that sets the defaults for all our supported editable interactions, andconfig.editscan override pieces of it. For example if you only want to enable editing legend entries, and axis titles and moving the legend, you could do:closes #1872
cc @etpinard @geocosmite
I chose to be fairly granular - for example, annotations have three separate flags (
annotationText,annotationPosition, andannotationTail, on the idea that for example you might want to allow someone to move an annotation but not change the length/direction of the arrow) but there are some other things we could segment further if desired (axisTitleTextcould be replaced byxaxisTitleTextandyaxisTitleTextfor example). Did I strike the right balance?