Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
[BZ 1080470] The unit in the new d3 charts is not refreshed correctly…
Browse files Browse the repository at this point in the history
…. Adjust the YAxis over to accommodate large values due to scale changes
  • Loading branch information
mtho11 committed Apr 19, 2014
1 parent 82b9324 commit 60c2a2e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -398,13 +398,16 @@ public String getJsonMetrics() {

sb.append(" \"barDuration\": \"" + barDurationString + "\", ");
sb.append(" \"high\":" + newHigh.getValue() + ",");
sb.append(" \"highFormatted\":\"" + MeasurementConverterClient.format(measurement.getHighValue(),definition.getUnits(), true,0,3) + "\",");
sb.append(" \"low\":" + cleanseLow(newLow.getValue(), newAvg.getValue(), newHigh.getValue()) + ",");
sb.append(" \"y\":" + newAvg.getValue() + "},");
sb.append(" \"lowFormatted\":\"" + MeasurementConverterClient.format(cleanseLow(measurement.getLowValue(), measurement.getValue(), measurement.getHighValue()),definition.getUnits(),true,0,3) + "\",");
sb.append(" \"avg\":" + newAvg.getValue() + ",");
sb.append(" \"avgFormatted\":\"" + MeasurementConverterClient.format(measurement.getValue(), definition.getUnits(),true,0,3) + "\"},");
} else {
// give it some values so that we dont have NaN
sb.append(" \"high\":0,");
sb.append(" \"low\":0,");
sb.append(" \"y\":0,");
sb.append(" \"avg\":0,");
sb.append(" \"nodata\":true },");
}
if (!sb.toString().endsWith("},")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public native void drawJsniChart() /*-{
var availabilityGraph = function () {
var margin = {top: 5, right: 5, bottom: 5, left: 40},
var margin = {top: 5, right: 5, bottom: 5, left: 90},
barOffset = 10,
width = 750 - margin.left - margin.right + barOffset,
height = 40 - margin.top - margin.bottom;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ public native void drawJsniChart() /*-{
// Define the Stacked Bar Graph function using the module pattern
var metricStackedBarGraph = function () {
// privates
var margin = {top: 10, right: 5, bottom: 5, left: 40},
margin2 = {top: 150, right: 5, bottom: 5, left: 0},
var margin = {top: 10, right: 5, bottom: 5, left: 90},
margin2 = {top: 150, right: 5, bottom: 5, left: 90},
width = 750 - margin.left - margin.right,
adjustedChartHeight = chartContext.chartHeight - 50,
height = adjustedChartHeight - margin.top - margin.bottom,
Expand Down Expand Up @@ -155,11 +155,11 @@ function determineScale() {
avgFiltered = chartContext.data.filter(function (d) {
if (d.nodata !== 'true') {
return d.y;
return d.avg;
}
});
avg = $wnd.d3.mean(avgFiltered.map(function (d) {
return d.y;
return d.avg;
}));
peakFiltered = chartContext.data.filter(function (d) {
if (d.nodata !== 'true') {
Expand Down Expand Up @@ -363,18 +363,18 @@ function showFullMetricBarHover(d){
metricGraphTooltipDiv.select("#metricGraphTooltipMaxLabel")
.text(chartContext.peakChartTitle);
metricGraphTooltipDiv.select("#metricGraphTooltipMaxValue")
.text(d.high.toFixed(1));
.text(d.highFormatted);
metricGraphTooltipDiv.select("#metricGraphTooltipAvgLabel")
.text(chartContext.avgChartTitle);
metricGraphTooltipDiv.select("#metricGraphTooltipAvgValue")
.text(d.y.toFixed(1));
.text(d.avgFormatted);
metricGraphTooltipDiv.select("#metricGraphTooltipMinLabel")
.text(chartContext.minChartTitle);
metricGraphTooltipDiv.select("#metricGraphTooltipMinValue")
.text(d.low.toFixed(1));
.text(d.lowFormatted);
//Show the tooltip
Expand Down Expand Up @@ -490,14 +490,14 @@ function createStackedBars() {
return 0;
}
else {
return yScale(d.y) - yScale(d.high);
return yScale(d.avg) - yScale(d.high);
}
})
.attr("width", function () {
return calcBarWidth();
})
.attr("data-rhq-value", function (d) {
return d.y;
return d.avg;
})
.attr("opacity", 0.9)
.on("mouseover",function (d) {
Expand All @@ -521,14 +521,14 @@ function createStackedBars() {
return timeScale(d.x);
})
.attr("y", function (d) {
return isNaN(d.y) ? height : yScale(d.y);
return isNaN(d.avg) ? height : yScale(d.avg);
})
.attr("height", function (d) {
if (d.down || d.unknown || d.nodata) {
return 0;
}
else {
return yScale(d.low) - yScale(d.y);
return yScale(d.low) - yScale(d.avg);
}
})
.attr("width", function () {
Expand Down Expand Up @@ -567,7 +567,7 @@ function showSingleValueMetricBarHover(d){
singleValueGraphTooltipDiv.select("#singleValueTooltipValueLabel")
.text(chartContext.singleValueLabel);
singleValueGraphTooltipDiv.select("#singleValueTooltipValue")
.text(d.y.toFixed(1));
.text(d.avgFormatted);
//Show the tooltip
Expand All @@ -586,15 +586,15 @@ function showSingleValueMetricBarHover(d){
return timeScale(d.x);
})
.attr("y", function (d) {
return isNaN(d.y) ? height : yScale(d.y) - 2;
return isNaN(d.avg) ? height : yScale(d.avg) - 2;
})
.attr("height", function (d) {
if (d.down || d.unknown || d.nodata) {
return 0;
}
else {
if (d.low === d.high) {
return yScale(d.low) - yScale(d.y) + 2;
return yScale(d.low) - yScale(d.avg) + 2;
}
else {
return 0;
Expand Down Expand Up @@ -656,7 +656,7 @@ function createXandYAxes() {
.attr("class", "y axis")
.call(yAxis)
.append("text")
.attr("transform", "rotate(-90),translate( -60,0)")
.attr("transform", "rotate(-90),translate( -60,-30)")
.attr("y", -30)
.style("text-anchor", "end")
.text(chartContext.yAxisUnits === "NONE" ? "" : chartContext.yAxisUnits);
Expand All @@ -676,7 +676,7 @@ function createAvgLines() {
})
.y(function (d) {
if (showBarAvgTrendline) {
return yScale(d.y);
return yScale(d.avg);
}
else {
return NaN;
Expand Down

0 comments on commit 60c2a2e

Please sign in to comment.