From 5c962dd00930408dd18886dc2348f5dbc2896e20 Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Wed, 29 Oct 2014 21:41:41 +0100 Subject: [PATCH] better scaling of network statistic graphs --- htroot/NetworkHistory.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/htroot/NetworkHistory.java b/htroot/NetworkHistory.java index ea9ffb27f..49bcbd139 100644 --- a/htroot/NetworkHistory.java +++ b/htroot/NetworkHistory.java @@ -93,13 +93,16 @@ public class NetworkHistory { } // find correct scale - int maxpeers = 10; // to be measured by pre-scanning the db + int maxpeers = 100, minpeers = Integer.MAX_VALUE; // to be measured by pre-scanning the db for (Map row: rows) { for (String column: columns) { Long v = row.get(column); if (v != null) maxpeers = Math.max(maxpeers, (int) v.longValue()); + if (v != null && v.longValue() > 0) minpeers = Math.min(minpeers, (int) v.longValue()); } } + maxpeers = 10 * ((maxpeers / 9 * 10) / 10); + minpeers = 10 * ((minpeers * 9 / 10) / 10); final int leftborder = 30; final int rightborder = 10; final int width = post.getInt("width", 768 + leftborder + rightborder); @@ -108,7 +111,7 @@ public class NetworkHistory { final int topborder = 20; final int bottomborder = 20; final int vspace = height - topborder - bottomborder; - final int leftscale = maxpeers / 10; + final int leftscale = 10 * (maxpeers / 100); String timestr = maxtime + " HOURS"; if (maxtime > 24 && maxtime % 24 == 0) timestr = (maxtime / 24) + " DAYS"; if (maxtime == 168) timestr = "WEEK"; @@ -121,11 +124,11 @@ public class NetworkHistory { if (columns.contains("cC")) headline += ", ACTIVE SENIOR PEERS"; if (columns.contains("cD")) headline += ", PASSIVE SENIOR PEERS"; if (columns.contains("cP")) headline += ", POTENTIAL JUNIOR PEERS"; - if (columns.contains("cI")) headline = "YACY INDEX SIZE HISTORY: NUMBER OF DOCUMENTS"; - if (columns.contains("cR")) headline = "YACY INDEX SIZE HISTORY: NUMBER OF RWI ENTRIES"; + if (columns.contains("cI")) headline = "YACY PEER '" + sb.peers.myName() + "' INDEX SIZE HISTORY: NUMBER OF DOCUMENTS"; + if (columns.contains("cR")) headline = "YACY PEER '" + sb.peers.myName() + "' INDEX SIZE HISTORY: NUMBER OF RWI ENTRIES"; ChartPlotter chart = new ChartPlotter(width, height, 0xFFFFFFl, 0x000000l, 0xAAAAAAl, leftborder, rightborder, topborder, bottomborder, headline, "IN THE LAST " + timestr); chart.declareDimension(ChartPlotter.DIMENSION_BOTTOM, bottomscale, hspace / (maxtime / bottomscale), -maxtime, 0x000000l, 0xCCCCCCl, "TIME/HOURS"); - chart.declareDimension(ChartPlotter.DIMENSION_LEFT, leftscale, vspace * leftscale / maxpeers, 0, 0x008800l, null , columns.contains("cI") ? "DOCUMENTS" : columns.contains("cR") ? "RWIs" : "PEERS"); + chart.declareDimension(ChartPlotter.DIMENSION_LEFT, leftscale, 10 * ((vspace * leftscale / (maxpeers - minpeers)) / 10), minpeers, 0x008800l, null , columns.contains("cI") ? "DOCUMENTS" : columns.contains("cR") ? "RWIs" : "PEERS"); // write the data float x0, x1;