Skip to content

Datetime fields not plotted #368

@miili

Description

@miili

Describe the bug

Plotly 4.2.0 does not plot QDateTime anymore.

Traceback (most recent call last):
  File "/home/.../.local/share/QGIS/QGIS3/profiles/default/python/plugins/DataPlotly/gui/plot_settings_widget.py", line 1480, in UpdatePlot
    self.create_plot()
  File "/home/.../.local/share/QGIS/QGIS3/profiles/default/python/plugins/DataPlotly/gui/plot_settings_widget.py", line 1428, in create_plot
    self.plot_path = plot_factory.build_figure()
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/.../.local/share/QGIS/QGIS3/profiles/default/python/plugins/DataPlotly/core/plot_factory.py", line 701, in build_figure
    f.write(self.build_html(config))
            ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/.../.local/share/QGIS/QGIS3/profiles/default/python/plugins/DataPlotly/core/plot_factory.py", line 660, in build_html
    raw_plot += plotly.offline.plot(fig, output_type='div', include_plotlyjs=False, show_link=False,
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/plotly/offline/offline.py", line 600, in plot
    return pio.to_html(
           ^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/plotly/io/_html.py", line 142, in to_html
    jdata = to_json_plotly(fig_dict.get("data", []))
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/plotly/io/_json.py", line 171, in to_json_plotly
    return _safe(orjson.dumps(cleaned, option=opts).decode("utf8"), _swap_orjson)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Type is not JSON serializable: QDateTime

To Reproduce
Use a QDateTime field in the plot.

Desktop (please complete the following information):

  • OS: Linux
  • QGIS release 3.34.13-Prizen
  • DataPlotly release 4.2.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions