Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Ensure title is added to default figure #396

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,9 @@ def default_figure(self) -> DeephavenFigure:
# this is very hacky but it's needed to prevent errors when
# there are no partitions until a better solution can be done
# also need the px template to be set
default_fig = px.scatter(x=[0], y=[0])
# the title can also be set here as it will never change
title = self.args.get("title")
default_fig = px.scatter(x=[0], y=[0], title=title)
default_fig.update_traces(x=[], y=[])
return DeephavenFigure(default_fig)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import unittest

from ..BaseTest import BaseTestCase


class ScatterTestCase(BaseTestCase):
def setUp(self) -> None:
from deephaven import empty_table

self.source = empty_table(0).update(["x=i", "y=i*Math.random()*i", "z=i%5"])

def test_empty_title(self):
import src.deephaven.plot.express as dx

chart = dx.line(
self.source, x="x", y="y", by=["z"], title="Hello World0"
).to_dict(self.exporter)
plotly, deephaven = chart["plotly"], chart["deephaven"]

expected_title = {"text": "Hello World0"}

self.assertEqual(plotly["layout"]["title"], expected_title)


if __name__ == "__main__":
unittest.main()
Loading