Refine search
public ChartHelper generateChart() { boolean legend = false; boolean tooltips = false; boolean urls = false; JFreeChart chart = ChartFactory.createStackedBarChart(null, null, yLabel, dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); setStackedBarChartDefaults(chart, i18nBean); CategoryPlot plot = chart.getCategoryPlot(); NumberAxis axis = (NumberAxis) plot.getRangeAxis(); TickUnitSource units = NumberAxis.createIntegerTickUnits(); axis.setStandardTickUnits(units); CategoryAxis catAxis = plot.getDomainAxis(); catAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); plot.getRenderer().setSeriesOutlinePaint(1, ChartDefaults.GREEN_DIFF); plot.getRenderer().setSeriesPaint(1, ChartDefaults.GREEN_DIFF); plot.getRenderer().setSeriesOutlinePaint(0, ChartDefaults.RED_DIFF); plot.getRenderer().setSeriesPaint(0, ChartDefaults.RED_DIFF); return new ChartHelper(chart); }
CategoryPlot plot = (CategoryPlot) chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.blue); NumberAxis xAxis = new NumberAxis(); DecimalFormat format = (DecimalFormat)DecimalFormat.getNumberInstance(Locale.ENGLISH); format.applyPattern("#"); xAxis.setNumberFormatOverride(format); xAxis.setLabel("Cycles"); plot.setRangeAxis(xAxis); renderer.setBaseToolTipGenerator(new IntervalCategoryToolTipGenerator("{3} - {4}", format));
private JFreeChart createChart(final DefaultStatisticalCategoryDataset dataset) { final CategoryItemRenderer renderer = new StatisticalLineAndShapeRenderer(true, true); //CategoryItemRenderer renderer = new StatisticalBarRenderer(); for (int i = 0; i < dataset.getRowCount(); i++) { renderer.setSeriesStroke(i, new BasicStroke(5f)); } final String numberAxisLabel = _menu._time.getSelectedIndex() == 0 ? "Execution Time (s)" : "Used Memory (%)"; final CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Release"), new NumberAxis(numberAxisLabel), renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); plot.setForegroundAlpha(0.8f); return new JFreeChart((String) _menu._ontology.getSelectedItem(), plot); }
/** * Sets the renderer to use for the dataset with the specified index and, * if requested, sends a change event to all registered listeners. Note * that each dataset should have its own renderer, you should not use one * renderer for multiple datasets. * * @param index the index. * @param renderer the renderer ({@code null} permitted). * @param notify notify listeners? * * @see #getRenderer(int) */ public void setRenderer(int index, CategoryItemRenderer renderer, boolean notify) { CategoryItemRenderer existing = this.renderers.get(index); if (existing != null) { existing.removeChangeListener(this); } this.renderers.put(index, renderer); if (renderer != null) { renderer.setPlot(this); renderer.addChangeListener(this); } configureDomainAxes(); configureRangeAxes(); if (notify) { fireChangeEvent(); } }
CategoryItemRenderer renderer = plot.getRenderer(); BasicStroke stroke = new BasicStroke(Constants.LINE_THICKNESS, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); renderer.setSeriesStroke(lineNumber++, stroke); renderer.setSeriesStroke(lineNumber++, stroke); renderer.setSeriesStroke(lineNumber++, stroke); renderer.setSeriesStroke(lineNumber, stroke); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setForegroundAlpha(Constants.FOREGROUND_ALPHA); plot.setRangeGridlinesVisible(true); plot.setDomainAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(Constants.DEFAULT_MARGIN); domainAxis.setUpperMargin(Constants.DEFAULT_MARGIN); domainAxis.setCategoryMargin(Constants.DEFAULT_MARGIN);
plot.setForegroundAlpha (0.7f); plot.setAxisOffset (new RectangleInsets (5.0, 5.0, 5.0, 5.0)); plot.setBackgroundPaint (Color.lightGray); plot.setDomainGridlinesVisible (true); plot.setDomainGridlinePaint (Color.white); CategoryItemRenderer renderer = plot.getRenderer (); renderer.setSeriesPaint (0, new Color (205, 173, 0)); // gold users renderer.setSeriesPaint (1, new Color (139, 69, 19)); renderer.setSeriesPaint (2, Color.BLUE); renderer.setSeriesPaint (3, Color.GREEN); renderer.setSeriesPaint (4, Color.WHITE); CategoryAxis domainAxis = (CategoryAxis) plot.getDomainAxis (); domainAxis.setCategoryLabelPositions (CategoryLabelPositions.DOWN_45); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0);
plot.setForegroundAlpha(0.7f); plot.setBackgroundPaint(Color.WHITE); plot.setRangeGridlinePaint(Color.darkGray); domain.setCategoryLabelPositions(CategoryLabelPositions.UP_45); domain.setLowerMargin(0.0); domain.setUpperMargin(0.0); domain.setCategoryMargin(0.0); plot.setDomainAxis(domain); renderer.setSeriesPaint(i, colors[i]);
CategoryAxis domainAxis = new CategoryAxis(); domainAxis.setTickLabelsVisible(false); domainAxis.setTickMarksVisible(false); domainAxis.setAxisLineVisible(true); domainAxis.setVisible(true); Arrays.sort(sorted); for (int i = 0; i < sorted.length; i++) { renderer.setSeriesPaint(i, colours.get(sorted[i])); CategoryPlot plot = new CategoryPlot(); plot.setDataset(dataset); plot.setDomainAxis(domainAxis); plot.setDomainGridlinesVisible(false); plot.setDomainCrosshairVisible(false);
public static JFreeChart createStackedBarChart(String title, List<List<Double>> bars, List<String> zoneLabels, String xLabel, String yLabel, ColorTheme theme) { DefaultCategoryDataset ds = new DefaultCategoryDataset(); Integer barId = 0; int maxStack = 0; for (List<Double> bar : bars) { int i = 0; maxStack = Math.max(maxStack, bar.size()); for (double value : bar) { ds.addValue(value, zoneLabels.get(i), barId); i++; } barId++; } JFreeChart chart = ChartFactory.createStackedBarChart(title, xLabel, yLabel, ds, PlotOrientation.VERTICAL, true, false, false); formatColorTheme(chart, theme); formatBars(chart); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.getDomainAxis().setCategoryMargin(0); plot.getDomainAxis().setLowerMargin(0); plot.getDomainAxis().setUpperMargin(0); Color[] colors = generateJetSpectrum(maxStack); for (int i = 0; i < maxStack; i++) { plot.getRenderer().setSeriesPaint(i, colors[i]); plot.getRenderer().setSeriesOutlinePaint(i, Color.white); } return chart; }
plot.getRangeAxis().setLowerBound(d); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.blue); CategoryItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.decode("#00008B")); return chart;
private static CategoryPlot createChartFrame(CategoryDataset dataSet) { JFreeChart chart = ChartFactory.createBarChart( "Trading Volume", "Stock", "Volume, USD", dataSet, PlotOrientation.HORIZONTAL, true, true, false); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.DARK_GRAY); plot.setRangeGridlinePaint(Color.DARK_GRAY); plot.getRenderer().setSeriesPaint(0, Color.BLUE); final JFrame frame = new JFrame(); frame.setBackground(Color.WHITE); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); frame.setTitle("Hazelcast Jet Source Builder Sample"); frame.setBounds(WINDOW_X, WINDOW_Y, WINDOW_WIDTH, WINDOW_HEIGHT); frame.setLayout(new BorderLayout()); frame.add(new ChartPanel(chart)); frame.setVisible(true); return plot; } }
public static ChartHelper generateStackedBarChart(CategoryDataset dataset, String chartTitle, String yLabel, String xLabel, List domainMarkers) { boolean legend = false; boolean tooltips = false; boolean urls = false; JFreeChart chart = ChartFactory.createStackedBarChart(chartTitle, yLabel, xLabel, dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); chart.setBackgroundPaint(Color.WHITE); chart.setBorderVisible(false); CategoryPlot plot = chart.getCategoryPlot(); NumberAxis axis = (NumberAxis) plot.getRangeAxis(); TickUnitSource units = NumberAxis.createIntegerTickUnits(); axis.setStandardTickUnits(units); plot.getRenderer().setSeriesOutlinePaint(1, COLOR_YELLOW_OUTLINE); plot.getRenderer().setSeriesPaint(1, COLOR_YELLOW_PAINT); plot.getRenderer().setSeriesOutlinePaint(0, COLOR_CYAN_OUTLINE); plot.getRenderer().setSeriesPaint(0, COLOR_CYAN_PAINT); return new ChartHelper(chart); }
/** * Sets the series colors for the specified chart. * * @param chart * the chart * @param colors * the colors to set */ public void setColors(final JFreeChart chart, final Color[] colors) { CategoryPlot plot = chart.getCategoryPlot(); CategoryItemRenderer renderer = plot.getRenderer(); int series = 0; for (Color color : colors) { renderer.setSeriesPaint(series, color); series++; } }
public ChartPanel getPlotCanvas() { final JFreeChart chart = ChartFactory.createBarChart( "JBroFuzz Jaccard Index Bar Chart", // chart title "File Name", // domain axis label "Jaccard Similarity Coefficient", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips? true // URLs? ); final Plot plot = chart.getPlot(); plot.setBackgroundImage(ImageCreator.IMG_OWASP_MED.getImage()); plot.setBackgroundImageAlignment(Align.TOP_RIGHT); final CategoryItemRenderer renderer = chart.getCategoryPlot().getRenderer(); renderer .setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); return new ChartPanel(chart); }
plot.getDomainAxis().setVisible(false); plot.getRenderer().setSeriesPaint(i, color);
public void customize(JFreeChart chart, ReportParameters reportParameters) { if (chart.getPlot() instanceof CategoryPlot) { CategoryItemRenderer renderer = chart.getCategoryPlot().getRenderer(); CategoryDataset dataset = chart.getCategoryPlot().getDataset(); Set<String> legend = new LinkedHashSet<String>(); if (dataset != null) { legend.add(key); renderer.setSeriesPaint(i, seriesColorsByName.get(key)); legendItems.add(new LegendItem(item, seriesColorsByName.get(item))); chart.getCategoryPlot().setFixedLegendItems(legendItems);
CategoryAxis xAxis = (CategoryAxis) this.domainAxes.get(i); if (xAxis != null) { CategoryAxis clonedAxis = (CategoryAxis) xAxis.clone(); clone.setDomainAxis(i, clonedAxis); if (yAxis != null) { ValueAxis clonedAxis = (ValueAxis) yAxis.clone(); clone.setRangeAxis(i, clonedAxis); CategoryDataset dataset = clone.getDataset(i); if (dataset != null) { dataset.addChangeListener(clone); CategoryItemRenderer rc = (CategoryItemRenderer) pc.clone(); clone.renderers.set(i, rc); rc.setPlot(clone); rc.addChangeListener(clone);
lineChart.getTitle().setFont(new Font("Ubuntu", Font.PLAIN, 20)); lineChart.getPlot().setOutlineStroke(new BasicStroke(3)); lineChart.getCategoryPlot().getRenderer().setSeriesStroke(0, new BasicStroke(3)); lineChart.getCategoryPlot().getRenderer().setSeriesStroke(1, new BasicStroke(3));
boolean urls) { CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); DateAxis dateAxis = new DateAxis(dateAxisLabel); renderer.setBaseToolTipGenerator( new IntervalCategoryToolTipGenerator( "{3} - {4}", DateFormat.getDateInstance())); renderer.setBaseItemURLGenerator( new StandardCategoryURLGenerator()); CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, dateAxis, renderer); plot.setOrientation(PlotOrientation.HORIZONTAL); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
renderer.setPlot(this); renderer.addChangeListener(this); mapDatasetToDomainAxis(0, 0); if (domainAxis != null) { domainAxis.setPlot(this); domainAxis.addChangeListener(this); mapDatasetToRangeAxis(0, 0); if (rangeAxis != null) { rangeAxis.setPlot(this); configureDomainAxes(); configureRangeAxes();