Annotation Callback 'onMove'
See original GitHub issueWhat I’m trying to do is set up an API call to my DB that allows users to add, edit, move, remove (etc.) annotations from the plot in their report. (I’ll need x/y coordinates, arrow info etc. to recreate from the DB on next run).
I’m having a hard time understanding the event handlers. (Sorry for the code formatting).
I set the plot with:
$( document ).ready(function() {
Plotly.newPlot('main_graph{{key}}',
main_data{{key}},
main_layout{{key}},
{displayModeBar: false,
edits:{annotationPosition: true,
annotationText: true,
annotationTail: true}},
);
});
And I have a button on the page to add a new default annotation
function addAnnotation(
var myPlot{{key}} = document.getElementById('main_graph{{key}}');
var annotate_text = 'New Annotation';
var annotation = {
text: annotate_text,
x: 1,
y: 15
}
var annotations = myPlot{{key}}.layout.annotations || [];
annotations.push(annotation);
var update = { annotations: annotations };
Plotly.relayout('main_graph{{key}}', update);
$(".annotation").bind("click mouseup mouseleave",function(e) {
var annotations_list = myPlot{{key}}.getElementsByClassName("annotation");
var ann_list = Array.prototype.slice.call( annotations_list );
var annot_number = this.getAttribute('data-index')
var annot = ann_list[annot_number]
var x = myPlot{{key}}.layout.annotations[annot_number]['x']
console.log('well something happened', annot)
});
};
The event prints to console until I move (drag and drop) an annotation…then nothing prints when I mouseup or mouseleave the new annotation location.
Ideally I would like an event to fire that I can tie to AJAX to update DB anytime an annotation is modified…re-positioned, renamed, etc.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
ItemTouchHelper.Callback - Android Developers
This class is the contract between ItemTouchHelper and your application. It lets you control which touch behaviors are enabled per each ViewHolder and...
Read more >OnMoveListener - Mapbox docs
OnMove Listener. Interface definition for a callback to be invoked when the map is moved. interface OnMoveListener. Content copied to clipboard. Functions
Read more >Callback - HELP CENTER
Callback is used after the script has issues a Reqagent and has not yet been answered. The phone call will not be initiated...
Read more >ItemTouchHelper.java - Google Git
import android.annotation.SuppressLint; ... import androidx.annotation.NonNull; ... {@link Callback#onMove(RecyclerView, ViewHolder, ViewHolder)} and / or.
Read more >android.support.v7.widget.helper.ItemTouchHelper$Callback ...
ItemTouchHelper$Callback ... RecyclerViewElasticityAdapter$ItemTouchHelperCallbackWrapper.getMoveThreshold(. ... Annotation (javassist.bytecode.annotation).
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You should use plotly_relayout event which will send you the changes after annotation change is finished.
Closing.