highcharts-for-python / highcharts-core

Python wrapper for the Highcharts Core JavaScript library
https://www.highcharts.com/integrations/python
Other
58 stars 13 forks source link

No data to display when saving the chart to pdf/png #153

Closed santurini closed 5 months ago

santurini commented 7 months ago

I am using this code to generate a Stacked Bar Chart and the output I get is correct, but when I try to download the chart the bars are missing:

chart_options = ChartOptions(
    height = 600,
    width = 550
)

labels = DataLabel(
    align = 'left',
    enabled = True,
    format = "{point.percentage:.0f}%",
    inside = True
)

series = ColumnSeries().from_pandas(
    data[::-1], 
    series_in_rows = True,
    data_labels = labels,
    stacking = 'normal'
    )

title = Title(
    align = 'left',
    margin = 80,
    style = {"color": "#123a64", "fontWeight": "bold", "fontSize": 16},
    text = 'Fig. 1a'
)

legend = Legend(
    align = 'right',
    border_color = None,
    enabled = True,
    layout = 'vertical',
    symbol_radius = 0,
    vertical_align = 'bottom',
    y = -20
)

chart = Chart(series = series)

chart.options.title = title
chart.options.subtitle = subtitle
chart.options.legend = legend
chart.options.chart = chart_options

chart.display()

Plot obtained: image

Plot downloaded: image

hcpchris commented 7 months ago

Sorry you're running into this, @santurini : I'll take a closer look and see if I can reproduce and diagnose what may be happening.

hcpchris commented 5 months ago

@santurini : Apologies for the delay, but I was able to identify a number of issues that may have been causing this behavior. I am not 100% certain whether those specific issues were causing this behavior, but their symptoms were analogous. Those issues have been addressed as of the most recent release (v.1.8.0) so please feel free to try again with your code and see if the strange behavior is still happening.

For the time being, I'm going to close this issue but if it is still happening feel free to re-open it and share some more details on what you are doing that produces the error. The code you shared is very helpful, but it would also be helpful if you could share a snippet of data (may be fake data, obviously) that produces this behavior if you are still running into trouble.