List of usage examples for org.jfree.chart.plot XYPlot getRenderer
public XYItemRenderer getRenderer()
From source file:edu.ucla.stat.SOCR.chart.demo.ScatterChartDemo1.java
/** * Creates a chart.//from w ww .j a v a2 s. c o m * * @param dataset the data for the chart. * * @return a chart. */ protected JFreeChart createChart(XYDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title domainLabel, // x axis label rangeLabel, // y axis label dataset, // data PlotOrientation.VERTICAL, !legendPanelOn, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setBaseLinesVisible(false); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setUpperMargin(0); rangeAxis.setLowerMargin(0); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); domainAxis.setAutoRangeIncludesZero(false); domainAxis.setUpperMargin(0); domainAxis.setLowerMargin(0); // OPTIONAL CUSTOMISATION COMPLETED. setXSummary(dataset); return chart; }
From source file:edu.ucla.stat.SOCR.chart.demo.XYAreaChartDemo2.java
/** * Creates a chart./*w ww . ja va 2s . com*/ * * @param dataset the dataset. * * @return The chart. */ protected JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createXYAreaChart(chartTitle, "Time", "Value", dataset, PlotOrientation.VERTICAL, !legendPanelOn, // legend true, // tool tips false // URLs ); XYPlot plot = chart.getXYPlot(); ValueAxis domainAxis = new DateAxis("Time"); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); plot.setDomainAxis(domainAxis); plot.setForegroundAlpha(0.5f); XYItemRenderer renderer = plot.getRenderer(); renderer.setBaseToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("#,##0.00"))); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); // setXSummary(dataset); X is time return chart; }
From source file:de.berlios.statcvs.xml.chart.AbstractTimeSeriesChart.java
/** * @param filename/*from w w w . ja v a 2 s . c om*/ * @param title */ public AbstractTimeSeriesChart(ReportSettings settings, String filename, String title, String rangeLabel) { super(settings, filename, title); tsc = new TimeSeriesCollection(); setChart(ChartFactory.createTimeSeriesChart(settings.getProjectName(), I18n.tr("Date"), rangeLabel, tsc, true, true, false)); //Paint[] colors = new Paint[1]; //colors[0] = Color.blue; //getChart().getPlot().setSeriesPaint(colors); // setup axis XYPlot plot = getChart().getXYPlot(); ValueAxis axis = plot.getDomainAxis(); axis.setVerticalTickLabels(true); plot.setRenderer(new XYStepRenderer()); // the 4th color is yellow which has almost no contrast to the white // background color, therefore we use a different color plot.getRenderer().setSeriesPaint(0, Color.red); plot.getRenderer().setSeriesPaint(1, Color.blue); plot.getRenderer().setSeriesPaint(2, Color.green); plot.getRenderer().setSeriesPaint(3, Color.magenta); plot.getRenderer().setSeriesPaint(4, Color.orange); plot.getRenderer().setSeriesPaint(5, Color.cyan); plot.getRenderer().setSeriesPaint(6, Color.pink); }
From source file:edu.psu.citeseerx.misc.charts.CiteChartBuilderJFree.java
protected JFreeChart buildChart(Document doc) throws SQLException { Long clusterid = doc.getClusterID(); if (clusterid == null) { return null; }/*from w ww . j a v a2 s .c o m*/ java.util.List<ThinDoc> citingDocs = citedao.getCitingDocuments(clusterid, 0, MAX_CITING); XYDataset dataset = collectData(citingDocs); if (dataset.getItemCount(0) <= 1) { return null; } XYBarDataset ivl_dataset = new XYBarDataset(dataset, 15.0); JFreeChart chart = ChartFactory.createXYBarChart(null, "Year", true, "Citation Count", ivl_dataset, PlotOrientation.VERTICAL, false, false, false); chart.setBackgroundPaint(Color.WHITE); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.WHITE); plot.setRangeGridlinePaint(Color.WHITE); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYItemRenderer r = plot.getRenderer(); NumberAxis axis = (NumberAxis) plot.getDomainAxis(); axis.setNumberFormatOverride(NumberFormat.getIntegerInstance()); //axis.setTickUnit(new DateTickUnit(DateTickUnit.YEAR, -1)); //axis.setDateFormatOverride(new SimpleDateFormat("yyyy")); return chart; }
From source file:GUI.PlotCreator.java
private ChartPanel createWindDirectionByTimePanel() { JFreeChart jfreechart = ChartFactory.createScatterPlot(title, "Time(Hours)", "Wind Direction", createWindDirectionByTime(), PlotOrientation.VERTICAL, true, true, false); XYPlot xyPlot = (XYPlot) jfreechart.getPlot(); xyPlot.setDomainCrosshairVisible(true); xyPlot.setRangeCrosshairVisible(true); XYItemRenderer renderer = xyPlot.getRenderer(); renderer.setSeriesPaint(0, Color.BLACK); NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis(); domain.setTickUnit(new NumberTickUnit(1.0)); domain.setVerticalTickLabels(true);/* w w w . j a va 2 s . co m*/ return new ChartPanel(jfreechart); }
From source file:GUI.PlotCreator.java
private ChartPanel createSeaCurrentSpeedByTimePanel() { JFreeChart jfreechart = ChartFactory.createScatterPlot(title, "Time(Hours)", "Sea Current Speed", createSeaCurrentSpeedDataByTime(), PlotOrientation.VERTICAL, true, true, false); XYPlot xyPlot = (XYPlot) jfreechart.getPlot(); xyPlot.setDomainCrosshairVisible(true); xyPlot.setRangeCrosshairVisible(true); XYItemRenderer renderer = xyPlot.getRenderer(); renderer.setSeriesPaint(0, Color.blue); NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis(); domain.setTickUnit(new NumberTickUnit(1.0)); domain.setVerticalTickLabels(true);//from ww w .j a v a 2 s . c o m return new ChartPanel(jfreechart); }
From source file:GUI.PlotCreator.java
private ChartPanel createWindIntensityByTimePanel() { JFreeChart jfreechart = ChartFactory.createScatterPlot(title, "Time(Hours)", "Wind Instensity", createWindIntensityByTime(), PlotOrientation.VERTICAL, true, true, false); XYPlot xyPlot = (XYPlot) jfreechart.getPlot(); xyPlot.setDomainCrosshairVisible(true); xyPlot.setRangeCrosshairVisible(true); XYItemRenderer renderer = xyPlot.getRenderer(); renderer.setSeriesPaint(0, Color.GREEN); NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis(); //domain.setRange(0,24); domain.setTickUnit(new NumberTickUnit(1.0)); domain.setVerticalTickLabels(true);/*from ww w . j av a 2 s.c om*/ return new ChartPanel(jfreechart); }
From source file:edu.ucla.stat.SOCR.chart.SuperIntervalXYChart_Time.java
protected JFreeChart createLegend(IntervalXYDataset dataset) { JFreeChart chart = ChartFactory.createXYBarChart(chartTitle, // chart title domainLabel, // domain axis label true, rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, false);/*from w w w. j a v a 2 s .c o m*/ // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); XYItemRenderer renderer = plot.getRenderer(); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); return chart; }
From source file:edu.ucla.stat.SOCR.chart.SuperIntervalXYChart.java
/** * Creates a chart.//from ww w. j a v a 2 s . c om * * @param dataset the dataset. * * @return a chart. */ protected JFreeChart createChart(IntervalXYDataset dataset) { JFreeChart chart = ChartFactory.createXYBarChart(chartTitle, domainLabel, false, rangeLabel, dataset, PlotOrientation.VERTICAL, !legendPanelOn, true, false); // then customise it a little... // chart.addSubtitle(new TextTitle("Source: http://www.amnestyusa.org/abolish/listbyyear.do")); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setRenderer(new ClusteredXYBarRenderer()); XYItemRenderer renderer = plot.getRenderer(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); return chart; }
From source file:IHM.compargraph.java
private JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createXYLineChart("", "", "", dataset); //chart.removeLegend(); XYPlot plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setSeriesShapesVisible(0, true); renderer.setSeriesShape(0, new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0)); renderer.setSeriesFillPaint(0, Color.WHITE); renderer.setUseFillPaint(true);/*from w w w . j a v a 2 s .c o m*/ NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }