-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Granular options for on-chart editing #1895
Conversation
@@ -397,7 +397,7 @@ function opaqueSetBackground(gd, bgColor) { | |||
} | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lovely commit 🎉
@@ -128,8 +130,11 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { | |||
var annTextGroup = annGroup.append('g') | |||
.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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For completeness, calling Plotly.plot
instead of Plotly.newPlot
would do the same here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice tests 🎉
I think so 👍 |
💃 |
Adds a new config option
edits
that's an object of all the separate editable interactions you want to enable or disable. The originalconfig.editable
should still be a boolean (defaultfalse
as always) that sets the defaults for all our supported editable interactions, andconfig.edits
can 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 (axisTitleText
could be replaced byxaxisTitleText
andyaxisTitleText
for example). Did I strike the right balance?