Issue #728 - Make graph scale to visible data when adding or removing data from graph
Change-Id: I44150e19b52436b7103226f6ce539b0e9536d072 Former-commit-id:94a1921f8b
[formerlyfb04389920
] [formerly0675868464
[formerly dd45abb6461510408a92e66e68a25222d45e9ecf]] Former-commit-id:0675868464
Former-commit-id:dc8a5420d4
This commit is contained in:
parent
a810e06c03
commit
e6647d5e9a
2 changed files with 43 additions and 2 deletions
|
@ -563,8 +563,10 @@ public class StatsDisplayCanvas extends Canvas {
|
|||
|
||||
gc.drawPolyline(yAxis);
|
||||
|
||||
double minVal = graphData.getMinValue();
|
||||
double maxVal = graphData.getMaxValue();
|
||||
Map<String, RGB> groupSettings = callback.getGroupSettings();
|
||||
|
||||
double minVal = graphData.getMinValue(groupSettings.keySet());
|
||||
double maxVal = graphData.getMaxValue(groupSettings.keySet());
|
||||
int numberTicks = 4;
|
||||
double inc = 5;
|
||||
double minScaleVal = 0;
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.HashMap;
|
|||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
|
@ -191,6 +192,44 @@ public class GraphData {
|
|||
return max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the smallest value in the data set.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public double getMinValue(Set<String> visibleDataSet) {
|
||||
double min = Double.MAX_VALUE;
|
||||
for (String key : statsDataMap.keySet()) {
|
||||
if (visibleDataSet.contains(key)) {
|
||||
double minVal = statsDataMap.get(key).getMinValue();
|
||||
if (minVal < min) {
|
||||
min = minVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return min;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the largest value in the data set.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public double getMaxValue(Set<String> visibleDataSet) {
|
||||
double max = Double.MIN_VALUE;
|
||||
for (String key : statsDataMap.keySet()) {
|
||||
if (visibleDataSet.contains(key)) {
|
||||
double maxVal = statsDataMap.get(key).getMaxValue();
|
||||
if (maxVal > max) {
|
||||
max = maxVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the time range for this object.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue