Auto grid lines, lower minimum, disable estimates.
Show automatic grid lines with power-of-two spacing, avoiding ANR when trying to render thousands of gridlines. Lower minimum chart height to 50MB to give better view of linear data. Also disable estimates rendering. Bug: 5500204, 6005240 Change-Id: Iacfed11b32c0095c9c2d08bee6a1b5e29637de98
This commit is contained in:
@@ -237,7 +237,7 @@ public class ChartDataUsageView extends ChartView {
|
|||||||
final long maxSweep = Math.max(mSweepWarning.getValue(), mSweepLimit.getValue());
|
final long maxSweep = Math.max(mSweepWarning.getValue(), mSweepLimit.getValue());
|
||||||
final long maxSeries = Math.max(mSeries.getMaxVisible(), mDetailSeries.getMaxVisible());
|
final long maxSeries = Math.max(mSeries.getMaxVisible(), mDetailSeries.getMaxVisible());
|
||||||
final long maxVisible = Math.max(maxSeries, maxSweep) * 12 / 10;
|
final long maxVisible = Math.max(maxSeries, maxSweep) * 12 / 10;
|
||||||
final long maxDefault = Math.max(maxVisible, 2 * GB_IN_BYTES);
|
final long maxDefault = Math.max(maxVisible, 50 * MB_IN_BYTES);
|
||||||
newMax = Math.max(maxDefault, newMax);
|
newMax = Math.max(maxDefault, newMax);
|
||||||
|
|
||||||
// only invalidate when vertMax actually changed
|
// only invalidate when vertMax actually changed
|
||||||
@@ -636,15 +636,9 @@ public class ChartDataUsageView extends ChartView {
|
|||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
public float[] getTickPoints() {
|
public float[] getTickPoints() {
|
||||||
final long range = mMax - mMin;
|
final long range = mMax - mMin;
|
||||||
final long tickJump;
|
|
||||||
if (range < 6 * GB_IN_BYTES) {
|
|
||||||
tickJump = 256 * MB_IN_BYTES;
|
|
||||||
} else if (range < 12 * GB_IN_BYTES) {
|
|
||||||
tickJump = 512 * MB_IN_BYTES;
|
|
||||||
} else {
|
|
||||||
tickJump = 1 * GB_IN_BYTES;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// target about 16 ticks on screen, rounded to nearest power of 2
|
||||||
|
final long tickJump = roundUpToPowerOfTwo(range / 16);
|
||||||
final int tickCount = (int) (range / tickJump);
|
final int tickCount = (int) (range / tickJump);
|
||||||
final float[] tickPoints = new float[tickCount];
|
final float[] tickPoints = new float[tickCount];
|
||||||
long value = mMin;
|
long value = mMin;
|
||||||
@@ -681,4 +675,21 @@ public class ChartDataUsageView extends ChartView {
|
|||||||
return new int[] { start, end };
|
return new int[] { start, end };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static long roundUpToPowerOfTwo(long i) {
|
||||||
|
// NOTE: borrowed from Hashtable.roundUpToPowerOfTwo()
|
||||||
|
|
||||||
|
i--; // If input is a power of two, shift its high-order bit right
|
||||||
|
|
||||||
|
// "Smear" the high-order bit all the way to the right
|
||||||
|
i |= i >>> 1;
|
||||||
|
i |= i >>> 2;
|
||||||
|
i |= i >>> 4;
|
||||||
|
i |= i >>> 8;
|
||||||
|
i |= i >>> 16;
|
||||||
|
i |= i >>> 32;
|
||||||
|
|
||||||
|
i++;
|
||||||
|
|
||||||
|
return i > 0 ? i : Long.MAX_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -44,6 +44,8 @@ public class ChartNetworkSeriesView extends View {
|
|||||||
private static final String TAG = "ChartNetworkSeriesView";
|
private static final String TAG = "ChartNetworkSeriesView";
|
||||||
private static final boolean LOGD = false;
|
private static final boolean LOGD = false;
|
||||||
|
|
||||||
|
private static final boolean ESTIMATE_ENABLED = false;
|
||||||
|
|
||||||
private ChartAxis mHoriz;
|
private ChartAxis mHoriz;
|
||||||
private ChartAxis mVert;
|
private ChartAxis mVert;
|
||||||
|
|
||||||
@@ -252,6 +254,7 @@ public class ChartNetworkSeriesView extends View {
|
|||||||
|
|
||||||
mMax = totalData;
|
mMax = totalData;
|
||||||
|
|
||||||
|
if (ESTIMATE_ENABLED) {
|
||||||
// build estimated data
|
// build estimated data
|
||||||
mPathEstimate.moveTo(lastX, lastY);
|
mPathEstimate.moveTo(lastX, lastY);
|
||||||
|
|
||||||
@@ -282,6 +285,7 @@ public class ChartNetworkSeriesView extends View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mMaxEstimate = totalData;
|
mMaxEstimate = totalData;
|
||||||
|
}
|
||||||
|
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
@@ -291,7 +295,7 @@ public class ChartNetworkSeriesView extends View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setEstimateVisible(boolean estimateVisible) {
|
public void setEstimateVisible(boolean estimateVisible) {
|
||||||
mEstimateVisible = estimateVisible;
|
mEstimateVisible = ESTIMATE_ENABLED ? estimateVisible : false;
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user