List of usage examples for org.jfree.chart.util LogFormat LogFormat
public LogFormat(double base, String baseLabel, boolean showBase)
From source file:netplot.GenericPlotPanel.java
void genericConfig(JFreeChart chart, XYPlot plot, int plotIndex) { if (!enableLegend) { chart.removeLegend();// www.ja va 2 s. co m } XYItemRenderer xyItemRenderer = plot.getRenderer(); //May also be XYBarRenderer if (xyItemRenderer instanceof XYLineAndShapeRenderer) { XYToolTipGenerator xyToolTipGenerator = xyItemRenderer.getBaseToolTipGenerator(); //If currently an XYLineAndShapeRenderer replace it so that we inc the colour for every plotIndex XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(linesEnabled, shapesEnabled); //Ensure we don't loose the tool tips on the new renderer renderer.setBaseToolTipGenerator(xyToolTipGenerator); renderer.setBasePaint(getPlotColour(plotIndex)); renderer.setSeriesStroke(0, new BasicStroke(lineWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL), true); plot.setRenderer(plotIndex, renderer); } //If we have a new y axis then we need a new data set if (yAxisName != null && yAxisName.length() > 0) { if (logYAxis) { LogAxis yAxis = new LogAxis(yAxisName); yAxis.setAutoRange(false); yAxis.setNumberFormatOverride(new LogFormat(10, "10", true)); yAxis.setRange(minScaleValue, maxScaleValue); yAxis.setLowerBound(minScaleValue); yAxis.setUpperBound(maxScaleValue); plot.setRangeAxis(yAxisIndex, yAxis); plot.setRangeAxisLocation(yAxisIndex, AxisLocation.BOTTOM_OR_LEFT); } else { NumberAxis axis = new NumberAxis(yAxisName); axis.setAutoRangeIncludesZero(zeroOnYScale); if (autoScaleEnabled) { axis.setAutoRange(true); } else { Range range = new Range(minScaleValue, maxScaleValue); axis.setRangeWithMargins(range, true, true); } if (yAxisTickCount > 0) { NumberTickUnit tick = new NumberTickUnit(yAxisTickCount); axis.setTickUnit(tick); } plot.setRangeAxis(yAxisIndex, axis); plot.setRangeAxisLocation(yAxisIndex, AxisLocation.BOTTOM_OR_LEFT); } yAxisIndex++; } plot.mapDatasetToRangeAxis(plotIndex, yAxisIndex - 1); ValueAxis a = plot.getDomainAxis(); if (xAxisName.length() > 0) { a.setLabel(xAxisName); } //We can enable/disable zero on the axis if we have a NumberAxis if (a instanceof NumberAxis) { ((NumberAxis) a).setAutoRangeIncludesZero(zeroOnXScale); } }
From source file:eu.planets_project.tb.impl.chart.ExperimentChartServlet.java
public JFreeChart createXYChart(String expId) { ExperimentPersistencyRemote edao = ExperimentPersistencyImpl.getInstance(); long eid = Long.parseLong(expId); log.info("Building experiment chart for eid = " + eid); Experiment exp = edao.findExperiment(eid); final String expName = exp.getExperimentSetup().getBasicProperties().getExperimentName(); final XYSeries series = new XYSeries(expName); for (BatchExecutionRecordImpl batch : exp.getExperimentExecutable().getBatchExecutionRecords()) { int i = 1; for (ExecutionRecordImpl exr : batch.getRuns()) { //log.info("Found Record... "+exr+" stages: "+exr.getStages()); if (exr != null && exr.getStages() != null) { // Look up the object, so we can get the name. DigitalObjectRefBean dh = new DataHandlerImpl().get(exr.getDigitalObjectReferenceCopy()); String dobName = "Object " + i; if (dh != null) dobName = dh.getName(); for (ExecutionStageRecordImpl exsr : exr.getStages()) { Double time = exsr.getDoubleMeasurement(TecRegMockup.PROP_SERVICE_TIME); Double size = exsr.getDoubleMeasurement(TecRegMockup.PROP_DO_SIZE); // Look for timing: if (time != null && size != null && size.doubleValue() > 0.0 && time.doubleValue() > 0.0) { series.add(size, time); /* if( exsr.isMarkedAsSuccessful() ) { dataset.addValue( time, "Succeded", dobName); } else {/*from www. j av a2s .co m*/ dataset.addValue( time, "Failed", dobName); } */ } } } // Increment, for the next run. i++; } } // Create the chart. JFreeChart chart = ChartFactory.createScatterPlot(null, "Size [bytes]", "Time [s]", new XYSeriesCollection(series), PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); LogAxis xAxis = new LogAxis("Size [bytes]"); // Set the base appropriately: xAxis.setBase(1024.0); // xAxis.setTickUnit( new NumberTickUnit(128.0) ); // xAxis.getTickUnit().getMinorTickCount(); // FIXME This should really be a KB/MB/etc number formatter... xAxis.setNumberFormatOverride(new LogFormat(1024.0, "1024", true)); // LogAxis yAxis = new LogAxis("Y"); // yAxis.setNumberFormatOverride(new LogFormat(10.0, "10", true)); plot.setDomainAxis(xAxis); // plot.setRangeAxis(yAxis); // Add some tool-tips plot.getRenderer().setBaseToolTipGenerator(new StandardXYToolTipGenerator()); return chart; }