Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c0dcbbe

Browse files
authoredMay 23, 2021
Auto-scale Y-axis for indicators when zooming kernc#356
1 parent 4ff1fe8 commit c0dcbbe

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed
 

‎backtesting/_plotting.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -523,12 +523,10 @@ def __eq__(self, other):
523523
colors = colors and cycle(_as_list(colors)) or (
524524
cycle([next(ohlc_colors)]) if is_overlay else colorgen())
525525
legend_label = LegendStr(value.name)
526-
527526
indicator_max=value.df.max(axis='columns')
528527
indicator_min=value.df.min(axis='columns')
529528
source.add(indicator_max, f'indicator_{i}_range_max')
530-
source.add(indicator_min,f'indicator_{i}_range_min')
531-
529+
source.add(indicator_min, f'indicator_{i}_range_min')
532530
for j, arr in enumerate(value, 1):
533531
color = next(colors)
534532
source_name = f'{legend_label}_{i}_{j}'
@@ -619,9 +617,8 @@ def __eq__(self, other):
619617
indicator_ranges = {}
620618
for idx,indicator in enumerate(indicator_figs):
621619
indicator_range_key = f'indicator_{idx}_range'
622-
indicator_ranges.update({indicator_range_key:indicator.y_range})
623-
custom_js_args.update({'indicator_ranges':indicator_ranges})
624-
620+
indicator_ranges.update({indicator_range_key: indicator.y_range})
621+
custom_js_args.update({'indicator_ranges': indicator_ranges})
625622
fig_ohlc.x_range.js_on_change('end', CustomJS(args=custom_js_args,
626623
code=_AUTOSCALE_JS_CALLBACK))
627624

0 commit comments

Comments
 (0)
Please sign in to comment.