List of usage examples for org.jfree.chart.plot XYPlot setRangeAxis
public void setRangeAxis(int index, ValueAxis axis)
From source file:no.met.jtimeseries.netcdf.plot.SimplePlotProvider.java
/** * Create range axes for all values to be used. * /*from ww w. j a v a2s . c om*/ * @param dataList List to create axes from * @param plot The plot render data on * * @return A map pointing from unit name to axis index */ private Map<String, Integer> createRangeAxes(List<NumberPhenomenon> dataList, XYPlot plot) { HashMap<String, Integer> ret = new HashMap<String, Integer>(); int i = 0; for (ValueAxis va : getRangeAxis(dataList)) { String unit = va.getLabel(); plot.setRangeAxis(i, va); ret.put(unit, i++); } return ret; }
From source file:com.trivadis.loganalysis.ui.ChartPanel.java
private void add(final Serie serie) { if (!isDisposed()) { serie.setIndex(seriesSequence.get()); final XYSeriesCollection dataset = new XYSeriesCollection(datasetProvider.getDataset(jvm, serie)); final int index = serie.getIndex(); final XYPlot plot = (XYPlot) jfreeChart.getPlot(); final Color color = getColor(index); removeDataset(index, plot);/* w ww . ja v a 2s . c o m*/ plot.setDataset(index, dataset); plot.setRangeAxis(index, axis(color, serie.getYaxis().getValueProvider().getUnit())); plot.setDomainAxis(index, axis(color, serie.getXaxis().getValueProvider().getUnit())); plot.mapDatasetToDomainAxis(index, index); plot.mapDatasetToRangeAxis(index, index); plot.setRenderer(index, getRenderer(color, serie.isDotted())); seriesSequence.incrementAndGet(); } }
From source file:org.signserver.client.cli.performance.PerformanceTestPDFServlet.java
License:asdf
/** * Create and write diagrams to disk.//from w w w . j av a 2 s . c o m */ private void createDiagram(String statisticsDirectory, ArrayList<String> explanationRow, ArrayList<ArrayList<Double>> processedData, int xRow, int y1Row, int y2Row) { final XYSeries s1 = new XYSeries(explanationRow.get(y1Row)); final XYSeries s2 = new XYSeries(explanationRow.get(y2Row)); for (ArrayList<Double> currentRow : processedData) { s1.add(currentRow.get(xRow), currentRow.get(y1Row)); s2.add(currentRow.get(xRow), currentRow.get(y2Row)); } final XYSeriesCollection dataset1 = new XYSeriesCollection(); dataset1.addSeries(s1); final XYSeriesCollection dataset2 = new XYSeriesCollection(); dataset2.addSeries(s2); final JFreeChart chart = ChartFactory.createXYLineChart("Test result " + xRow + "" + y1Row + "" + y2Row, explanationRow.get(xRow), explanationRow.get(y1Row), dataset1, PlotOrientation.VERTICAL, true, true, false); final XYPlot plot = chart.getXYPlot(); if (y1Row == COLUMN_INVOCATIONS_PER_SECOND) { final NumberAxis axis1 = new LogarithmicAxis(explanationRow.get(y1Row)); plot.setRangeAxis(0, axis1); } final NumberAxis axis2 = new NumberAxis(explanationRow.get(y2Row)); axis2.setAutoRangeIncludesZero(false); plot.setRangeAxis(1, axis2); plot.setDataset(1, dataset2); plot.mapDatasetToRangeAxis(1, 1); final StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.BLUE); plot.setRenderer(1, renderer2); final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); final File file = new File( statisticsDirectory + "PDF Signatures" + "-" + xRow + "" + y1Row + "" + y2Row + ".png"); int imageWidth = 800; int imageHeight = 600; try { System.out.println("Writing diagram to " + file.getName()); System.out.flush(); ChartUtilities.saveChartAsPNG(file, chart, imageWidth, imageHeight, info); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.ivli.roim.controls.VOILUTPanel.java
public VOILUTPanel(LUTControl aP) { iCurveName = java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle").getString("VOILUTPANEL.VOI_LUT"); iLUT = LUTControl.create(aP);//ww w .ja va2s .c o m aP.addWindowChangeListener(this); initComponents(); XYPlot plot = new XYPlot(); plot.setDataset(0, makeLUTCurve()); plot.setRenderer(0, new XYSplineRenderer()); ((XYSplineRenderer) plot.getRenderer()).setShapesVisible(false); plot.setRangeAxis(0, new NumberAxis(java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle") .getString("VOILUTPANEL.AXIS_LABEL_VOI_CURVE"))); XYSeriesCollection col2 = new XYSeriesCollection(); col2.addSeries(makeHistogram()); plot.setDataset(1, col2); plot.setRenderer(1, new XYBarRenderer()); plot.setRangeAxis(1, new NumberAxis(java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle") .getString("VOILUTPANEL.AXIS_LABEL_IMAGE_SPACE"))); plot.mapDatasetToRangeAxis(1, 1); plot.setDomainAxis(new NumberAxis(java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle") .getString("VOILUTPANEL.AXIS_LABEL_IMAGE_HISTOGRAM"))); plot.setRangeGridlinesVisible(true); plot.setDomainGridlinesVisible(true); // change the rendering order so the primary dataset appears "behind" the // other datasets... plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE); JFreeChart jfc = new JFreeChart(plot); jfc.setBorderVisible(true); jfc.removeLegend(); iPanel = new ChartPanel(jfc); iPanel.setSize(jPanel1.getPreferredSize()); jPanel1.add(iPanel);//, java.awt.BorderLayout.CENTER); iLUT.setSize(jPanel2.getPreferredSize()); jPanel2.add(iLUT); iLabelMin.setText(String.format("%.0f", iLUT.getView().getMin())); iLabelMax.setText(String.format("%.0f", iLUT.getView().getMax())); validate(); }
From source file:com.bt.aloha.sipstone.GenGraph.java
private JFreeChart createCombinedChart() { XYDataset xydatasetArray[] = createDataset_TotalCallCreated_CallsPerSecond(); XYDataset xydataset = xydatasetArray[0]; final XYDataset percXydataset = xydatasetArray[1]; JFreeChart jfreechart = ChartFactory.createXYLineChart("SIPStone graph", "Calls", "Call rate", xydataset, PlotOrientation.VERTICAL, false, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); NumberAxis numberaxis = new NumberAxis("Avg. Response Time"); numberaxis.setAutoRangeIncludesZero(false); xyplot.setRangeAxis(1, numberaxis); xyplot.setDataset(1, createDataset_TotalCallCreated_AvgResponseTime()); xyplot.mapDatasetToRangeAxis(1, 1);// w w w . j a v a2 s .c o m XYItemRenderer xyitemrenderer = xyplot.getRenderer(); xyitemrenderer.setBaseToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance()); if (xyitemrenderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setShapesFilled(true); } XYLineAndShapeRenderer xylineandshaperenderer1 = new XYLineAndShapeRenderer(); xylineandshaperenderer1.setSeriesPaint(0, Color.black); xylineandshaperenderer1.setBaseShapesVisible(true); xylineandshaperenderer1.setBaseToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance()); xyplot.setRenderer(1, xylineandshaperenderer1); NumberAxis timeaxis = (NumberAxis) xyplot.getDomainAxis(); timeaxis.setAutoRange(true); timeaxis.setAxisLineVisible(true); LegendTitle legendtitle = new LegendTitle(xyitemrenderer); LegendTitle legendtitle1 = new LegendTitle(xylineandshaperenderer1); BlockContainer blockcontainer = new BlockContainer(new BorderArrangement()); blockcontainer.add(legendtitle, RectangleEdge.LEFT); blockcontainer.add(legendtitle1, RectangleEdge.RIGHT); blockcontainer.add(new EmptyBlock(2000D, 0.0D)); XYItemRenderer xyrenderer = (XYItemRenderer) xyplot.getRenderer(); xyrenderer.setBaseItemLabelGenerator(new MyXYItemLabelGenerator(percXydataset)); xyrenderer.setBaseItemLabelsVisible(true); CompositeTitle compositetitle = new CompositeTitle(blockcontainer); compositetitle.setPosition(RectangleEdge.BOTTOM); jfreechart.addSubtitle(compositetitle); return jfreechart; }
From source file:net.sf.clichart.chart.AbstractChartBuilder.java
/** * Add the data set as the second axis to this chart *//* w w w . ja va2 s .co m*/ public void addSecondAxis(JFreeChart chart, Options options) { XYPlot plot = chart.getXYPlot(); plot.setDataset(1, getDataset()); plot.mapDatasetToRangeAxis(1, 1); NumberAxis rangeAxis2 = new NumberAxis(options.getSecondAxisChartYAxisTitle()); plot.setRangeAxis(1, rangeAxis2); // need a separate renderer for the axis, otherwise the same colours are used as for the first axis series setAxisRenderer(chart.getXYPlot(), 1, options.isSecondAxisBarChart(), options.hasSecondAxisDataPoints(), options.getSecondAxisLineWeight()); setAxisLimits(rangeAxis2, options.getSecondAxisMinYValue(), options.getSecondAxisMaxYValue(), options.forceSecondAxisYRange()); rangeAxis2.setAutoRangeIncludesZero(false); }
From source file:graph.MySensorPanel.java
/** * Creates a new self-contained demo panel. */// w w w . j ava 2 s . c o m public MySensorPanel(String header_str) { //super(new BorderLayout()); this.series1 = new TimeSeries("Temperature"); this.series2 = new TimeSeries("Humidity"); TimeSeriesCollection dataset1 = new TimeSeriesCollection(this.series1); TimeSeriesCollection dataset2 = new TimeSeriesCollection(this.series2); JFreeChart chart = ChartFactory.createTimeSeriesChart(header_str, "Time", "C", dataset1, true, true, false); /*this.addChart(chart);*/ XYPlot plot = (XYPlot) chart.getPlot(); ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); axis.setFixedAutoRange(1000.0 * 60 * 60 /* 24*/); // 24 hrs plot.setDataset(1, dataset2); NumberAxis rangeAxis2 = new NumberAxis("%"); rangeAxis2.setAutoRangeIncludesZero(false); plot.setRenderer(1, new DefaultXYItemRenderer()); plot.setRangeAxis(1, rangeAxis2); plot.mapDatasetToRangeAxis(1, 1); ChartUtilities.applyCurrentTheme(chart); plot.setBackgroundPaint(Color.DARK_GRAY); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); chartPanel = new ChartPanel(chart); }
From source file:org.jfree.chart.demo.CombinedXYPlotDemo4.java
/** * Creates a combined chart./*from w w w . j a v a2 s. c om*/ * * @return The combined chart. */ private JFreeChart createCombinedChart() { // create subplot 1... final XYDataset data1 = createDataset1(); final XYItemRenderer renderer1 = new StandardXYItemRenderer(); final NumberAxis rangeAxis1 = new NumberAxis("Range 1"); final XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); // add secondary axis subplot1.setDataset(1, createDataset2()); final NumberAxis axis2 = new NumberAxis("Range Axis 2"); axis2.setAutoRangeIncludesZero(false); subplot1.setRangeAxis(1, axis2); subplot1.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); subplot1.setRenderer(1, new StandardXYItemRenderer()); subplot1.mapDatasetToRangeAxis(1, 1); final XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0, 10000.0); annotation.setFont(new Font("SansSerif", Font.PLAIN, 9)); annotation.setRotationAngle(Math.PI / 4.0); subplot1.addAnnotation(annotation); // create subplot 2... final XYDataset data2 = createDataset2(); final XYItemRenderer renderer2 = new StandardXYItemRenderer(); final NumberAxis rangeAxis2 = new NumberAxis("Range 2"); rangeAxis2.setAutoRangeIncludesZero(false); final XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2); subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); // parent plot... final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Domain")); plot.setGap(10.0); // add the subplots... plot.add(subplot1, 1); plot.add(subplot2, 1); plot.setOrientation(PlotOrientation.VERTICAL); // return a new chart containing the overlaid plot... return new JFreeChart("CombinedDomainXYPlot Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:org.encog.workbench.dialogs.training.ChartPane.java
/** * Create the initial chart.//from w w w .j a v a 2s .c om * @return The chart. */ private JFreeChart createChart() { this.chart = ChartFactory.createXYLineChart(null, "Iteration", "Current Error", this.dataset1, PlotOrientation.VERTICAL, true, true, false); final XYPlot plot = (XYPlot) this.chart.getPlot(); plot.setOrientation(PlotOrientation.VERTICAL); plot.getRangeAxis().setFixedDimension(15.0); // AXIS 2 final NumberAxis axis2 = new NumberAxis("Error Improvement"); axis2.setFixedDimension(10.0); axis2.setAutoRangeIncludesZero(false); axis2.setLabelPaint(Color.red); axis2.setTickLabelPaint(Color.red); plot.setRangeAxis(1, axis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); plot.setDataset(1, this.dataset2); plot.mapDatasetToRangeAxis(1, 1); final XYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.red); plot.setRenderer(1, renderer2); ChartUtilities.applyCurrentTheme(this.chart); return this.chart; }
From source file:uk.co.moonsit.sockets.GraphClient.java
private void setAxes(XYPlot plot, int[] axesIndex) { for (int i = 0; i < datasets.length; i++) { plot.setRangeAxis(axesIndex[i] - 1, getTheRangeAxis(axesIndex[i] - 1)); AxisLocation axloc;/*from w ww. ja v a 2s . c o m*/ if (i % 2 == 0) { axloc = AxisLocation.BOTTOM_OR_LEFT; //System.out.print("L "); } else { axloc = AxisLocation.BOTTOM_OR_RIGHT; //System.out.print("R "); } plot.setRangeAxisLocation(i, axloc); plot.setDataset(i, datasets[i]); //System.out.println(i + " " + (axesIndex[i] - 1)); plot.mapDatasetToRangeAxis(i, axesIndex[i] - 1); final StandardXYItemRenderer renderer = new StandardXYItemRenderer(); //renderer2.setSeriesPaint(0, Color.black); plot.setRenderer(i, renderer); } }