Julien-Cousineau / MNRF

MNRF Dashboard
MIT License
2 stars 0 forks source link

Scale Y-Axis in TS Plots Dynamically #6

Closed rywhale closed 6 years ago

rywhale commented 6 years ago

The Y-Axis on the time series plots should scale dynamically to the min/max of the values when you change the time period.

Currently we go from

pre_scale

to

post_scale

The scale needs to change in the second plot or the data isn't readable.

Julien-Cousineau commented 6 years ago

I'm not too sure I understand. Would the second plot Y-axis be between 2.46 and 2.5?

rywhale commented 6 years ago

Yeah, the Y-axis in the second plot should scale to the min/max of the data in the second plot. In other words, every time you change the time range with one of the selectors (all, 6m, 1m, 1w), the Y-axis should automatically scale to the min/max values in the time range.

So if the min/max in the second plot are 2.46/2.5 you would scale to those values. The issue is that the second plot looks flat when in reality there is still some fluctuation going on there

Julien-Cousineau commented 6 years ago

I'll look into it. The Plotly library is nice but customization can be a pain.

beatonan commented 6 years ago

@Julien-Cousineau we see the scaling of y-axis is a pretty high priority vs other issues so would be great if this could get some focus.

Julien-Cousineau commented 6 years ago

From plotly:https://github.com/plotly/plotly.js/issues/1876 The axis auto-range is currently not available.

Possible temporary solution: Hard code y-axis based on selected data.

  1. Add clicking event = >(div.on('plotly_relayout',function(relayoutData){})) :heavy_check_mark:
  2. filter data based on dates = >relayoutData={xaxis.range[0]:start,xaxis.range[1]:end} :heavy_check_mark:
  3. find min max :heavy_check_mark:
  4. adjust graph :heavy_check_mark:
Julien-Cousineau commented 6 years ago

My temporary code seems to be working. However the range slider at the bottom use the same y-axis as the chart as shown below. Please let me know if that is an issue. screenshot 2018-03-15 at 19 14 48

rywhale commented 6 years ago

@Julien-Cousineau Looks good to me

Cevior commented 1 year ago

Could you provide some (coding-) details on how you solved it? Would it be possible to integrate it via event handlers in R?