@cryptotaxi247 / netdata-1 / commits / dcb9c662a

mainchart control initial selection no less than 1/10th of the total

Costa Tsaousis (ktsaou) committed Jun 14, 2014 at 20:06 UTC dcb9c662ad7aee2750f0f4e09256c928c4421baa
1 file changed +7 -2
web/index.js
+7 -2
@@ -16,6 +16,7 @@ var MAINCHART_STACKED_POINTS_DIVISOR = 20; // how much detailed will the main c
16
17 var MAINCHART_CONTROL_HEIGHT = 75; // how tall the control chart will be
18 var MAINCHART_CONTROL_DIVISOR = 2; // how much detailed will the control chart be? 1 = finest, higher is faster
19 +var MAINCHART_INITIAL_SELECTOR=10; // 1/10 of the width
20
21 var MODE_THUMBS = 1;
22 var MODE_MAIN = 2;
@@ -210,11 +211,15 @@ function refreshHiddenChart(doNext) {
211 google.visualization.events.addListener(mainchart.control_wrapper, 'ready', mainchartControlReadyEvent);
212 mainchart.dashboard.bind(mainchart.control_wrapper, mainchart.hidden_wrapper);
213 }
213 - if(refresh_mode != REFRESH_PAUSED)
214 + if(refresh_mode != REFRESH_PAUSED) {
215 + var duration = (mainchart.hiddenchart.last_entry_t - mainchart.hiddenchart.first_entry_t) / MAINCHART_INITIAL_SELECTOR;
216 + if(duration <= 0) duration = MAINCHART_INITIAL_SELECTOR;
217 +
218 mainchart.control_wrapper.setState({range: {
215 - start: new Date((Math.round(new Date().getTime() / 1000) - MAINCHART_MAX_TIME_TO_SHOW) * 1000),
219 + start: new Date((Math.round(new Date().getTime() / 1000) - duration) * 1000),
220 end: new Date()
221 }});
222 + }
223
224 mainchart.dashboard.draw(mainchart.control_data);
225 mainchart.hiddenchart.last_updated = new Date().getTime();