Skip to content

Commit

Permalink
Closes-Bug:#1581650
Browse files Browse the repository at this point in the history
Did the following changes,
1)Using the start time and end time in query response for bucketizing the data, instead of the min & max time stamp of
response to make sure always the bars are of same width irrespective of data
2)When there is not data for a given bucket, adding 0.01 time the max value as data to improve look and feel.

Change-Id: Ice947a7bff468992e111f20b64af5ba3ca5c359a
  • Loading branch information
vishnuvv committed Jul 29, 2016
1 parent 94e502f commit 02b72c5
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions webroot/js/views/StackedBarChartWithFocusView.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ define([
sliceTooltipFn = viewConfig['chartOptions']['sliceTooltipFn'];
}
if (contrail.checkIfFunction(viewConfig['parseFn'])) {
data = viewConfig['parseFn'](data);
data = viewConfig['parseFn'](data, chartViewModel);
}
if ($(selector).find('.stacked-bar-chart-container').find("svg") != null &&
$(selector).find('.stacked-bar-chart-container').find("svg").length > 0) {
Expand Down Expand Up @@ -212,6 +212,20 @@ define([
}
var dateExtent;
var yAxisMaxValue = d3.max(data, function(d) { return d.total; });
if (yAxisMaxValue == 0) {
yAxisMaxValue = height;
}
//inserting the dummy values where the no data in the given bucket
$.each(data, function (idx, obj) {
if (obj.total == 0) {
ifNull(obj['counts'], []).push({
tooltip: false,
color: obj.colorCodes[0],
y0: 0,
y1: yAxisMaxValue * 0.01
})
}
});
yAxisMaxValue = yAxisMaxValue + (yAxisOffset/100) * yAxisMaxValue;
var yExtent = [0, yAxisMaxValue];
var filter = cfDataSource != null ? cfDataSource.getFilter('timeFilter') : null;
Expand Down Expand Up @@ -332,7 +346,7 @@ define([
.style("fill", function(d) { return d.color; })
.on("mouseover", function(d) {
if (sliceTooltipFn != null &&
typeof sliceTooltipFn == 'function') {
typeof sliceTooltipFn == 'function' && d.tooltip != false) {
var event = d3.event;
tooltipDiv.transition()
.duration(200)
Expand Down

0 comments on commit 02b72c5

Please sign in to comment.