How to add modeBarButtons Increase/Decrease textfont.size similar to Zoom in/Zoom out provided that the size increments\decrements by 1?
1. I implemented a codepen for plotly.js:
https://codepen.io/mx2048/pen/xYgYXe
Here I set specific values for textfont.size. But I want to retrieve current textfont.size from the plot and generate a new size.
2. Now how to do that via Python? So far, I succeeded in creating updatemenus buttons, but they should be the modeBarButtons.
See the code:
import plotly.graph_objs as go
from plotly.offline import plot
data = []
lone_point = go.Scatter(x=[1], y=[1],
mode='markers+text',
text='My point',
textposition='top',
textfont=dict(size=18),
)
data.append(lone_point)
updatemenus = list([
dict(
buttons=list([
dict(
args=['textfont', {'size': 22}],
label='A+',
method='restyle'
),
dict(
args=['textfont', {'size': 14}],
label='A-',
method='restyle'
)
]),
type='buttons',
),
])
layout = go.Layout(updatemenus=updatemenus)
figure = go.Figure(data=data, layout=layout)
config = dict(modeBarButtonsToRemove=['zoomIn2d', 'zoomOut2d'],
# modeBarButtonsToAdd=[dict(
# name='Increase font size',
# # What to write here?
# )]
)
plot(figure, config=config)
I am considering embedding additional scripts because I know ID of my div plot. Something like that, but I am stuck here:
<script type="text/javascript">
document.getElementById("{}").on('plotly_click', function(data){
// do something I don't know
});
</script>