From: Sasa M. <sa...@us...> - 2004-06-11 07:59:06
|
Update of /cvsroot/jrobin/src/org/jrobin/demo In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1827/org/jrobin/demo Modified Files: PlottableDemo.java Log Message: minor changes Index: PlottableDemo.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/demo/PlottableDemo.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PlottableDemo.java 9 Jun 2004 12:09:23 -0000 1.1 --- PlottableDemo.java 11 Jun 2004 07:58:51 -0000 1.2 *************** *** 74,77 **** --- 74,78 ---- createGraph15(); createGraph16(); + createGraph17(); } *************** *** 96,114 **** CubicSplineInterpolator i2 = new CubicSplineInterpolator(t, x); // graph definition ! RrdGraphDef gdef = new RrdGraphDef(t0, t1); ! gdef.setTitle("Plottable demonstration"); ! gdef.setTimeAxisLabel("days of our lives"); ! gdef.setVerticalLabel("inspiration"); ! gdef.datasource("real", p); ! gdef.datasource("linear", i1); ! gdef.datasource("spline", i2); ! gdef.line("real", Color.BLUE, "Real values", 1); ! gdef.line("linear", Color.RED, "Linear interpolation", 1); ! gdef.line("spline", Color.MAGENTA, "Spline interpolation@r", 1); ! gdef.setTimeAxis(TimeAxisUnit.DAY, 1, TimeAxisUnit.DAY, 1, "dd", true); ! RrdGraph g = new RrdGraph(gdef); ! String filename = Util.getJRobinDemoPath("plottable1.png"); ! g.saveAsPNG(filename, 400, 200); ! System.out.println("Graph1 saved to " + filename); } --- 97,112 ---- CubicSplineInterpolator i2 = new CubicSplineInterpolator(t, x); // graph definition ! RrdGraphDef gDef = new RrdGraphDef(t0, t1); ! gDef.setTitle("Plottable demonstration"); ! gDef.setTimeAxisLabel("days of our lives"); ! gDef.setVerticalLabel("inspiration"); ! gDef.datasource("real", p); ! gDef.datasource("linear", i1); ! gDef.datasource("spline", i2); ! gDef.line("real", Color.BLUE, "Real values", 1); ! gDef.line("linear", Color.RED, "Linear interpolation", 1); ! gDef.line("spline", Color.MAGENTA, "Spline interpolation@r", 1); ! gDef.setTimeAxis(TimeAxisUnit.DAY, 1, TimeAxisUnit.DAY, 1, "dd", true); ! createGraph(gDef); } *************** *** 138,145 **** gDef.gprint("spline", "AVERAGE", "Average spline value: @0 inches@r"); gDef.gprint("linear", "AVERAGE", "Average linear value: @0 inches@r"); ! RrdGraph graph = new RrdGraph(gDef); ! String filename = Util.getJRobinDemoPath("plottable2.png"); ! graph.saveAsPNG(filename, 300, 100); ! System.out.println("Graph2 saved to " + filename); } --- 136,140 ---- gDef.gprint("spline", "AVERAGE", "Average spline value: @0 inches@r"); gDef.gprint("linear", "AVERAGE", "Average linear value: @0 inches@r"); ! createGraph(gDef); } *************** *** 156,163 **** gDef.setTimeAxis(TimeAxisUnit.MONTH, 1, TimeAxisUnit.MONTH, 1, "MMM", false); gDef.comment("Data provided by SourceForge.net@r"); ! RrdGraph graph = new RrdGraph(gDef); ! String filename = Util.getJRobinDemoPath("plottable3.png"); ! graph.saveAsPNG(filename, 400, 200); ! System.out.println("Graph3 saved to " + filename); } --- 151,155 ---- gDef.setTimeAxis(TimeAxisUnit.MONTH, 1, TimeAxisUnit.MONTH, 1, "MMM", false); gDef.comment("Data provided by SourceForge.net@r"); ! createGraph(gDef); } *************** *** 174,181 **** gDef.setTimeAxis(TimeAxisUnit.MONTH, 1, TimeAxisUnit.MONTH, 1, "MMM", false); gDef.comment("Data provided by SourceForge.net@r"); ! RrdGraph graph = new RrdGraph(gDef); ! String filename = Util.getJRobinDemoPath("plottable4.png"); ! graph.saveAsPNG(filename, 400, 200); ! System.out.println("Graph4 saved to " + filename); } --- 166,170 ---- gDef.setTimeAxis(TimeAxisUnit.MONTH, 1, TimeAxisUnit.MONTH, 1, "MMM", false); gDef.comment("Data provided by SourceForge.net@r"); ! createGraph(gDef); } *************** *** 200,215 **** gDef.gprint("ratio", "AVERAGE", "Average number of page hits per download: @0@r"); gDef.comment("Data provided by SourceForge.net@r"); ! RrdGraph graph = new RrdGraph(gDef); ! String filename = Util.getJRobinDemoPath("plottable5.png"); ! graph.saveAsPNG(filename, 400, 200); ! System.out.println("Graph5 saved to " + filename); } private void createGraph6() throws RrdException, IOException { CubicSplineInterpolator hitsInterpolator = new CubicSplineInterpolator(SF_TIMESTAMPS, SF_PAGE_HITS); RrdGraphDef gDef = new RrdGraphDef(SF_TIMESTAMPS[0], SF_TIMESTAMPS[SF_TIMESTAMPS.length - 1]); ! gDef.setTitle("Trick graph 1"); gDef.setTimeAxisLabel("month"); gDef.setVerticalLabel("hits"); --- 189,223 ---- gDef.gprint("ratio", "AVERAGE", "Average number of page hits per download: @0@r"); gDef.comment("Data provided by SourceForge.net@r"); ! createGraph(gDef); } private void createGraph6() throws RrdException, IOException { + LinearInterpolator hitsInterpolator = + new LinearInterpolator(SF_TIMESTAMPS, SF_PAGE_HITS); + LinearInterpolator trendInterpolator = new LinearInterpolator(SF_TIMESTAMPS, SF_PAGE_HITS); + trendInterpolator.setInterpolationMethod(LinearInterpolator.INTERPOLATE_REGRESSION); + RrdGraphDef gDef = new RrdGraphDef(SF_TIMESTAMPS[0], SF_TIMESTAMPS[SF_TIMESTAMPS.length - 1]); + gDef.setTitle("Trend report"); + gDef.setTimeAxisLabel("month"); + gDef.setVerticalLabel("hits"); + gDef.datasource("hits", hitsInterpolator); + gDef.datasource("trend", trendInterpolator); + gDef.datasource("diff", "hits,trend,-"); + gDef.datasource("absdiff", "diff,ABS"); + gDef.area("trend", null, null); + gDef.stack("diff", Color.YELLOW, "difference"); + gDef.line("hits", Color.RED, "real page hits"); + gDef.line("trend", Color.BLUE, "trend@L"); + gDef.gprint("absdiff", "AVERAGE", "Average difference: @0@r"); + gDef.setTimeAxis(TimeAxisUnit.MONTH, 1, TimeAxisUnit.MONTH, 1, "MMM", false); + createGraph(gDef); + } + + private void createGraph7() throws RrdException, IOException { CubicSplineInterpolator hitsInterpolator = new CubicSplineInterpolator(SF_TIMESTAMPS, SF_PAGE_HITS); RrdGraphDef gDef = new RrdGraphDef(SF_TIMESTAMPS[0], SF_TIMESTAMPS[SF_TIMESTAMPS.length - 1]); ! gDef.setTitle("Trick graph"); gDef.setTimeAxisLabel("month"); gDef.setVerticalLabel("hits"); *************** *** 223,238 **** gDef.line("hits", Color.WHITE, null, 1); gDef.setTimeAxis(TimeAxisUnit.MONTH, 1, TimeAxisUnit.MONTH, 1, "MMM", false); ! RrdGraph graph = new RrdGraph(gDef); ! String filename = Util.getJRobinDemoPath("plottable6.png"); ! graph.saveAsPNG(filename, 400, 200); ! System.out.println("Graph6 saved to " + filename); } ! private void createGraph7() throws RrdException, IOException { CubicSplineInterpolator hitsInterpolator = ! new CubicSplineInterpolator(SF_TIMESTAMPS, SF_PAGE_HITS); RrdGraphDef gDef = new RrdGraphDef(SF_TIMESTAMPS[0], SF_TIMESTAMPS[SF_TIMESTAMPS.length - 1]); ! gDef.setTitle("Trick graph 2"); gDef.setTimeAxisLabel("month"); gDef.setVerticalLabel("hits"); --- 231,243 ---- gDef.line("hits", Color.WHITE, null, 1); gDef.setTimeAxis(TimeAxisUnit.MONTH, 1, TimeAxisUnit.MONTH, 1, "MMM", false); ! createGraph(gDef); } ! private void createGraph8() throws RrdException, IOException { CubicSplineInterpolator hitsInterpolator = ! new CubicSplineInterpolator(SF_TIMESTAMPS, SF_PAGE_HITS); RrdGraphDef gDef = new RrdGraphDef(SF_TIMESTAMPS[0], SF_TIMESTAMPS[SF_TIMESTAMPS.length - 1]); ! gDef.setTitle("Trick graph"); gDef.setTimeAxisLabel("month"); gDef.setVerticalLabel("hits"); *************** *** 251,261 **** gDef.setTimeAxis(TimeAxisUnit.MONTH, 1, TimeAxisUnit.MONTH, 1, "MMM", false); gDef.gprint("hits", "AVERAGE", "Average: @0@r"); ! RrdGraph graph = new RrdGraph(gDef); ! String filename = Util.getJRobinDemoPath("plottable7.png"); ! graph.saveAsPNG(filename, 400, 200); ! System.out.println("Graph7 saved to " + filename); } ! private void createGraph8() throws RrdException, IOException { GregorianCalendar[] times = { SF_TIMESTAMPS[0], SF_TIMESTAMPS[SF_TIMESTAMPS.length - 1] }; double[] values = { SF_PAGE_HITS[0], SF_PAGE_HITS[SF_PAGE_HITS.length - 1] }; --- 256,263 ---- gDef.setTimeAxis(TimeAxisUnit.MONTH, 1, TimeAxisUnit.MONTH, 1, "MMM", false); gDef.gprint("hits", "AVERAGE", "Average: @0@r"); ! createGraph(gDef); } ! private void createGraph9() throws RrdException, IOException { GregorianCalendar[] times = { SF_TIMESTAMPS[0], SF_TIMESTAMPS[SF_TIMESTAMPS.length - 1] }; double[] values = { SF_PAGE_HITS[0], SF_PAGE_HITS[SF_PAGE_HITS.length - 1] }; *************** *** 265,269 **** RrdGraphDef gDef = new RrdGraphDef(SF_TIMESTAMPS[0], SF_TIMESTAMPS[SF_TIMESTAMPS.length - 1]); ! gDef.setTitle("Trick graph 3"); gDef.setTimeAxisLabel("month"); gDef.setVerticalLabel("hits"); --- 267,271 ---- RrdGraphDef gDef = new RrdGraphDef(SF_TIMESTAMPS[0], SF_TIMESTAMPS[SF_TIMESTAMPS.length - 1]); ! gDef.setTitle("Trick graph"); gDef.setTimeAxisLabel("month"); gDef.setVerticalLabel("hits"); *************** *** 276,286 **** gDef.line("trend", Color.RED, "trend@L"); gDef.setTimeAxis(TimeAxisUnit.MONTH, 1, TimeAxisUnit.MONTH, 1, "MMM", false); ! RrdGraph graph = new RrdGraph(gDef); ! String filename = Util.getJRobinDemoPath("plottable8.png"); ! graph.saveAsPNG(filename, 400, 200); ! System.out.println("Graph8 saved to " + filename); } ! private void createGraph9() throws RrdException, IOException { final int GRADIENT_STEPS = 30; final Color color1 = Color.RED, color2 = Color.YELLOW; --- 278,285 ---- gDef.line("trend", Color.RED, "trend@L"); gDef.setTimeAxis(TimeAxisUnit.MONTH, 1, TimeAxisUnit.MONTH, 1, "MMM", false); ! createGraph(gDef); } ! private void createGraph10() throws RrdException, IOException { final int GRADIENT_STEPS = 30; final Color color1 = Color.RED, color2 = Color.YELLOW; *************** *** 288,292 **** new CubicSplineInterpolator(SF_TIMESTAMPS, SF_PAGE_HITS); RrdGraphDef gDef = new RrdGraphDef(SF_TIMESTAMPS[0], SF_TIMESTAMPS[SF_TIMESTAMPS.length - 1]); ! gDef.setTitle("Trick graph 4"); gDef.setTimeAxisLabel("month"); gDef.setVerticalLabel("hits"); --- 287,291 ---- new CubicSplineInterpolator(SF_TIMESTAMPS, SF_PAGE_HITS); RrdGraphDef gDef = new RrdGraphDef(SF_TIMESTAMPS[0], SF_TIMESTAMPS[SF_TIMESTAMPS.length - 1]); ! gDef.setTitle("Trick graph"); gDef.setTimeAxisLabel("month"); gDef.setVerticalLabel("hits"); *************** *** 301,311 **** gDef.line("hits", Color.BLACK, "Number of page hits"); gDef.setTimeAxis(TimeAxisUnit.MONTH, 1, TimeAxisUnit.MONTH, 1, "MMM", false); ! RrdGraph graph = new RrdGraph(gDef); ! String filename = Util.getJRobinDemoPath("plottable9.png"); ! graph.saveAsPNG(filename, 400, 200); ! System.out.println("Graph9 saved to " + filename); } ! private void createGraph10() throws RrdException, IOException { final int GRADIENT_STEPS = 30; final Color color1 = Color.RED, color2 = Color.YELLOW; --- 300,307 ---- gDef.line("hits", Color.BLACK, "Number of page hits"); gDef.setTimeAxis(TimeAxisUnit.MONTH, 1, TimeAxisUnit.MONTH, 1, "MMM", false); ! createGraph(gDef); } ! private void createGraph11() throws RrdException, IOException { final int GRADIENT_STEPS = 30; final Color color1 = Color.RED, color2 = Color.YELLOW; *************** *** 313,317 **** new CubicSplineInterpolator(SF_TIMESTAMPS, SF_PAGE_HITS); RrdGraphDef gDef = new RrdGraphDef(SF_TIMESTAMPS[0], SF_TIMESTAMPS[SF_TIMESTAMPS.length - 1]); ! gDef.setTitle("Trick graph 5"); gDef.setTimeAxisLabel("month"); gDef.setVerticalLabel("hits"); --- 309,313 ---- new CubicSplineInterpolator(SF_TIMESTAMPS, SF_PAGE_HITS); RrdGraphDef gDef = new RrdGraphDef(SF_TIMESTAMPS[0], SF_TIMESTAMPS[SF_TIMESTAMPS.length - 1]); ! gDef.setTitle("Trick graph"); gDef.setTimeAxisLabel("month"); gDef.setVerticalLabel("hits"); *************** *** 327,337 **** gDef.setTimeAxis(TimeAxisUnit.MONTH, 1, TimeAxisUnit.MONTH, 1, "MMM", false); gDef.setCanvasColor(color1); ! RrdGraph graph = new RrdGraph(gDef); ! String filename = Util.getJRobinDemoPath("plottable10.png"); ! graph.saveAsPNG(filename, 400, 200); ! System.out.println("Graph10 saved to " + filename); } ! private void createGraph11() throws RrdException, IOException { final int GRADIENT_STEPS = 30; final Color color1 = Color.YELLOW, color2 = Color.RED; --- 323,330 ---- gDef.setTimeAxis(TimeAxisUnit.MONTH, 1, TimeAxisUnit.MONTH, 1, "MMM", false); gDef.setCanvasColor(color1); ! createGraph(gDef); } ! private void createGraph12() throws RrdException, IOException { final int GRADIENT_STEPS = 30; final Color color1 = Color.YELLOW, color2 = Color.RED; *************** *** 339,343 **** new CubicSplineInterpolator(SF_TIMESTAMPS, SF_PAGE_HITS); RrdGraphDef gDef = new RrdGraphDef(SF_TIMESTAMPS[0], SF_TIMESTAMPS[SF_TIMESTAMPS.length - 1]); ! gDef.setTitle("Trick graph 6"); gDef.setTimeAxisLabel("month"); gDef.setVerticalLabel("hits"); --- 332,336 ---- new CubicSplineInterpolator(SF_TIMESTAMPS, SF_PAGE_HITS); RrdGraphDef gDef = new RrdGraphDef(SF_TIMESTAMPS[0], SF_TIMESTAMPS[SF_TIMESTAMPS.length - 1]); ! gDef.setTitle("Trick graph"); gDef.setTimeAxisLabel("month"); gDef.setVerticalLabel("hits"); *************** *** 353,363 **** gDef.line("hits", color2, "Estimated number of page hits"); gDef.setTimeAxis(TimeAxisUnit.MONTH, 1, TimeAxisUnit.MONTH, 1, "MMM", false); ! RrdGraph graph = new RrdGraph(gDef); ! String filename = Util.getJRobinDemoPath("plottable11.png"); ! graph.saveAsPNG(filename, 400, 200); ! System.out.println("Graph11 saved to " + filename); } ! private void createGraph12() throws RrdException, IOException { final int GRADIENT_STEPS = 15; final Color color1 = Color.LIGHT_GRAY, color2 = Color.WHITE; --- 346,353 ---- gDef.line("hits", color2, "Estimated number of page hits"); gDef.setTimeAxis(TimeAxisUnit.MONTH, 1, TimeAxisUnit.MONTH, 1, "MMM", false); ! createGraph(gDef); } ! private void createGraph13() throws RrdException, IOException { final int GRADIENT_STEPS = 15; final Color color1 = Color.LIGHT_GRAY, color2 = Color.WHITE; *************** *** 365,369 **** new CubicSplineInterpolator(SF_TIMESTAMPS, SF_PAGE_HITS); RrdGraphDef gDef = new RrdGraphDef(SF_TIMESTAMPS[0], SF_TIMESTAMPS[SF_TIMESTAMPS.length - 1]); ! gDef.setTitle("Trick graph 7"); gDef.setTimeAxisLabel("month"); gDef.setVerticalLabel("hits"); --- 355,359 ---- new CubicSplineInterpolator(SF_TIMESTAMPS, SF_PAGE_HITS); RrdGraphDef gDef = new RrdGraphDef(SF_TIMESTAMPS[0], SF_TIMESTAMPS[SF_TIMESTAMPS.length - 1]); ! gDef.setTitle("Trick graph"); gDef.setTimeAxisLabel("month"); gDef.setVerticalLabel("hits"); *************** *** 375,385 **** gDef.line("hits", color1, "Estimated number of page hits"); gDef.setTimeAxis(TimeAxisUnit.MONTH, 1, TimeAxisUnit.MONTH, 1, "MMM", false); ! RrdGraph graph = new RrdGraph(gDef); ! String filename = Util.getJRobinDemoPath("plottable12.png"); ! graph.saveAsPNG(filename, 400, 200); ! System.out.println("Graph12 saved to " + filename); } ! private void createGraph13() throws RrdException, IOException { final int GRADIENT_STEPS = 20; final double GRADIENT_WIDTH = 2000.0; --- 365,372 ---- gDef.line("hits", color1, "Estimated number of page hits"); gDef.setTimeAxis(TimeAxisUnit.MONTH, 1, TimeAxisUnit.MONTH, 1, "MMM", false); ! createGraph(gDef); } ! private void createGraph14() throws RrdException, IOException { final int GRADIENT_STEPS = 20; final double GRADIENT_WIDTH = 2000.0; *************** *** 388,392 **** new CubicSplineInterpolator(SF_TIMESTAMPS, SF_PAGE_HITS); RrdGraphDef gDef = new RrdGraphDef(SF_TIMESTAMPS[0], SF_TIMESTAMPS[SF_TIMESTAMPS.length - 1]); ! gDef.setTitle("Trick graph 8"); gDef.setTimeAxisLabel("month"); gDef.setVerticalLabel("hits"); --- 375,379 ---- new CubicSplineInterpolator(SF_TIMESTAMPS, SF_PAGE_HITS); RrdGraphDef gDef = new RrdGraphDef(SF_TIMESTAMPS[0], SF_TIMESTAMPS[SF_TIMESTAMPS.length - 1]); ! gDef.setTitle("Trick graph"); gDef.setTimeAxisLabel("month"); gDef.setVerticalLabel("hits"); *************** *** 400,410 **** } gDef.setTimeAxis(TimeAxisUnit.MONTH, 1, TimeAxisUnit.MONTH, 1, "MMM", false); ! RrdGraph graph = new RrdGraph(gDef); ! String filename = Util.getJRobinDemoPath("plottable13.png"); ! graph.saveAsPNG(filename, 400, 200); ! System.out.println("Graph13 saved to " + filename); } ! private void createGraph14() throws RrdException, IOException { final int STEPS = 20; final Color color1 = Color.BLACK, color2 = Color.RED; --- 387,394 ---- } gDef.setTimeAxis(TimeAxisUnit.MONTH, 1, TimeAxisUnit.MONTH, 1, "MMM", false); ! createGraph(gDef); } ! private void createGraph15() throws RrdException, IOException { final int STEPS = 20; final Color color1 = Color.BLACK, color2 = Color.RED; *************** *** 412,416 **** new CubicSplineInterpolator(SF_TIMESTAMPS, SF_PAGE_HITS); RrdGraphDef gDef = new RrdGraphDef(SF_TIMESTAMPS[0], SF_TIMESTAMPS[SF_TIMESTAMPS.length - 1]); ! gDef.setTitle("Trick graph 9"); gDef.setTimeAxisLabel("month"); gDef.setVerticalLabel("hits"); --- 396,400 ---- new CubicSplineInterpolator(SF_TIMESTAMPS, SF_PAGE_HITS); RrdGraphDef gDef = new RrdGraphDef(SF_TIMESTAMPS[0], SF_TIMESTAMPS[SF_TIMESTAMPS.length - 1]); ! gDef.setTitle("Trick graph"); gDef.setTimeAxisLabel("month"); gDef.setVerticalLabel("hits"); *************** *** 425,435 **** gDef.line("hits", Color.BLUE, "page hits", 2); gDef.setTimeAxis(TimeAxisUnit.MONTH, 1, TimeAxisUnit.MONTH, 1, "MMM", false); ! RrdGraph graph = new RrdGraph(gDef); ! String filename = Util.getJRobinDemoPath("plottable14.png"); ! graph.saveAsPNG(filename, 400, 200); ! System.out.println("Graph14 saved to " + filename); } ! private void createGraph15() throws RrdException, IOException { final int STEPS = 20; final Color color1 = Color.BLACK, color2 = Color.RED; --- 409,416 ---- gDef.line("hits", Color.BLUE, "page hits", 2); gDef.setTimeAxis(TimeAxisUnit.MONTH, 1, TimeAxisUnit.MONTH, 1, "MMM", false); ! createGraph(gDef); } ! private void createGraph16() throws RrdException, IOException { final int STEPS = 20; final Color color1 = Color.BLACK, color2 = Color.RED; *************** *** 438,442 **** hitsInterpolator.setInterpolationMethod(LinearInterpolator.INTERPOLATE_LEFT); RrdGraphDef gDef = new RrdGraphDef(SF_TIMESTAMPS[0], SF_TIMESTAMPS[SF_TIMESTAMPS.length - 1]); ! gDef.setTitle("Trick graph 10"); gDef.setTimeAxisLabel("month"); gDef.setVerticalLabel("hits"); --- 419,423 ---- hitsInterpolator.setInterpolationMethod(LinearInterpolator.INTERPOLATE_LEFT); RrdGraphDef gDef = new RrdGraphDef(SF_TIMESTAMPS[0], SF_TIMESTAMPS[SF_TIMESTAMPS.length - 1]); ! gDef.setTitle("Trick graph"); gDef.setTimeAxisLabel("month"); gDef.setVerticalLabel("hits"); *************** *** 451,461 **** gDef.line("hits", Color.BLUE, "page hits", 2); gDef.setTimeAxis(TimeAxisUnit.MONTH, 1, TimeAxisUnit.MONTH, 1, "MMM", false); ! RrdGraph graph = new RrdGraph(gDef); ! String filename = Util.getJRobinDemoPath("plottable15.png"); ! graph.saveAsPNG(filename, 400, 200); ! System.out.println("Graph15 saved to " + filename); } ! private void createGraph16() throws RrdException, IOException { LinearInterpolator hitsInterpolator = new LinearInterpolator(SF_TIMESTAMPS, SF_PAGE_HITS); --- 432,441 ---- gDef.line("hits", Color.BLUE, "page hits", 2); gDef.setTimeAxis(TimeAxisUnit.MONTH, 1, TimeAxisUnit.MONTH, 1, "MMM", false); ! createGraph(gDef); } ! private void createGraph17() throws RrdException, IOException { ! final int STEPS = 20; ! final Color color1 = Color.YELLOW, color2 = Color.RED; LinearInterpolator hitsInterpolator = new LinearInterpolator(SF_TIMESTAMPS, SF_PAGE_HITS); *************** *** 463,483 **** trendInterpolator.setInterpolationMethod(LinearInterpolator.INTERPOLATE_REGRESSION); RrdGraphDef gDef = new RrdGraphDef(SF_TIMESTAMPS[0], SF_TIMESTAMPS[SF_TIMESTAMPS.length - 1]); ! gDef.setTitle("Trend report"); gDef.setTimeAxisLabel("month"); ! gDef.setVerticalLabel("hits"); gDef.datasource("hits", hitsInterpolator); gDef.datasource("trend", trendInterpolator); gDef.datasource("diff", "hits,trend,-"); ! gDef.datasource("absdiff", "diff,ABS"); ! gDef.area("trend", null, null); ! gDef.stack("diff", Color.YELLOW, "difference"); ! gDef.line("hits", Color.RED, "real page hits"); ! gDef.line("trend", Color.BLUE, "trend@L"); ! gDef.gprint("absdiff", "AVERAGE", "Average difference: @0@r"); gDef.setTimeAxis(TimeAxisUnit.MONTH, 1, TimeAxisUnit.MONTH, 1, "MMM", false); ! RrdGraph graph = new RrdGraph(gDef); ! String filename = Util.getJRobinDemoPath("plottable16.png"); ! graph.saveAsPNG(filename, 400, 200); ! System.out.println("Graph16 saved to " + filename); } --- 443,464 ---- trendInterpolator.setInterpolationMethod(LinearInterpolator.INTERPOLATE_REGRESSION); RrdGraphDef gDef = new RrdGraphDef(SF_TIMESTAMPS[0], SF_TIMESTAMPS[SF_TIMESTAMPS.length - 1]); ! gDef.setTitle("Trick graph"); gDef.setTimeAxisLabel("month"); ! gDef.setVerticalLabel("difference"); gDef.datasource("hits", hitsInterpolator); gDef.datasource("trend", trendInterpolator); gDef.datasource("diff", "hits,trend,-"); ! for(int i = 1; i <= STEPS; i++) { ! gDef.datasource("diff" + i, "diff," + i + ",*," + STEPS + ",/"); ! } ! for(int i = STEPS; i >= 1; i--) { ! String ds = "diff" + i; ! Color c = interpolateColor(color1, color2, i / (double) STEPS); ! String legend = (i == 1)? "dissipation": null; ! gDef.area(ds, c, legend); ! } ! gDef.setCanvasColor(color2); gDef.setTimeAxis(TimeAxisUnit.MONTH, 1, TimeAxisUnit.MONTH, 1, "MMM", false); ! createGraph(gDef); } *************** *** 489,492 **** --- 470,482 ---- } + private static int count; + + private static void createGraph(RrdGraphDef gDef) throws IOException, RrdException { + RrdGraph graph = new RrdGraph(gDef); + String filename = Util.getJRobinDemoPath("plottable" + (++count) + ".png"); + graph.saveAsPNG(filename, 400, 200); + System.out.println("Saved to: " + filename); + } + public static void main(String[] args) throws RrdException, IOException { new PlottableDemo(); |