List of usage examples for org.jfree.chart.plot XYPlot getRenderer
public XYItemRenderer getRenderer()
From source file:edu.ucla.stat.SOCR.chart.demo.HistogramChartDemo6.java
protected JFreeChart createChart(IntervalXYDataset dataset) { JFreeChart chart = ChartFactory.createXYBarChart(chartTitle, domainLabel, false, rangeLabel, dataset, PlotOrientation.VERTICAL, false, //!legendPanelOn, true, false);/*from w w w . j av a 2 s . com*/ // 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:mrmc.chart.StudyDesignPlot.java
/** * Constructs the chart//from ww w. ja v a2 s . c o m * * @param dataset Representation of x-y data * @param title Title of chart * @param xaxis Label for x-axis * @param yaxis Label for y-axis * @return The chart */ private JFreeChart createChart(final DefaultXYDataset dataset, String title, String xaxis, String yaxis) { final JFreeChart chart = ChartFactory.createScatterPlot(title, xaxis, yaxis, dataset, PlotOrientation.VERTICAL, true, true, false); XYPlot xyplot = (XYPlot) chart.getPlot(); NumberAxis rangeAxis = (NumberAxis) xyplot.getRangeAxis(); ; rangeAxis.setLowerBound(-.5); rangeAxis.setTickUnit(new NumberTickUnit(1)); XYItemRenderer renderer = xyplot.getRenderer(); Rectangle square = new Rectangle(5, 5); renderer.setSeriesShape(0, square); renderer.setSeriesShape(1, square); renderer.setSeriesPaint(0, Color.white); renderer.setSeriesPaint(1, Color.black); return chart; }
From source file:edu.ucla.stat.SOCR.chart.demo.XYBarChartDemo2.java
/** * Creates a chart.//from ww w . j av a 2 s .c o m * * @param dataset the dataset. * * @return The chart. */ protected JFreeChart createChart(IntervalXYDataset dataset) { JFreeChart chart = ChartFactory.createXYBarChart(chartTitle, // chart title domainLabel, // domain axis label true, rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, !legendPanelOn, // include legend //false, // when choose no legend, the color order used in chart is different true, false); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... XYPlot plot = chart.getXYPlot(); plot.setRenderer(new ClusteredXYBarRenderer()); XYItemRenderer renderer = plot.getRenderer(); renderer.setBaseToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yy"), new DecimalFormat("#,##0.00"))); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); // OPTIONAL CUSTOMISATION COMPLETED. //setXSummary(dataset); X is time return chart; }
From source file:edu.ucla.stat.SOCR.chart.demo.XYBarChartDemo2.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);/*www.j av a 2s . c o m*/ // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... XYPlot plot = chart.getXYPlot(); plot.setRenderer(new ClusteredXYBarRenderer()); XYItemRenderer renderer = plot.getRenderer(); renderer.setBaseToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yy"), new DecimalFormat("#,##0.00"))); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); // OPTIONAL CUSTOMISATION COMPLETED. //setXSummary(dataset); X is time return chart; }
From source file:beadAnalyzer.DrawPoints.java
protected JFreeChart createChart(final IntervalXYDataset dataset, final String title, final String units) { final JFreeChart chart = ChartFactory.createXYBarChart(title, "Pixel [" + units + "]", false, "Count", dataset, PlotOrientation.VERTICAL, false, // legend false, false);//from w w w. j a v a 2 s . c o m NumberAxis range = (NumberAxis) chart.getXYPlot().getDomainAxis(); range.setRange(getMin(), getMax()); XYPlot plot = chart.getXYPlot(); XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); renderer.setSeriesPaint(0, Color.red); renderer.setDrawBarOutline(true); renderer.setSeriesOutlinePaint(0, Color.black); renderer.setBarPainter(new StandardXYBarPainter()); return chart; }
From source file:ws.moor.bt.grapher.ChartBuilder.java
public JFreeChart getChart() { JFreeChart chart = ChartFactory.createTimeSeriesChart(chartName, timeAxisLabel, valueAxisLabel, timeSeries, showLegend && (timeSeries.getSeriesCount() > 1), false, false); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.getRenderer().setSeriesPaint(0, Color.black); plot.getRenderer().setSeriesStroke(0, new BasicStroke(1.0f)); plot.getRenderer().setSeriesPaint(1, Color.black); plot.getRenderer().setSeriesStroke(1, new BasicStroke(2.0f)); plot.getRenderer().setSeriesPaint(2, Color.black); plot.getRenderer().setSeriesStroke(2, new BasicStroke(0.1f)); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); return chart; }
From source file:br.unicamp.cst.behavior.bn.support.Grafico.java
public Grafico(String frametitle, String charttitle, String xlabel, String ylabel, XYSeriesCollection dataset) { JFreeChart chart = ChartFactory.createXYLineChart(charttitle, xlabel, ylabel, dataset, PlotOrientation.VERTICAL, true, true, false); 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.setShapesVisible(true);/*from ww w. jav a 2s. c om*/ renderer.setShapesFilled(true); setXyplot(plot); setChart(chart); ChartFrame frame = new ChartFrame(frametitle, chart); frame.pack(); frame.setVisible(true); }
From source file:sim.app.sugarscape.Charts.java
JFreeChart createAgeHistoChart() { JFreeChart chart = ChartFactory.createHistogram("Age Distribution", "Age", "Count", model.age_hist_dataset, PlotOrientation.VERTICAL, true, true, false); model.age_histo_chart = chart;/*ww w .j a va 2 s.co m*/ //CategoryDataset dataset1 = createDataset1(); NumberAxis rangeAxis1 = new NumberAxis("Age"); rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); org.jfree.chart.axis.NumberAxis domainAxis = new NumberAxis("Bins"); XYPlot plot = chart.getXYPlot(); ValueAxis xAxis = plot.getDomainAxis(); xAxis.setRange(0, 100); XYItemRenderer renderer1 = plot.getRenderer(); renderer1.setSeriesPaint(0, Color.MAGENTA); return chart; }
From source file:org.jfree.chart.demo.XYAreaChartDemo2.java
/** * Creates a chart./* w w w . j a v a2 s . c o m*/ * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createXYAreaChart("XY Area Chart Demo 2", "Time", "Value", dataset, PlotOrientation.VERTICAL, true, // legend true, // tool tips false // URLs ); final XYPlot plot = chart.getXYPlot(); final ValueAxis domainAxis = new DateAxis("Time"); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); plot.setDomainAxis(domainAxis); plot.setForegroundAlpha(0.5f); final XYItemRenderer renderer = plot.getRenderer(); renderer.setToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("#,##0.00"))); return chart; }
From source file:org.yccheok.jstock.gui.charting.DynamicChart.java
public void showNewJDialog(java.awt.Frame parent, String title) { TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(this.price); JFreeChart freeChart = ChartFactory.createTimeSeriesChart(title, GUIBundle.getString("DynamicChart_Date"), GUIBundle.getString("DynamicChart_Price"), dataset, true, true, false); freeChart.setAntiAlias(true);//from w w w .j a va 2 s .co m XYPlot plot = freeChart.getXYPlot(); NumberAxis rangeAxis1 = (NumberAxis) plot.getRangeAxis(); DecimalFormat format = new DecimalFormat("00.00"); rangeAxis1.setNumberFormatOverride(format); XYItemRenderer renderer1 = plot.getRenderer(); renderer1.setBaseToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("h:mm:ss a"), new DecimalFormat("0.00#"))); org.yccheok.jstock.charting.Utils.applyChartTheme(freeChart); ChartPanel _chartPanel = new ChartPanel(freeChart, true, true, true, true, true); JDialog dialog = new JDialog(parent, title, false); dialog.getContentPane().add(_chartPanel, java.awt.BorderLayout.CENTER); dialog.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); final java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); dialog.setBounds((screenSize.width - 750) >> 1, (screenSize.height - 600) >> 1, 750, 600); dialog.setVisible(true); }