From 477f0884c036c9ecf33fcd037e420f1fbaf962c1 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Wed, 5 Mar 2008 01:42:58 +0000 Subject: [PATCH] implemented an algorithm that does the smarter Y-axis auto ranging. (#1246) git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@7319 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/model/Job.java | 1 + core/src/main/java/hudson/util/ChartUtil.java | 81 +++++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/core/src/main/java/hudson/model/Job.java b/core/src/main/java/hudson/model/Job.java index 9b917a2298..561cec045c 100644 --- a/core/src/main/java/hudson/model/Job.java +++ b/core/src/main/java/hudson/model/Job.java @@ -859,6 +859,7 @@ public abstract class Job, RunT extends Run + * The algorithm is based on Chebyshev's inequality, + * which states that given any number sequence, nore more than 1/(N^2) values are more than N x stddev away + * from the average. + * + *

+ * So the algorithm is to set Y-axis range so that we can see all data points that are within N x stddev + * of the average. Most of the time, Cebyshev's inequality is very conservative, so it shouldn't do + * much harm. + * + *

+ * When the algorithm does kick in, however, we can kick out at most 1 in N^2 data points. + * (So for example if N=3 then we can "fix" the graph as long as we only have less than 1/(3*3)=11.111...% bad data. + * + *

+ * Also see issue #1246. + */ + public static void adjustChebyshev(CategoryDataset dataset, NumberAxis yAxis) { + // first compute E(X) and Var(X) + double sum=0,sum2=0; + + final int nColumns = dataset.getColumnCount(); + final int nRows = dataset.getRowCount(); + for (int i=0; i