allow custom title on charts
Costa Tsaousis (ktsaou) committed
Jan 5, 2016 at 20:35 UTC
49ba8df1896329ea7010030e61744e276cdf1329
1 file changed
+30
-15
web/dashboard.js
+30
-15
@@ -891,19 +891,21 @@
891
series: null
892
};
893
894
- this.chart_url = null; // string - the url to download chart info
895
- this.chart = null; // object - the chart as downloaded from the server
894
+ this.chart_url = null; // string - the url to download chart info
895
+ this.chart = null; // object - the chart as downloaded from the server
896
897
- this.validated = false; // boolean - has the chart been validated?
898
- this.enabled = true; // boolean - is the chart enabled for refresh?
899
- this.paused = false; // boolean - is the chart paused for any reason?
900
- this.selected = false; // boolean - is the chart shown a selection?
901
- this.debug = false; // boolean - console.log() debug info about this chart
897
+ this.title = self.data('title') || null; // the title of the chart
898
903
- this.netdata_first = 0; // milliseconds - the first timestamp in netdata
904
- this.netdata_last = 0; // milliseconds - the last timestamp in netdata
905
- this.requested_after = null; // milliseconds - the timestamp of the request after param
906
- this.requested_before = null; // milliseconds - the timestamp of the request before param
899
+ this.validated = false; // boolean - has the chart been validated?
900
+ this.enabled = true; // boolean - is the chart enabled for refresh?
901
+ this.paused = false; // boolean - is the chart paused for any reason?
902
+ this.selected = false; // boolean - is the chart shown a selection?
903
+ this.debug = false; // boolean - console.log() debug info about this chart
904
+
905
+ this.netdata_first = 0; // milliseconds - the first timestamp in netdata
906
+ this.netdata_last = 0; // milliseconds - the last timestamp in netdata
907
+ this.requested_after = null; // milliseconds - the timestamp of the request after param
908
+ this.requested_before = null; // milliseconds - the timestamp of the request before param
909
910
this.auto = {
911
name: 'auto',
@@ -2307,6 +2309,16 @@
2309
var ret = 0;
2310
var tolerance = 0;
2311
2312
+ if(x.width === 0 || x.height === 0 || this.element.style.display === 'none') {
2313
+ hideChart();
2314
+ this.___isVisible___ = false;
2315
+
2316
+ if(this.debug === true)
2317
+ this.log('isVisible: ' + this.___isVisible___);
2318
+
2319
+ return this.___isVisible___;
2320
+ }
2321
+
2322
if(x.top < 0 && -x.top > x.height) {
2323
// the chart is entirely above
2324
ret = -x.top - x.height;
@@ -2452,6 +2464,9 @@
2464
this.data_update_every = chart.update_every * 1000;
2465
this.data_points = Math.round(this.chartWidth() / this.chartPixelsPerPoint());
2466
this.tm.last_info_downloaded = new Date().getTime();
2467
+
2468
+ if(this.title === null)
2469
+ this.title = chart.title;
2470
}
2471
2472
// fetch the chart description from the netdata server
@@ -3002,7 +3017,7 @@
3017
highlightColor: highlightColor,
3018
tooltipContainer: tooltipContainer,
3019
tooltipClassname: tooltipClassname,
3005
- tooltipChartTitle: state.chart.title,
3020
+ tooltipChartTitle: state.title,
3021
tooltipFormat: tooltipFormat,
3022
tooltipPrefix: tooltipPrefix,
3023
tooltipSuffix: tooltipSuffix,
@@ -3170,7 +3185,7 @@
3185
showRangeSelector: self.data('dygraph-showrangeselector') || false,
3186
showRoller: self.data('dygraph-showroller') || false,
3187
3173
- title: self.data('dygraph-title') || state.chart.title,
3188
+ title: self.data('dygraph-title') || state.title,
3189
titleHeight: self.data('dygraph-titleheight') || 19,
3190
3191
legend: self.data('dygraph-legend') || 'always', // 'onmouseover',
@@ -3790,7 +3805,7 @@
3805
//width: state.chartWidth(),
3806
//height: state.chartHeight(),
3807
lineWidth: 1,
3793
- title: state.chart.title,
3808
+ title: state.title,
3809
fontSize: 11,
3810
hAxis: {
3811
// title: "Time of Day",
@@ -3967,7 +3982,7 @@
3982
var titletop = Math.round(valuetop - titlefontsize - (size / 20));
3983
state.easyPieChartTitle = document.createElement('span');
3984
state.easyPieChartTitle.className = 'easyPieChartTitle';
3970
- state.easyPieChartTitle.innerHTML = state.chart.name;
3985
+ state.easyPieChartTitle.innerHTML = state.title;
3986
state.easyPieChartTitle.style.fontSize = titlefontsize + 'px';
3987
state.easyPieChartTitle.style.lineHeight = titlefontsize + 'px';
3988
state.easyPieChartTitle.style.top = titletop.toString() + 'px';