diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/analiytics-graphs/public/css/legend.css b/modules/distribution/src/repository/jaggeryapps/iotserver/units/analiytics-graphs/public/css/legend.css index 29c7358a..25787686 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/analiytics-graphs/public/css/legend.css +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/analiytics-graphs/public/css/legend.css @@ -7,6 +7,7 @@ padding: 12px 5px; border-radius: 2px; position: relative; + float: right; } .rickshaw_legend:hover { z-index: 10; @@ -70,4 +71,17 @@ .rickshaw_legend li:active { background: rgba(255, 255, 255, 0.2); border-radius: 3px; +} +.legend { + display: inline-block; + position: relative; + left: 8px; +} +.legend_container { + float: right; + padding-right: 10px; + width: 0; + z-index: 999; + position: relative; + opacity: 0.7; } \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/analytics/public/js/graph_util.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/analytics/public/js/graph_util.js index 3a5f51f7..3278f558 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/analytics/public/js/graph_util.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/analytics/public/js/graph_util.js @@ -7,12 +7,12 @@ var endDate = new Date(currentDay.getTime()); var groupId; -var color = ['#c05020','#30c020', '#6060c0', '#170B3B','#5E610B', '#2F0B3A', '#FF4000', '#2F0B3A', 'steelblue']; +var color = ['#c05020', '#30c020', '#6060c0', '#170B3B', '#5E610B', '#2F0B3A', '#FF4000', '#2F0B3A', 'steelblue']; // create a custom bar renderer that shift bars Rickshaw.Graph.Renderer.BinaryBar = Rickshaw.Class.create(Rickshaw.Graph.Renderer.Bar, { name: 'binary_bar', - render: function(args) { + render: function (args) { args = args || {}; @@ -25,36 +25,46 @@ Rickshaw.Graph.Renderer.BinaryBar = Rickshaw.Class.create(Rickshaw.Graph.Rendere var barWidth = this.barWidth(series.active()[0]); var barXOffset = 0; - var activeSeriesCount = series.filter( function(s) { return !s.disabled; } ).length; + var activeSeriesCount = series.filter(function (s) { + return !s.disabled; + }).length; var seriesBarWidth = this.unstack ? barWidth / activeSeriesCount : barWidth; - var transform = function(d) { + var transform = function (d) { // add a matrix transform for negative values - var matrix = [ 1, 0, 0, (d.y < 0 ? -1 : 1), 0, (d.y < 0 ? graph.y.magnitude(Math.abs(d.y)) * 2 : 0) ]; + var matrix = [1, 0, 0, (d.y < 0 ? -1 : 1), 0, (d.y < 0 ? graph.y.magnitude(Math.abs(d.y)) * 2 : 0)]; return "matrix(" + matrix.join(',') + ")"; }; var index = 0; - series.forEach( function(series) { + series.forEach(function (series) { if (series.disabled) return; var nodes = vis.selectAll("path") - .data(series.stack.filter( function(d) { return d.y !== null } )) + .data(series.stack.filter(function (d) { + return d.y !== null + })) .enter().append("svg:rect") - .attr("x", function(d) { return graph.x(d.x) + barXOffset }) - .attr("y", function(d) { return ((graph.y(index + Math.abs(d.y))) * (d.y < 0 ? -1 : 1 )) }) + .attr("x", function (d) { + return graph.x(d.x) + barXOffset + }) + .attr("y", function (d) { + return ((graph.y(index + Math.abs(d.y))) * (d.y < 0 ? -1 : 1 )) + }) .attr("width", seriesBarWidth) - .attr("height", function(d) { return graph.y.magnitude(Math.abs(d.y)) }) + .attr("height", function (d) { + return graph.y.magnitude(Math.abs(d.y)) + }) .attr("transform", transform); index++; - Array.prototype.forEach.call(nodes[0], function(n) { + Array.prototype.forEach.call(nodes[0], function (n) { n.setAttribute('fill', series.color); - } ); + }); if (this.unstack) barXOffset += seriesBarWidth; - }, this ); + }, this); } }); @@ -267,7 +277,7 @@ function updateGraphs(stats) { scaleGraphs(); } -function drawLineGraph(graphId, chartDataRaw){ +function drawLineGraph(graphId, chartDataRaw) { var chartWrapperElmId = "#canvas-wrapper" + graphId; var graphWidth = $(chartWrapperElmId).width() - 50; if (chartDataRaw.length == 0) { @@ -279,8 +289,10 @@ function drawLineGraph(graphId, chartDataRaw){ var sliderDiv = "slider" + graphId; var x_axis = "x_axis" + graphId; var y_axis = "y_axis" + graphId; - $(chartWrapperElmId).html("").html('