private CategoryPlot createBarChartPlot(DefaultCategoryDataset dataset, String yAxisLabel, NumberFormat yAxisNumberFormat) { CategoryAxis xAxis = new CategoryAxis("Data"); xAxis.setCategoryMargin(0.40); NumberAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setNumberFormatOverride(yAxisNumberFormat); BarRenderer renderer = createBarChartRenderer(yAxisNumberFormat); CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); return plot; }
private CategoryPlot createBoxAndWhiskerChartPlot(DefaultBoxAndWhiskerCategoryDataset dataset, String yAxisLabel, NumberFormat yAxisNumberFormat) { CategoryAxis xAxis = new CategoryAxis("Data"); NumberAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setNumberFormatOverride(yAxisNumberFormat); BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setItemMargin(0.10); renderer.setMeanVisible(false); // Improve readability by avoiding low contrast with light colors renderer.setUseOutlinePaintForWhiskers(true); CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); return plot; }
dataset.addValue(i, "Time", "Hours" + String.valueOf(i + 1)); CategoryPlot plot = new CategoryPlot(); CategoryItemRenderer renderer = new BarRenderer(); plot.setDataset(0, dataset);
protected CategoryPlot drawChart4FOI(String featureID, String timeString, ObservedValueTuple tuple) { BarRenderer3D barRenderer = new BarRenderer3D(); CategoryPlot plot = new CategoryPlot(); plot.setDomainAxis(new CategoryAxis(featureID)); for (int i = 0; i < observedProperties.length; i++) { plot.setDataset(i, createDataset(i, timeString, tuple)); plot.setRangeAxis(i, new NumberAxis(tuple.getPhenomenonNames()[i].split(":")[tuple.getPhenomenonNames()[i].split(":").length - 1])); plot.setRenderer(i, barRenderer); plot.mapDatasetToRangeAxis(i, i); } return plot; }
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); }
/** * Returns a CategoryPlot. */ private CategoryPlot getCategoryPlot( CategoryDataset dataSet, CategoryItemRenderer renderer, PlotOrientation orientation, CategoryLabelPositions labelPositions ) { CategoryPlot plot = new CategoryPlot( dataSet, new CategoryAxis(), new NumberAxis(), renderer ); plot.setDatasetRenderingOrder( DatasetRenderingOrder.FORWARD ); plot.setOrientation( orientation ); CategoryAxis xAxis = plot.getDomainAxis(); xAxis.setCategoryLabelPositions( labelPositions ); return plot; }
public static JFreeChart createStatisticalBarChart(CategoryDataset dataset) { final CategoryAxis xAxis = new CategoryAxis("Type"); xAxis.setLowerMargin(0.01d); // percentage of space before first bar xAxis.setUpperMargin(0.01d); // percentage of space after last bar xAxis.setCategoryMargin(0.3d); // percentage of space between // categories xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); final LogarithmicAxis yAxis = new LogarithmicAxis("Time (s)");//new NumberAxis("Value"); yAxis.setAutoRange(true); //yAxis.setAutoRangeMinimumSize(/size); yAxis.setLowerBound(0.0001); yAxis.setMinorTickMarksVisible(true); yAxis.setAutoRangeIncludesZero(false); yAxis.setStrictValuesFlag(false); // define the plot final CategoryItemRenderer renderer = new StatisticalBarRenderer(); final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); final JFreeChart chart = new JFreeChart("Performance Comparison", new Font("Helvetica", Font.BOLD, 14), plot, true); return chart; }
//Mock data DefaultCategoryDataset dataset = new DefaultCategoryDataset(); int[] times = new int[]{1,2,3,4,5,6,7,8,9}; for ( int i = 0; i < times.length; i++ ){ dataset.addValue(times[i], "Time", "Hour" + String.valueOf(i+1)); } //create the plot CategoryPlot plot = new CategoryPlot(); //add the first dataset, and render as bar values CategoryItemRenderer renderer = new BarRenderer(); plot.setDataset(0,dataset); plot.setRenderer(0,renderer); //add the second dataset, render as lines CategoryItemRenderer renderer2 = new LineAndShapeRenderer(); plot.setDataset(1, dataset); plot.setRenderer(1, renderer2); //set axis plot.setDomainAxis(new CategoryAxis("Time")); plot.setRangeAxis(new NumberAxis("Value"));
renderer.setDefaultToolTipGenerator(new BoxAndWhiskerToolTipGenerator()); CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
@Override protected Plot getPlot(ChartParameters params) { DefaultCategoryDataset dataset = createDataset(params); CategoryAxis domainAxis = new CategoryAxis(); domainAxis.setCategoryMargin(0.0); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setNumberFormatOverride(NumberFormat.getIntegerInstance(params.getLocale())); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); AreaRenderer renderer = new AreaRenderer(); CategoryPlot plot = new CategoryPlot(dataset, domainAxis, rangeAxis, renderer); plot.setForegroundAlpha(0.5f); plot.setDomainGridlinesVisible(true); configureColors(dataset, plot, params.getValues(PARAM_COLORS, ",")); return plot; }
renderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator()); CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
private CategoryPlot generateJFreeChart(ChartParameters params) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); CategoryPlot plot = new CategoryPlot(); Font font = getFont(params.getValue(PARAM_FONT_SIZE)); configureDomainAxis(plot, font); configureRangeAxis(plot, params.getValue(PARAM_Y_SUFFIX, "", true), font); configureRenderer(plot); configureValues(dataset, params.getValues(PARAM_VALUES, "|", true), params.getValue(PARAM_X_SUFFIX, "", true)); configureColors(dataset, plot, params.getValues(PARAM_COLORS, ",")); plot.setDataset(dataset); return plot; }
private CategoryPlot generateJFreeChart(ChartParameters params) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); CategoryPlot plot = new CategoryPlot(); Font font = getFont(params.getValue(PARAM_FONT_SIZE)); configureDomainAxis(plot, font); configureRangeAxis(plot, params.getValue(PARAM_Y_SUFFIX, "", true), font); configureRenderer(plot); configureValues(dataset, params.getValues(PARAM_VALUES, "|", true), params.getValue(PARAM_X_SUFFIX, "", true)); configureColors(dataset, plot, params.getValues(PARAM_COLORS, ",")); plot.setDataset(dataset); return plot; }
private static JFreeChart createAreaChart( final CategoryDatasetChartDefinition chartDefinition ) { // TODO Make the following accessible from the chartDefinition String categoryAxisLabel = null; String valueAxisLabel = null; boolean tooltips = true; boolean urls = true; // ----------------------------------------------------------- String title = chartDefinition.getTitle(); boolean legend = chartDefinition.isLegendIncluded(); CategoryAxis categoryAxis = new CategoryAxis( categoryAxisLabel ); ValueAxis valueAxis = new NumberAxis( valueAxisLabel ); AreaRenderer renderer = chartDefinition.isStacked() ? new StackedAreaRenderer() : new AreaRenderer(); if ( tooltips ) { renderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator() ); } if ( urls ) { renderer.setBaseItemURLGenerator( new StandardCategoryURLGenerator() ); } CategoryPlot plot = new CategoryPlot( chartDefinition, categoryAxis, valueAxis, renderer ); JFreeChartEngine.updatePlot( plot, chartDefinition ); JFreeChart chart = new JFreeChart( title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend ); return chart; }
new StandardCategoryURLGenerator()); CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer); plot.setOrientation(orientation);
domainAxis.setCategoryMargin(0.0); CategoryPlot plot = new CategoryPlot(dataSet, domainAxis, numberAxis, new LineAndShapeRenderer(true, false)); plot.setOrientation(PlotOrientation.VERTICAL);
throw new GenerateException("Invalid series parameter: " + dataSeries); return new CategoryPlot(dataset, domainAxis, rangeAxis, renderer);
domainAxis.setCategoryMargin(0.0); CategoryPlot plot = new CategoryPlot(dataSet, domainAxis, numberAxis, new LineAndShapeRenderer(true, false)); plot.setOrientation(PlotOrientation.VERTICAL);
CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer); plot.setOrientation(orientation);
private static JFreeChart createLineChart( final CategoryDatasetChartDefinition chartDefinition ) { // TODO Make the following accessible from the chartDefinition String categoryAxisLabel = null; String valueAxisLabel = null; boolean tooltips = true; boolean urls = true; // ----------------------------------------------------------- String title = chartDefinition.getTitle(); boolean legend = chartDefinition.isLegendIncluded(); CategoryAxis categoryAxis = new CategoryAxis( categoryAxisLabel ); ValueAxis valueAxis = new NumberAxis( valueAxisLabel ); LineAndShapeRenderer renderer = chartDefinition.isThreeD() ? new LineRenderer3D() : new LineAndShapeRenderer( true, false ); if ( tooltips ) { renderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator() ); } if ( urls ) { renderer.setBaseItemURLGenerator( new StandardCategoryURLGenerator() ); } renderer.setStroke( JFreeChartEngine.getLineStyleStroke( chartDefinition.getLineStyle(), chartDefinition .getLineWidth() ) ); renderer.setShapesVisible( chartDefinition.isMarkersVisible() ); renderer.setBaseShapesFilled( chartDefinition.isMarkersVisible() ); CategoryPlot plot = new CategoryPlot( chartDefinition, categoryAxis, valueAxis, renderer ); JFreeChartEngine.updatePlot( plot, chartDefinition ); JFreeChart chart = new JFreeChart( title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend ); return chart; }