[gnome-boxes] resource-graph: Adaptive ymax
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] resource-graph: Adaptive ymax
- Date: Tue, 24 Feb 2015 17:05:08 +0000 (UTC)
commit fd99f07ae7e3d5d90d48581df4f04d4f87ce263a
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Tue Feb 24 14:51:09 2015 +0000
resource-graph: Adaptive ymax
For the case of data being I/O bytes written/read, we can't just assume a
particular fixed value for max on y-axis (ymax) since I/O speed varies a
lot across different hardware. The result of a fixed ymax is typically
graphs fluctuating between 0 and ymax and that is not just useless but
also looks ugly.
Lets reset ymax to the value of data point if it happens to be greater
than current ymax.
src/resource-graph.vala | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/src/resource-graph.vala b/src/resource-graph.vala
index 71c83b3..06e93d5 100644
--- a/src/resource-graph.vala
+++ b/src/resource-graph.vala
@@ -5,6 +5,11 @@ private class Boxes.ResourceGraph: Gtk.DrawingArea {
private double[] _points;
public double[] points { get { return _points; }
set {
+ for (var i = 0; i < value.length; i++) {
+ if (value[i] > ymax)
+ ymax = value[i];
+ }
+
_points = value;
queue_draw ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]