Skip to content

Commit

Permalink
Closes-Bug:#1581650
Browse files Browse the repository at this point in the history
Handled the following in monitor infra config & Analytics nodes summary page

1)Irrespective of the response of chart queries legends will show all nodes
2)Add the tooltips for the legend which will show the node name
3)Fixed the issue, same node is getting assigned different colors across the charts in same page.
4)Added the number formatter utility and used in stackedbarchart counts.
	Formatter eg:
	2200 formats to 2.2 K decimals options is there.
Unit test results
---------------
Web Controller
-------------
PhantomJS 1.9.8 (Mac OS X 0.0.0): Executed 376 of 376 SUCCESS (3 mins 22.093 secs / 3 mins 10.173 secs)

Web Storage
----------
PhantomJS 1.9.8 (Mac OS X 0.0.0): Executed 84 of 84 SUCCESS (28.573 secs / 26.395 secs)

Web Server Manager
-----------------
PhantomJS 1.9.8 (Mac OS X 0.0.0): Executed 89 of 89 SUCCESS (25.292 secs / 23.72 secs)

Change-Id: If1d53961ab2b2ca7eeeb1abbd31203b692589202
(cherry picked from commit 8e77f10)
  • Loading branch information
vishnuvv committed Jul 31, 2016
1 parent c1817b1 commit a774930
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
24 changes: 24 additions & 0 deletions webroot/js/common/core.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1209,6 +1209,30 @@ define(['underscore'], function (_) {
}
return json;
};

this.numberFormatter = function(number, decimals) {
var units = ['', 'K', 'M', 'B', 'T'],
unit = units.length - 1,
kilo = 1000,
decimals = isNaN(decimals) ? 2 : Math.abs(decimals),
decPoint = '.';
for (var i=0; i < units.length; i++) {
if (number < Math.pow(kilo, i+1)) {
unit = i;
break;
}
}
number = number / Math.pow(kilo, unit);
var suffix = units[unit] ;
var sign = number < 0 ? '-' : '';
number = Math.abs(+number || 0);
var intPart = parseInt(number.toFixed(decimals), 10) + '';
if (Math.abs(number - intPart) > 0)
return sign + intPart + (decimals ? decPoint + Math.abs(number - intPart).toFixed(decimals).slice(2) : '') + " "+suffix;
else
return sign + intPart +" "+suffix;
};

};

function filterXML(xmlString, is4SystemLogs) {
Expand Down
6 changes: 4 additions & 2 deletions webroot/js/views/StackedBarChartWithFocusView.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ define([
var tickPadding = getValueByJsonPath(viewConfig,'chartOptions;tickPadding',10);
var showLegend = getValueByJsonPath(viewConfig,'chartOptions;showLegend',false);
var legendFn = getValueByJsonPath(viewConfig,'chartOptions;legendFn',null);
var colorMap = getValueByJsonPath(viewConfig,'chartOptions;colorMap',{});
var sliceTooltipFn = null;

//sliceTooltipFn is for portion of bar in stacked bar.
Expand Down Expand Up @@ -155,7 +156,7 @@ define([
.scale(y)
.orient("left")
.ticks(3)
.tickFormat(d3.format("d"))
.tickFormat(cowu.numberFormatter)
.innerTickSize(-width)
.outerTickSize(0)
.tickPadding(tickPadding);
Expand Down Expand Up @@ -343,7 +344,8 @@ define([
.attr("width", barWidth)
.attr("y", function(d) { return y(d.y1); })
.attr("height", function(d) { return y(d.y0) - y(d.y1); })
.style("fill", function(d) { return d.color; })
.style("fill", function(d) {
return colorMap[d.name] != null ? colorMap[d.name] : d.color; })
.on("mouseover", function(d) {
if (sliceTooltipFn != null &&
typeof sliceTooltipFn == 'function' && d.tooltip != false) {
Expand Down

0 comments on commit a774930

Please sign in to comment.