Skip to content

Format of data for large number of points to be a list instead of dict #99

Open
@abbas-mohd56

Description

@abbas-mohd56

I'm trying to plot a LineSeries with 4000+ points. When I try to render the chart, It fails on the front end and shows me this link in the console https://assets.highcharts.com/errors/12/.

It fails on the front end because the number of points exceeds the default turboThreshold value which is 1000. I can disable turbo mode by setting it to 0 and it works just fine, However, if the data returned could be in the format which could be supported by boost mode, it'd be great!

To explain this with an example, imagine this DataFrame saved in variable df (Using 3 points instead of 4000 for simplicity):

timestamp value
2023-08-03 19517.0
2023-08-04 21262.0
2023-08-05 18535.0

If I create a LineSeries instance using the following code:

from highcharts_core.options.series.area import LineSeries

series = LineSeries.from_pandas(df, {"x": "timestamp", "y": "value"})
print(series.to_json())

This gives me the following ouput:

{"data": [{"x": 1691020800000.0, "y": 19517.0}, {"x": 1691107200000.0, "y": 21262.0}, {"x": 1691193600000.0, "y": 18535.0}], "type": "line"}

However, for it to work in turbo mode, I need the data to be in the following format

{"data": [[1691020800000.0, 19517.0], [1691107200000.0, 21262.0], [1691193600000.0, 18535.0]], "type": "line"}

Is it somehow possible to generate this output?
Regardless of the turbo mode, this format would be ideal to send large datasets through an API as the size generated would be less compared to the list of dict format.

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions