empty sparklines

This commit is contained in:
Will McGugan
2024-11-14 17:59:58 +00:00
parent 0a7a292c51
commit adeb306ac9
2 changed files with 6 additions and 5 deletions

View File

@@ -367,7 +367,7 @@ def loop_first_last(values: Iterable[T]) -> Iterable[tuple[bool, bool, T]]:
def update_log(self) -> None:
"""Update the Log with new content."""
log = self.query_one(Log)
if not self.app.screen.can_view_partial(log) and not log.is_in_maximized_view:
if not self.app.screen.can_view_entire(log) and not log.is_in_maximized_view:
return
self.log_count += 1
line_no = self.log_count % len(self.TEXT)
@@ -378,7 +378,7 @@ def loop_first_last(values: Iterable[T]) -> Iterable[tuple[bool, bool, T]]:
"""Update the Rich Log with content."""
rich_log = self.query_one(RichLog)
if (
not self.app.screen.can_view_partial(rich_log)
not self.app.screen.can_view_entire(rich_log)
and not rich_log.is_in_maximized_view
):
return

View File

@@ -87,8 +87,9 @@ class Sparkline(Widget):
def render(self) -> RenderResult:
"""Renders the sparkline when there is data available."""
if not self.data:
return "<empty sparkline>"
data = self.data or []
if not data:
return ""
_, base = self.background_colors
min_color = base + (
self.get_component_styles("sparkline--min-color").color
@@ -101,7 +102,7 @@ class Sparkline(Widget):
else self.max_color
)
return SparklineRenderable(
self.data,
data,
width=self.size.width,
min_color=min_color.rich_color,
max_color=max_color.rich_color,