@cryptotaxi247 / netdata-1 / commits / 0d2cac3c1

fixed an issue with list synchronization of selection in dygraphs - more aesthetic changes to dygraphs

Costa Tsaousis (ktsaou) committed Dec 7, 2015 at 04:39 UTC 0d2cac3c16b478a3d202dcd05dd288c60e1cc92f
1 file changed +53 -33
web/dashboard.js
+53 -33
@@ -506,11 +506,7 @@
506
507 calculateRowForTime: function(t) {
508 if(!this.timeIsVisible(t)) return -1;
509 -
510 - var r = Math.floor((t - this.current.after_ms) / this.current.view_update_every);
511 - // console.log(this.current.data);
512 -
513 - return r;
509 + return Math.floor((t - this.current.after_ms) / this.current.view_update_every);
510 },
511
512 pauseChart: function() {
@@ -771,7 +767,7 @@
767
768 // if the result is JSON, find the latest update-every
769 if(typeof data == 'object' && this.library.jsonWrapper) {
774 - if(!this.follows_global && typeof data.view_update_every != 'undefined')
770 + if(typeof data.view_update_every != 'undefined')
771 this.current.view_update_every = data.view_update_every * 1000;
772
773 if(typeof data.after != 'undefined')
@@ -1461,7 +1457,7 @@
1457 // state.debug = true;
1458
1459 var t = state.current.after_ms + row * state.current.view_update_every;
1464 - // console.log('row = ' + row + ', x = ' + x + ', t = ' + t + ' ' + ((t == x)?'SAME':'DIFFERENT'));
1460 + // console.log('row = ' + row + ', x = ' + x + ', t = ' + t + ' ' + ((t == x)?'SAME':'DIFFERENT') + ', rows in db: ' + state.current.data.points + ' visible(x) = ' + state.timeIsVisible(x) + ' visible(t) = ' + state.timeIsVisible(t) + ' r(x) = ' + state.calculateRowForTime(x) + ' r(t) = ' + state.calculateRowForTime(t) + ' range: ' + state.current.after_ms + ' - ' + state.current.before_ms + ' real: ' + state.current.data.after + ' - ' + state.current.data.before + ' every: ' + state.current.view_update_every);
1461
1462 now = new Date().getTime();
1463 if(now < NETDATA.dygraph.dont_sync_before) {
@@ -1544,6 +1540,7 @@
1540 NETDATA.dygraph.chartPanOrZoom = function(state, dygraph, after, before) {
1541 if(NETDATA.options.debug.dygraph) console.log('>>>> dygraph.zoomOrPan(state, dygraph, after:' + after + ', before: ' + before + ')');
1542
1543 + //console.log(state.dygraph_instance);
1544 state.updateChartPanOrZoom(after, before);
1545 return;
1546 }
@@ -1619,49 +1616,71 @@
1616 var self = $(state.element);
1617 var title = self.data('dygraph-title') || state.chart.title;
1618 var titleHeight = self.data('dygraph-titleheight') || 19;
1622 - var labelsDiv = self.data('dygraph-labelsdiv') || undefined;
1623 - var connectSeparatedPoints = self.data('dygraph-connectseparatedpoints') || false;
1624 - var yLabelWidth = self.data('dygraph-ylabelwidth') || 12;
1625 - var stackedGraph = self.data('dygraph-stackedgraph') || (state.chart.chart_type == 'stacked')?true:false;
1626 - var stackedGraphNaNFill = self.data('dygraph-stackedgraphnanfill') || 'none';
1619 var hideOverlayOnMouseOut = self.data('dygraph-hideoverlayonmouseout') || true;
1628 - var fillGraph = self.data('dygraph-fillgraph') || (state.chart.chart_type == 'area')?true:false;
1629 - var drawPoints = self.data('dygraph-drawpoints') || false;
1620 + var colors = self.data('dygraph-colors') || NETDATA.colors;
1621 +
1622 + // legend
1623 + var legend = self.data('dygraph-legend') || 'onmouseover';
1624 + var labelsDiv = self.data('dygraph-labelsdiv') || undefined;
1625 var labelsDivStyles = self.data('dygraph-labelsdivstyles') || { 'fontSize':'10px' };
1626 var labelsDivWidth = self.data('dygraph-labelsdivwidth') || state.chartWidth() - 70;
1627 var labelsSeparateLines = self.data('dygraph-labelsseparatelines') || false;
1628 var labelsShowZeroValues = self.data('dygraph-labelsshowzerovalues') || true;
1634 - var legend = self.data('dygraph-legend') || 'onmouseover';
1629 var showLabelsOnHighlight = self.data('dygraph-showlabelsonhighlight') || true;
1636 - var gridLineColor = self.data('dygraph-gridlinecolor') || '#EEE';
1637 - var axisLineColor = self.data('dygraph-axislinecolor') || '#EEE';
1638 - var maxNumberWidth = self.data('dygraph-maxnumberwidth') || 8;
1630 + var yLabelWidth = self.data('dygraph-ylabelwidth') || 12;
1631 +
1632 + // Value Formatting
1633 var sigFigs = self.data('dygraph-sigfigs') || null;
1634 + var maxNumberWidth = self.data('dygraph-maxnumberwidth') || 8;
1635 var digitsAfterDecimal = self.data('dygraph-digitsafterdecimal') || 2;
1636 + var valueFormatter = self.data('dygraph-valueformatter') || undefined; //function(x){ return x.toFixed(2); };
1637 +
1638 + // Axis and Grid
1639 + var drawAxis = self.data('dygraph-drawaxis') || true;
1640 var axisLabelFontSize = self.data('dygraph-axislabelfontsize') || 10;
1641 var axisLineWidth = self.data('dygraph-axislinewidth') || 0.3;
1643 - var drawAxis = self.data('dygraph-drawaxis') || true;
1644 - var strokeWidth = self.data('dygraph-strokewidth') || 1.0;
1642 + var gridLineColor = self.data('dygraph-gridlinecolor') || '#EEE';
1643 + var axisLineColor = self.data('dygraph-axislinecolor') || '#DDD';
1644 + var drawGrid = self.data('dygraph-drawgrid') || true;
1645 + var drawXGrid = self.data('dygraph-drawxgrid') || undefined;
1646 + var drawYGrid = self.data('dygraph-drawygrid') || undefined;
1647 + var gridLinePattern = self.data('dygraph-gridlinepattern') || null;
1648 + var gridLineWidth = self.data('dygraph-gridlinewidth') || 0.3;
1649 +
1650 + // enabling this makes the chart with little square lines
1651 + var stepPlot = self.data('dygraph-stepplot') || false;
1652 + var connectSeparatedPoints = self.data('dygraph-connectseparatedpoints') || false;
1653 +
1654 + // Draw points at the edges of gaps in the data. This improves visibility of small data segments or other data irregularities.
1655 var drawGapEdgePoints = self.data('dygraph-drawgapedgepoints') || true;
1646 - var colors = self.data('dygraph-colors') || NETDATA.colors;
1656 +
1657 + // The size of the dot to draw on each point in pixels (see drawPoints). A dot is always drawn when a point is "isolated",
1658 + // i.e. there is a missing point on either side of it. This also controls the size of those dots.
1659 + var drawPoints = self.data('dygraph-drawpoints') || false;
1660 var pointSize = self.data('dygraph-pointsize') || 1;
1648 - var stepPlot = self.data('dygraph-stepplot') || false;
1649 - var strokeBorderColor = self.data('dygraph-strokebordercolor') || 'white';
1650 - var strokeBorderWidth = self.data('dygraph-strokeborderwidth') || (state.chart.chart_type == 'stacked')?0.1:0.0;
1661 +
1662 + // The width of the lines connecting data points. This can be used to increase the contrast or some graphs.
1663 + var strokeWidth = self.data('dygraph-strokewidth') || (state.chart.chart_type == 'stacked')?0.0:1.0;
1664 var strokePattern = self.data('dygraph-strokepattern') || undefined;
1665 +
1666 + // Draw a border around graph lines to make crossing lines more easily distinguishable. Useful for graphs with many lines.
1667 + var strokeBorderColor = self.data('dygraph-strokebordercolor') || 'white';
1668 + var strokeBorderWidth = self.data('dygraph-strokeborderwidth') || (state.chart.chart_type == 'stacked')?0.0:0.0;
1669 +
1670 var highlightCircleSize = self.data('dygraph-highlightcirclesize') || 3;
1671 var highlightSeriesOpts = self.data('dygraph-highlightseriesopts') || null; // TOO SLOW: { strokeWidth: 1.5 };
1672 var highlightSeriesBackgroundAlpha = self.data('dygraph-highlightseriesbackgroundalpha') || null; // TOO SLOW: (state.chart.chart_type == 'stacked')?0.7:0.5;
1673 var pointClickCallback = self.data('dygraph-pointclickcallback') || undefined;
1674 var showRangeSelector = self.data('dygraph-showrangeselector') || false;
1675 var showRoller = self.data('dygraph-showroller') || false;
1658 - var valueFormatter = self.data('dygraph-valueformatter') || undefined; //function(x){ return x.toFixed(2); };
1676 +
1677 + // leave a few pixels empty on the right of the chart
1678 var rightGap = self.data('dygraph-rightgap') || 5;
1660 - var drawGrid = self.data('dygraph-drawgrid') || true;
1661 - var drawXGrid = self.data('dygraph-drawxgrid') || undefined;
1662 - var drawYGrid = self.data('dygraph-drawygrid') || undefined;
1663 - var gridLinePattern = self.data('dygraph-gridlinepattern') || null;
1664 - var gridLineWidth = self.data('dygraph-gridlinewidth') || 0.3;
1679 +
1680 + var fillGraph = self.data('dygraph-fillgraph') || (state.chart.chart_type == 'area')?true:false;
1681 + var fillAlpha = self.data('dygraph-fillalpha') || (state.chart.chart_type == 'stacked')?0.8:0.2;
1682 + var stackedGraph = self.data('dygraph-stackedgraph') || (state.chart.chart_type == 'stacked')?true:false;
1683 + var stackedGraphNaNFill = self.data('dygraph-stackedgraphnanfill') || 'none';
1684
1685 state.dygraph_options = {
1686 title: title,
@@ -1697,6 +1716,7 @@
1716 digitsAfterDecimal: digitsAfterDecimal,
1717 axisLabelFontSize: axisLabelFontSize,
1718 colors: colors,
1719 + fillAlpha: fillAlpha,
1720 strokeWidth: strokeWidth,
1721 drawGapEdgePoints: drawGapEdgePoints,
1722 pointSize: pointSize,
@@ -2132,7 +2152,7 @@
2152 legend: 'right-side',
2153 autoresize: true,
2154 max_updates_to_recreate: 5000,
2135 - pixels_per_point: 2,
2155 + pixels_per_point: 3,
2156 detects_dimensions_on_update: false
2157 },
2158 "sparkline": {
@@ -2149,7 +2169,7 @@
2169 legend: 'sparkline',
2170 autoresize: false,
2171 max_updates_to_recreate: 5000,
2152 - pixels_per_point: 2,
2172 + pixels_per_point: 3,
2173 detects_dimensions_on_update: false
2174 },
2175 "peity": {
@@ -2166,7 +2186,7 @@
2186 legend: 'sparkline',
2187 autoresize: false,
2188 max_updates_to_recreate: 5000,
2169 - pixels_per_point: 2,
2189 + pixels_per_point: 3,
2190 detects_dimensions_on_update: false
2191 },
2192 "morris": {