@cryptotaxi247 / netdata-1 / commits / 3df9ef13d

fix for mainchart slider control size

Costa Tsaousis (ktsaou) committed Oct 4, 2015 at 00:52 UTC 3df9ef13d2fe9bb3955de90f5c2da8168e8d8937
1 file changed +9 -7
web/index.js
+9 -7
@@ -12,13 +12,13 @@ var GROUPS_MAX_TIME_TO_SHOW = 120; // how much time the group charts will prese
12 var GROUPS_POINTS_DIVISOR = 2;
13 var GROUPS_STACKED_POINTS_DIVISOR = 2;
14
15 -var MAINCHART_MAX_TIME_TO_SHOW = 600; // how much time the main chart will present by default?
15 +var MAINCHART_MIN_TIME_TO_SHOW = 600; // how much time the main chart will present by default?
16 var MAINCHART_POINTS_DIVISOR = 5; // how much detailed will the main chart be by default? 1 = finest, higher is faster
17 var MAINCHART_STACKED_POINTS_DIVISOR = 10; // how much detailed will the main chart be by default? 1 = finest, higher is faster
18
19 var MAINCHART_CONTROL_HEIGHT = 75; // how tall the control chart will be
20 var MAINCHART_CONTROL_DIVISOR = 2; // how much detailed will the control chart be? 1 = finest, higher is faster
21 -var MAINCHART_INITIAL_SELECTOR= 20; // 1/20th of the width, this overrides MAINCHART_MAX_TIME_TO_SHOW
21 +var MAINCHART_INITIAL_SELECTOR= 20; // 1/20th of the width, this overrides MAINCHART_MIN_TIME_TO_SHOW
22
23 var CHARTS_REFRESH_LOOP = 100; // delay between chart refreshes
24 var CHARTS_REFRESH_IDLE = 500; // delay between chart refreshes when no chart was ready for refresh the last time
@@ -120,7 +120,7 @@ function initMainChart(c) {
120
121 mainchart.div = 'maingraph';
122 mainchart.max_time_to_show = (mainchart.last_entry_t - mainchart.first_entry_t) / MAINCHART_INITIAL_SELECTOR;
123 - if(mainchart.max_time_to_show < mainchart.update_every * MAINCHART_INITIAL_SELECTOR) mainchart.max_time_to_show = mainchart.update_every * MAINCHART_INITIAL_SELECTOR;
123 + if(mainchart.max_time_to_show < MAINCHART_MIN_TIME_TO_SHOW) mainchart.max_time_to_show = MAINCHART_MIN_TIME_TO_SHOW;
124 calculateChartPointsToShow(mainchart, mainchart.chartOptions.isStacked?MAINCHART_STACKED_POINTS_DIVISOR:MAINCHART_POINTS_DIVISOR, mainchart.max_time_to_show, 0);
125
126 // copy it to the hidden chart
@@ -186,7 +186,7 @@ function refreshHiddenChart(doNext) {
186 ui: {
187 chartType: mainchart.chartType,
188 chartOptions: controlopts,
189 - minRangeSize: (MAINCHART_MAX_TIME_TO_SHOW * 1000) / MAINCHART_POINTS_DIVISOR,
189 + minRangeSize: (mainchart.max_time_to_show * 1000) / MAINCHART_POINTS_DIVISOR,
190 }
191 },
192 });
@@ -225,8 +225,10 @@ function refreshHiddenChart(doNext) {
225 mainchart.dashboard.bind(mainchart.control_wrapper, mainchart.hidden_wrapper);
226 }
227 if(refresh_mode != REFRESH_PAUSED) {
228 + // console.log('mainchart.points_to_show: ' + mainchart.points_to_show + ', mainchart.group: ' + mainchart.group + ', mainchart.update_every: ' + mainchart.update_every);
229 +
230 mainchart.control_wrapper.setState({range: {
229 - start: new Date(now - (mainchart.max_time_to_show * 1000)),
231 + start: new Date(new Date().getTime() - (mainchart.points_to_show * mainchart.group * mainchart.update_every * 1000)),
232 end: new Date()
233 }});
234 }
@@ -481,7 +483,7 @@ function playGraphs() {
483
484 // check if the thread died due to a javascript error
485 var now = new Date().getTime();
484 - if((now - last_refresh) > 5000) {
486 + if((now - last_refresh) > 60000) {
487 // it died or never started
488 //mylog('It seems the refresh thread died. Restarting it.');
489 chartsRefresh();
@@ -504,7 +506,7 @@ function checkRefreshThread() {
506 }
507
508 var now = new Date().getTime();
507 - if(now - last_refresh > 10000) {
509 + if(now - last_refresh > 60000) {
510 mylog('Refresh thread died. Restarting it.');
511 chartsRefresh();
512 }