List of usage examples for org.jfree.chart JFreeChart getLegend
public LegendTitle getLegend()
From source file:mrmc.chart.BarGraph.java
/** * Sole constructor. Creates a bar-graph style chart * //from www .j a v a 2 s . c om * @param title Title of chart * @param xaxis Label for x-axis * @param yaxis Label for y-axis * @param treeMap Mapping of x-y data */ public BarGraph(final String title, String xaxis, String yaxis, TreeMap<String, Double> treeMap) { super(title); CategoryDataset dataset = createDataset(treeMap, xaxis); JFreeChart chart = createChart(dataset, title, xaxis, yaxis); LegendTitle legend = chart.getLegend(); legend.setVisible(false); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
From source file:playground.dgrether.analysis.charts.DgMixedModeSwitcherOnlyDeltaScoreIncomeModeChoiceChart.java
public JFreeChart createChart() { XYPlot plot = new XYPlot(); ValueAxis xAxis = this.axisBuilder.createValueAxis("Income [Chf / Year]"); ValueAxis yAxis = this.axisBuilder.createValueAxis("Delta Utils [Utils]"); plot.setDomainAxis(xAxis);/*ww w .j av a 2 s. c o m*/ plot.setRangeAxis(yAxis); DgColorScheme colorScheme = new DgColorScheme(); XYItemRenderer renderer1 = new XYLineAndShapeRenderer(false, true); renderer1.setSeriesPaint(0, colorScheme.COLOR3B); renderer1.setSeriesPaint(1, colorScheme.COLOR4B); plot.setDataset(0, this.inomeModeChoiceDs); plot.setRenderer(0, renderer1); XYItemRenderer renderer2; renderer2 = new XYLineAndShapeRenderer(true, true); plot.setDataset(1, this.avgDeltaScoreIncomeDs); for (int i = 2; i <= 3; i++) { renderer2.setSeriesStroke(i - 2, new BasicStroke(2.0f)); renderer2.setSeriesOutlineStroke(i - 2, new BasicStroke(3.0f)); renderer2.setSeriesPaint(i - 2, colorScheme.getColor(i + 1, "a")); } plot.setRenderer(1, renderer2); JFreeChart chart = new JFreeChart("", plot); chart.setBackgroundPaint(ChartColor.WHITE); chart.getLegend().setItemFont(this.axisBuilder.getAxisFont()); chart.setTextAntiAlias(true); return chart; }
From source file:playground.dgrether.analysis.charts.DgMixedDeltaUtilsModeGroupChart.java
public JFreeChart createChart() { XYPlot plot = new XYPlot(); ValueAxis xAxis = this.axisBuilder.createValueAxis("% of Population Sorted by Income"); ValueAxis yAxis = this.axisBuilder.createValueAxis("Delta Utils [Utils]"); plot.setDomainAxis(xAxis);//from w ww . j a va2 s.co m plot.setRangeAxis(yAxis); //RANGE xAxis.setRange(0.0, 102.0); yAxis.setRange(-0.31, 0.61); DgColorScheme colorScheme = new DgColorScheme(); XYItemRenderer renderer1 = new XYLineAndShapeRenderer(false, true); renderer1.setSeriesPaint(0, colorScheme.COLOR1B); renderer1.setSeriesPaint(1, colorScheme.COLOR2B); renderer1.setSeriesPaint(2, colorScheme.COLOR3B); renderer1.setSeriesPaint(3, colorScheme.COLOR4B); plot.setDataset(0, this.inomeModeChoiceDs); plot.setRenderer(0, renderer1); XYItemRenderer renderer2; renderer2 = new XYLineAndShapeRenderer(true, true); plot.setDataset(1, this.avgDeltaScoreIncomeDs); for (int i = 0; i <= 3; i++) { renderer2.setSeriesStroke(i, new BasicStroke(2.0f)); renderer2.setSeriesOutlineStroke(i, new BasicStroke(3.0f)); renderer2.setSeriesPaint(i, colorScheme.getColor(i + 1, "a")); } plot.setRenderer(1, renderer2); JFreeChart chart = new JFreeChart("", plot); chart.setBackgroundPaint(ChartColor.WHITE); chart.getLegend().setItemFont(this.axisBuilder.getAxisFont()); chart.setTextAntiAlias(true); return chart; }
From source file:playground.dgrether.analysis.charts.DgAvgDeltaUtilsModeGroupChart.java
@Override public JFreeChart createChart() { XYPlot plot = new XYPlot(); ValueAxis xAxis = this.axisBuilder.createValueAxis("Income [Chf / Year]"); ValueAxis yAxis = this.axisBuilder.createValueAxis("Delta Utils [Utils]"); plot.setDomainAxis(xAxis);/*from ww w. ja v a 2s .co m*/ plot.setRangeAxis(yAxis); DgColorScheme colorScheme = new DgColorScheme(); XYItemRenderer renderer2; renderer2 = new XYLineAndShapeRenderer(true, true); plot.setDataset(0, this.dataset); for (int i = 0; i <= 3; i++) { renderer2.setSeriesStroke(i, new BasicStroke(2.0f)); renderer2.setSeriesOutlineStroke(i, new BasicStroke(3.0f)); renderer2.setSeriesPaint(i, colorScheme.getColor(i + 1, "a")); } plot.setRenderer(0, renderer2); JFreeChart chart = new JFreeChart("", plot); chart.setBackgroundPaint(ChartColor.WHITE); chart.getLegend().setItemFont(this.axisBuilder.getAxisFont()); chart.setTextAntiAlias(true); return chart; }
From source file:com.idealista.solrmeter.view.statistic.PieChartPanel.java
private Component createChartPanel() { PiePlot plot = new PiePlot(pieDataset); JFreeChart chart = new JFreeChart(I18n.get("statistic.pieChartPanel.title"), null, plot, true); chart.getLegend().setPosition(RectangleEdge.RIGHT); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setBorder(CHART_BORDER);//from w ww. ja va2s. c o m chartPanel.setMinimumDrawHeight(0); chartPanel.setMinimumDrawWidth(0); chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE); chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE); return chartPanel; }
From source file:org.jtheque.films.stats.view.impl.panels.PanelStats.java
/** * Create a panel containing a pie chart. * * @param key The i18 key of the title of the pie chart. * @param dataset The dataset used to populate the pie chart. * * @return The component containing the pie chart. *///from w w w .ja v a 2s . c om final Component createPieChartPanel(String key, PieDataset dataset) { JFreeChart pie = ChartFactory.createPieChart3D(resources.getMessage(key), dataset, true, true, true); pie.getLegend().setLegendItemGraphicLocation(RectangleAnchor.RIGHT); Managers.getManager(ILanguageManager.class).addInternationalizable(new InternationalizableChart(pie, key)); Component chartPanel = new ChartPanel(pie); chartPanel.setBackground(Color.white); return chartPanel; }
From source file:playground.dgrether.linkanalysis.DgCountPerIterationGraph.java
public JFreeChart createChart() { XYPlot plot = new XYPlot(); ValueAxis xAxis = this.axisBuilder.createValueAxis("Iteration"); xAxis.setRange(this.controllerConfig.getFirstIteration(), this.controllerConfig.getLastIteration() + 2); ValueAxis yAxis = this.axisBuilder.createValueAxis("Trips"); // yAxis.setRange(-0.05, 0.3); // xAxis.setVisible(false); // xAxis.setFixedAutoRange(1.0); plot.setDomainAxis(xAxis);/*from w ww .jav a 2 s.com*/ plot.setRangeAxis(yAxis); plot.setDataset(0, this.dataset); DgColorScheme colorScheme = new DgColorScheme(); XYItemRenderer renderer2; renderer2 = new XYLineAndShapeRenderer(true, true); for (int i = 0; i < this.dataset.getSeriesCount(); i++) { renderer2.setSeriesItemLabelsVisible(i, true); renderer2.setSeriesOutlineStroke(i, new BasicStroke(3.0f)); renderer2.setSeriesStroke(i, new BasicStroke(2.0f)); renderer2.setSeriesPaint(i, colorScheme.getColor(i + 1, "a")); } // renderer2.setSeriesItemLabelGenerator(0, this.labelGenerator); // renderer2.setSeriesStroke(1, new BasicStroke(2.0f)); // renderer2.setSeriesOutlineStroke(1, new BasicStroke(3.0f)); // renderer2.setSeriesPaint(1, colorScheme.getColor(2, "a")); plot.setRenderer(0, renderer2); JFreeChart chart = new JFreeChart("", plot); chart.setBackgroundPaint(ChartColor.WHITE); chart.getLegend().setItemFont(this.axisBuilder.getAxisFont()); chart.setTextAntiAlias(true); // chart.removeLegend(); return chart; }
From source file:org.jfree.chart.demo.ScatterPlotDemo.java
/** * A demonstration application showing a scatter plot. * //from www.jav a 2 s .co m * @param title * the frame title. */ public ScatterPlotDemo(final String title) { super(title); final XYDataset data = new SampleXYDataset2(); final JFreeChart chart = ChartFactory.createScatterPlot("Scatter Plot Demo", "X", "Y", data, PlotOrientation.VERTICAL, true, true, false); final Legend legend = chart.getLegend(); if (legend instanceof StandardLegend) { final StandardLegend sl = (StandardLegend) legend; sl.setDisplaySeriesShapes(true); } XYPlot plot = (XYPlot) chart.getPlot(); plot.setNoDataMessage("NO DATA"); final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRangeIncludesZero(false); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); chartPanel.setVerticalAxisTrace(true); chartPanel.setHorizontalAxisTrace(true); chartPanel.setVerticalZoom(true); chartPanel.setHorizontalZoom(true); setContentPane(chartPanel); }
From source file:playground.dgrether.analysis.charts.DgAvgDeltaUtilsQuantilesChart.java
public JFreeChart createChart() { XYPlot plot = new XYPlot(); ValueAxis xAxis = this.axisBuilder.createValueAxis("% of Population Sorted by Income"); xAxis.setRange(0.0, 102.0);/*from w w w . java2 s . co m*/ ValueAxis yAxis = this.axisBuilder.createValueAxis("Delta Utils [Utils]"); yAxis.setRange(-0.05, 0.3); // xAxis.setVisible(false); // xAxis.setFixedAutoRange(1.0); plot.setDomainAxis(xAxis); plot.setRangeAxis(yAxis); DgColorScheme colorScheme = new DgColorScheme(); XYItemRenderer renderer2; renderer2 = new XYLineAndShapeRenderer(true, true); renderer2.setSeriesItemLabelsVisible(0, true); // renderer2.setSeriesItemLabelGenerator(0, this.labelGenerator); plot.setDataset(0, this.dataset); renderer2.setSeriesStroke(0, new BasicStroke(2.0f)); renderer2.setSeriesOutlineStroke(0, new BasicStroke(3.0f)); renderer2.setSeriesPaint(0, colorScheme.getColor(1, "a")); plot.setRenderer(0, renderer2); JFreeChart chart = new JFreeChart("", plot); chart.setBackgroundPaint(ChartColor.WHITE); chart.getLegend().setItemFont(this.axisBuilder.getAxisFont()); chart.setTextAntiAlias(true); chart.removeLegend(); return chart; }
From source file:playground.dgrether.analysis.charts.DgModalSplitQuantilesChart.java
public JFreeChart createChart() { CategoryAxis categoryAxis = this.axisBuilder.createCategoryAxis(xLabel); categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); ValueAxis valueAxis = this.axisBuilder.createValueAxis(yLabel); valueAxis.setRange(0.0, 102.0);/*from w ww . ja va 2s.c o m*/ DgColorScheme colorScheme = new DgColorScheme(); CategoryPlot plot = new CategoryPlot(); plot.setDomainAxis(categoryAxis); plot.setRangeAxis(valueAxis); plot.setDataset(0, this.dataset); BarRenderer carRenderer = new BarRenderer(); carRenderer.setSeriesPaint(0, colorScheme.COLOR1A); carRenderer.setSeriesPaint(1, colorScheme.COLOR3A); carRenderer.setItemMargin(0.10); plot.setRenderer(0, carRenderer); JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.setBackgroundPaint(ChartColor.WHITE); chart.getLegend().setItemFont(this.axisBuilder.getAxisFont()); chart.removeLegend(); return chart; }