-
Notifications
You must be signed in to change notification settings - Fork 15
Description
Describe the bug
The Chart.to_dict()
method ignores keys which have a value of an empty string, but a value of empty string means something for the Annotations.draggable
parameter (https://api.highcharts.com/highcharts/annotations.draggable) meaning that, in practice, you can't disable draggable annotations using that parameter.
To Reproduce
Steps to reproduce the behavior:
- Create a Chart that has annotations, including the
draggable
parameter set to a value of""
chart_options = {
"title": {"text": "Chart title"},
"annotations": [
{
"labels": annotations, # List of annotations
"draggable": "",
"labelOptions": {
"backgroundColor": "rgba(252, 255, 255, 0.0)",
"borderColor": "rgba(252, 255, 255, 0.0)",
"allowOverlap": True,
"y": -2,
"overflow": "justify"
},
}
]
}
chart = Chart.from_options(chart_options)
- Export the Chart to a dictionary using the
to_dict
method and inspect theuserOptions
in the result. Note in the picture below that all parameters have been preserved exceptdraggable
:
chart.to_dict()["userOptions"]
Expected behavior
The draggable
parameter should be preserved, even when the value is an empty string.
Your Environment:
- OS: Windows 11
- Python Version: 3.11
- Highcharts JavaScript Version: highcharts-core==1.2.4
Additional context
Tracing the issue with the debugger, I isolated the following line as the problem. metaclasses.py -> lines 253, 254
elif value in [0, 0., False]:
as_dict[key] = value
Locally, I was able to correct the issue by adding an empty string in the list of permitted values, though I don't know what other affects this might have.