Hi everyone,
Im trying to get a response from a Highcharts component implemented through a dash_alternative_viz component.
When I drag the in/out points of a Gantt Chart, it does not trigger a change on the ‘options’ property of the Gantt HighChart.
When I query the current options property via State, the options property does not return the current options. (press TEST STATE! button)
I there a simple way around this?
import dash
import dash_alternative_viz as dav
import dash_html_components as html
from dash.dependencies import Input, Output, State
import datetime, time
external_scripts = [
"https://code.highcharts.com/gantt/highcharts-gantt.js",
"https://code.highcharts.com/gantt/modules/gantt.js",
"https://code.highcharts.com/modules/draggable-points.js"
]
app = dash.Dash(
__name__,
external_scripts=external_scripts
)
def epoch_js(date_time):
return int(time.mktime(date_time.timetuple())) * 1000
app.layout = html.Div(
[
html.Button(id="my_button", children="TEST STATE!"),
dav.HighChart(
id="my_highchart",
constructorType = 'ganttChart',
options = {
'title': {
'text': 'Interactive Gantt Chart',
'align': 'left'
},
'xAxis': {
'min': epoch_js(datetime.datetime(2023, 8, 17)),
'max': epoch_js(datetime.datetime(2023, 10, 30)),
},
'plotOptions': {
'series': {
'animation': False, # Do not animate dependency connectors
'dragDrop': {
'draggableX': True,
'draggableY': True,
'dragMinY': 0,
'dragMaxY': 2,
'dragPrecisionX': 86400000, # 1day = 1000 * 60 * 60 * 24 (millis)
},
'dataLabels': {
'enabled': True,
'format': '{point.name}',
'style': {
'cursor': 'default',
'pointerEvents': 'none'
}
},
'allowPointSelect': True,
}
},
'series': [
{
'name': 'Project 1',
'data': [
{
'name': 'Start prototype',
'start': epoch_js(datetime.datetime(2023, 9, 1)),
'end' : epoch_js(datetime.datetime(2023, 10, 20)),
'completed': {
'amount': 0.25
}
}
]
}
],
}
),
html.Div(id='output'),
]
)
@app.callback(
Output("my_highchart", "options"),
Input("my_button", "n_clicks"),
State("my_highchart", "options"),
prevent_initial_callback = True,
)
def apply(n_clicks, options):
print(options)
return options
@app.callback( # THIS DOES NOT TIGGER AS EXPECTED !!!
Output("output", "children"),
Input("my_highchart", "options"),
)
def get_options(options):
print(options)
return f'{options}'
if __name__ == "__main__":
app.run_server( port = 8050, debug=True)
Maybe I need to add some js in the assets directory. But I don’t know how to start.
Thanks in advance!