Skip to content

Commit

Permalink
Create new class to determine line mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
nathancoliver committed Dec 15, 2023
1 parent 369dae2 commit 4f06e55
Showing 1 changed file with 28 additions and 12 deletions.
40 changes: 28 additions & 12 deletions dimes/dimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,23 @@ class LineProperties:
class TimeSeriesData:
"""Time series data."""

class LineMode:
def determine_line_mode(
self, marker_symbol, marker_size, marker_line_color, marker_fill_color
):
if all(
variables is None
for variables in (
marker_size,
marker_symbol,
marker_line_color,
marker_fill_color,
)
):
return "lines"
else:
return "lines+markers"

def __init__(
self,
data_values: list,
Expand Down Expand Up @@ -55,6 +72,13 @@ def __init__(

self.line_properties = line_properties

self.mode = self.LineMode().determine_line_mode(
line_properties.marker_symbol,
line_properties.marker_size,
line_properties.marker_line_color,
line_properties.marker_fill_color,
)


class TimeSeriesAxis:
"""Time series 'Y' axis. May contain multiple `TimeSeriesData` objects."""
Expand Down Expand Up @@ -141,18 +165,10 @@ def finalize_plot(self):
),
name=time_series.name,
yaxis=f"y{axis_id}",
mode="lines"
if all(
variables is None
for variables in (
time_series.marker_size,
time_series.marker_symbol,
time_series.marker_line_color,
time_series.marker_fill_color,
)
)
else "lines+markers",
visible="legendonly" if not time_series.is_visible else True,
mode=time_series.mode,
visible="legendonly"
if not time_series.line_properties.is_visible
else True,
line={
"color": time_series.line_properties.color,
"dash": time_series.line_properties.line_type,
Expand Down

0 comments on commit 4f06e55

Please sign in to comment.