Skip to content

to_js_literal method is taking excessively long time #51

@rdp1414

Description

@rdp1414

Describe the bug

The to_js_literal method is taking excessively long time.


Steps Reproduce

  1. First, let us create a 4000 points dataset.
import seaborn as sns

original_df = sns.load_dataset('iris')
df = sns.load_dataset('iris')
for i in range(26):
    df = df.append(original_df, ignore_index=True)
df

image
2. Now, create a Highcharts Python chart.

from highcharts_core.chart import Chart
from highcharts_core.options.series.scatter import ScatterSeries
from highcharts_core.options.plot_options import PlotOptions

ch = Chart.from_pandas(
    df,
    property_map={
        'x': 'petal_width',
        'y': 'sepal_length',
    },
    series_type='scatter',
)

# Disable boost.
ch.options.plot_options = PlotOptions(series=ScatterSeries(turbo_threshold=0))
  1. Then, when chart is displayed. the bulk of time goes in to_js_literal method. This particular method takes 21 seconds - See python profiling screenshot.
display(ch)

image


Expected behavior

I observed that:

  1. IF the number of rows in the input DataFrame decreases, so does the time taken by to_js_literal method.
  2. Why is this method taking so much time? I looked at the code - it seems that this is a recursive method. Due to this method taking 21 seconds, entire rendering time is 28 seconds. This is not a great user experience that you've to wait for half-a-minute to view your chart.

Your Environment

  • OS: Windows, Jupyter Lab (notebook).
  • Python Version: 3.10.4
  • Highcharts Version: Installed Highcharts Python using pip install highcharts-core command.

Metadata

Metadata

Assignees

Labels

duplicateThis issue or pull request already exists

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions