|
63 | 63 | 'flows': {'x': 'time', 'color': 'variable', 'symbol': None}, |
64 | 64 | 'charge_states': {'x': 'time', 'color': 'variable', 'symbol': None}, |
65 | 65 | 'storage': {'x': 'time', 'color': 'variable', 'pattern_shape': None}, |
| 66 | + 'storage_line': {'x': 'time', 'color': None, 'line_dash': None, 'symbol': None}, |
66 | 67 | 'sizes': {'x': 'variable', 'color': 'variable'}, |
67 | 68 | 'duration_curve': {'symbol': None}, # x is computed dynamically |
68 | 69 | 'effects': {}, # x is computed dynamically |
@@ -2393,17 +2394,20 @@ def storage( |
2393 | 2394 | _apply_unified_hover(fig, unit=unit_label) |
2394 | 2395 |
|
2395 | 2396 | # Add charge state as line on secondary y-axis |
2396 | | - # Build line figure with same faceting kwargs |
2397 | | - line_kwargs = { |
2398 | | - k: v for k, v in plotly_kwargs.items() if k in ('x', 'facet_col', 'facet_row', 'animation_frame') |
2399 | | - } |
2400 | | - line_fig = charge_da.plotly.line(color=None, **line_kwargs) |
2401 | | - # Style the line traces |
2402 | | - for trace in line_fig.data: |
2403 | | - trace.name = 'charge_state' |
2404 | | - trace.line = dict(color=charge_state_color, width=2) |
2405 | | - trace.showlegend = trace == line_fig.data[0] # Only first trace in legend |
2406 | | - trace.legendgroup = 'charge_state' |
| 2397 | + # Filter out bar-only kwargs, then apply line-specific defaults |
| 2398 | + line_kwargs = {k: v for k, v in plotly_kwargs.items() if k not in ('pattern_shape', 'color')} |
| 2399 | + _apply_slot_defaults(line_kwargs, 'storage_line') |
| 2400 | + line_fig = charge_da.plotly.line(**line_kwargs) |
| 2401 | + # Style all traces including animation frames |
| 2402 | + update_traces( |
| 2403 | + line_fig, |
| 2404 | + line=dict(color=charge_state_color, width=2), |
| 2405 | + name='charge_state', |
| 2406 | + legendgroup='charge_state', |
| 2407 | + showlegend=False, |
| 2408 | + ) |
| 2409 | + if line_fig.data: |
| 2410 | + line_fig.data[0].showlegend = True |
2407 | 2411 | # Combine using xarray_plotly's add_secondary_y which handles facets correctly |
2408 | 2412 | fig = add_secondary_y(fig, line_fig, secondary_y_title='Charge State') |
2409 | 2413 |
|
|
0 commit comments