List of usage examples for org.jfree.chart.plot XYPlot setRenderer
public void setRenderer(XYItemRenderer renderer)
From source file:SciTK.PlotXYError.java
/** More (common) initialization routines */ private void init(String x_label, String y_label, String window_title) { chart = ChartFactory.createScatterPlot("", x_label, y_label, data, PlotOrientation.VERTICAL, false, true, false);// w w w. j a v a 2s .c om XYErrorRenderer renderer = new XYErrorRenderer(); XYPlot plot = chart.getXYPlot(); // the plot itself plot.setRenderer(renderer); // for some reason default is white, change it to black: setGridlineColor(Color.BLACK); super.window_title = window_title; super.initUI(); }
From source file:edu.ucla.stat.SOCR.chart.demo.HistogramChartDemo5.java
protected JFreeChart createChart(IntervalXYDataset dataset) { domainLabel = "Row_Number"; rangeLabel = "Frequency"; JFreeChart chart = ChartFactory.createXYBarChart(chartTitle, domainLabel, false, rangeLabel, dataset, PlotOrientation.VERTICAL, false, //!legendPanelOn, true, false);//from w ww.j a va2 s . co m // 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:de.berlios.statcvs.xml.chart.AbstractTimeSeriesChart.java
/** * @param filename/* ww w . j a v a2 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:Servizi.GraficoJ.java
/** * * Metodo deputato alla creazione del grafico. * * @param dataset il dataset creato dal metodo createDataset * * @return il grafico.// ww w . ja v a 2 s . co m * */ private JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createXYLineChart("Grafico a Linea", //titolo "n individuo", //label asse delle X "Valore Funzione Fitness", //label asse dell Y dataset, // sorgente dei dati PlotOrientation.VERTICAL, //orientamento del grafico true, // mostra la legenda true, //usa i tooltip false); XYPlot plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, true); plot.setRenderer(renderer); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); NumberFormat format = NumberFormat.getNumberInstance(); format.setMaximumFractionDigits(2); XYItemLabelGenerator generator = new StandardXYItemLabelGenerator( StandardXYItemLabelGenerator.DEFAULT_ITEM_LABEL_FORMAT, format, format); renderer.setBaseItemLabelGenerator(generator); renderer.setBaseItemLabelsVisible(true); return chart; }
From source file:org.geoserver.monitor.web.ActivityChartBasePanel.java
JFreeChart createTimeSeriesChart(String title, String timeAxisLabel, String valueAxisLabel, XYDataset dataset) { ValueAxis timeAxis = new DateAxis(timeAxisLabel); timeAxis.setLowerMargin(0.02); // reduce the default margins timeAxis.setUpperMargin(0.02);/*from www . jav a 2 s. c o m*/ NumberAxis valueAxis = new NumberAxis(valueAxisLabel); valueAxis.setAutoRangeIncludesZero(false); // override default XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); plot.setRenderer(renderer); JFreeChart chart = new JFreeChart(plot); //TextTitle t = new TextTitle(title); //t.setTextAlignment(HorizontalAlignment.LEFT); //chart.setTitle(t); chart.setBackgroundPaint(Color.WHITE); chart.setAntiAlias(true); chart.clearSubtitles(); return chart; }
From source file:org.projectforge.statistics.TimesheetDisciplineChartBuilder.java
private JFreeChart create(final TimeSeries series1, final TimeSeries series2, final Shape shape, final Stroke stroke, final boolean showAxisValues, final String valueAxisUnitKey) { final TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series1);//from ww w. j ava2 s. co m dataset.addSeries(series2); final JFreeChart chart = ChartFactory.createXYLineChart(null, null, null, dataset, PlotOrientation.VERTICAL, true, true, false); final XYDifferenceRenderer renderer = new XYDifferenceRenderer(new Color(238, 176, 176), new Color(135, 206, 112), true); renderer.setSeriesPaint(0, new Color(222, 23, 33)); renderer.setSeriesPaint(1, new Color(64, 169, 59)); if (shape != null) { renderer.setSeriesShape(0, shape); renderer.setSeriesShape(1, shape); } else { final Shape none = new Rectangle(); renderer.setSeriesShape(0, none); renderer.setSeriesShape(1, none); } renderer.setSeriesStroke(0, stroke); renderer.setSeriesStroke(1, stroke); renderer.setSeriesVisibleInLegend(0, false); renderer.setSeriesVisibleInLegend(1, false); final XYPlot plot = chart.getXYPlot(); plot.setRenderer(renderer); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); final DateAxis xAxis = new DateAxis(); xAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); xAxis.setLowerMargin(0.0); xAxis.setUpperMargin(0.0); xAxis.setVisible(showAxisValues); plot.setDomainAxis(xAxis); final NumberAxis yAxis; if (showAxisValues == true) { yAxis = new NumberAxis(PFUserContext.getLocalizedString(valueAxisUnitKey)); } else { yAxis = new NumberAxis(); } yAxis.setVisible(showAxisValues); plot.setRangeAxis(yAxis); plot.setOutlineVisible(false); return chart; }
From source file:financepro.XYLineChartExample.java
License:asdf
private JPanel createChartPanel() { // creates a line chart object // returns the chart panel String chartTitle = "Various Financial Ratios"; String xAxisLabel = "Years"; String yAxisLabel = "Ratio Values"; XYDataset dataset = createDataset(); JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, xAxisLabel, yAxisLabel, dataset); XYPlot plot = chart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); plot.setRenderer(renderer); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, Color.GREEN); renderer.setSeriesPaint(2, Color.YELLOW); renderer.setSeriesPaint(3, Color.CYAN); renderer.setSeriesPaint(4, Color.BLACK); renderer.setSeriesStroke(0, new BasicStroke(4.0f)); renderer.setSeriesStroke(1, new BasicStroke(4.0f)); renderer.setSeriesStroke(2, new BasicStroke(4.0f)); renderer.setSeriesStroke(3, new BasicStroke(4.0f)); renderer.setSeriesStroke(4, new BasicStroke(4.0f)); plot.setRenderer(renderer);/*ww w .j av a 2s .co m*/ plot.setOutlinePaint(Color.BLUE); plot.setOutlineStroke(new BasicStroke(4.0f)); plot.setBackgroundPaint(Color.DARK_GRAY); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.BLACK); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.BLACK); return new ChartPanel(chart); }
From source file:no.ntnu.mmfplanner.ui.graph.NpvChart.java
/** * Updates the chart with data from the model. *//*from ww w. ja va 2 s . c o m*/ private void updateModel() { modelValid = true; XYSeriesCollection dataset = new XYSeriesCollection(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setLegendLine(new Rectangle2D.Double(0.0, 0.0, 6.0, 0.0)); renderer.setUseFillPaint(true); // the x=0 line addLineX(dataset, renderer); // rolling npv line (iterative) ProjectRoi projectRoi = ProjectRoi.getRoiTable(project, project.getInterestRate(), false); addNpvLine(projectRoi, "NPV Iterative", chartColor[0], dataset, renderer); // rolling npv line (waterfall) if (waterfall) { ProjectRoi projectRoiWaterfall = ProjectRoi.getRoiTable(project, project.getInterestRate(), true); addNpvLine(projectRoiWaterfall, "NPV Waterfall", chartColor[1], dataset, renderer); } // legend (break even and self funding) addLegendElements(dataset, renderer); XYPlot plot = ((XYPlot) getChart().getPlot()); plot.setDataset(dataset); plot.setRenderer(renderer); plot.setDomainGridlinesVisible(false); }
From source file:com.mycompany.istudy.principalservices.GraphicalView.java
/** * Overwrites the method of createXYLineChart from ChartFactory interface * and creates a XYLine Chart./*from w w w. ja v a 2s. co m*/ * @param applicationTitle * @param chartTitle * @param investedHoursPerWeek * @param hoursToBeInvested */ public GraphicalView(String applicationTitle, String chartTitle, Map<Double, Double> investedHoursPerWeek, Map<Double, Double> hoursToBeInvested) { super(applicationTitle); xylineChart = ChartFactory.createXYLineChart(chartTitle, "Calender Weeks", "Invested Study-hours", createDataset(investedHoursPerWeek, hoursToBeInvested), PlotOrientation.VERTICAL, true, true, false); ChartPanel chartPanel = new ChartPanel(xylineChart); chartPanel.setPreferredSize(new java.awt.Dimension(560, 367)); final XYPlot plot = xylineChart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesPaint(0, Color.BLUE); renderer.setSeriesPaint(1, Color.RED); renderer.setSeriesStroke(0, new BasicStroke(4.0f)); plot.setRenderer(renderer); setContentPane(chartPanel); }
From source file:cs.register.geraGrafico.java
public geraGrafico(String title, int type, List<partida> L) { super(title); JFreeChart chart = null;/* www. ja v a 2s .com*/ switch (type) { case 0: chart = ChartFactory.createXYLineChart(title, "X", "y", datakill(L), PlotOrientation.VERTICAL, true, true, false); case 1: chart = ChartFactory.createXYLineChart(title, "X", "y", datakda(L), PlotOrientation.VERTICAL, true, true, false); case 2: chart = ChartFactory.createXYLineChart(title, "X", "y", datawld(L), PlotOrientation.VERTICAL, true, true, false); case 3: chart = ChartFactory.createXYLineChart(title, "X", "y", datasocore(L), PlotOrientation.VERTICAL, true, true, false); case 4: chart = ChartFactory.createXYLineChart(title, "X", "y", datarank(L), PlotOrientation.VERTICAL, true, true, false); } graf = new ChartPanel(chart); graf.setPreferredSize(new java.awt.Dimension(560, 367)); XYPlot plot = chart.getXYPlot(); XYLineAndShapeRenderer rendrer = new XYLineAndShapeRenderer(); rendrer.setSeriesPaint(0, Color.GREEN); rendrer.setSeriesStroke(0, new BasicStroke(4.0f)); plot.setRenderer(rendrer); setContentPane(graf); }