static private void configureLineChart(JFreeChart chart) { CategoryPlot plot = chart.getCategoryPlot(); final DrawingSupplier supplier = new DefaultDrawingSupplier( DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, // Draw a small diamond new Shape[] { new Polygon(new int[] {3, 0, -3, 0}, new int[] {0, 3, 0, -3}, 4) } ); plot.setDomainGridlinePaint(Color.black); plot.setRangeGridlinePaint(Color.black); plot.setDrawingSupplier(supplier); LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setShapesVisible(true); renderer.setStroke(new BasicStroke(2.0f)); }
static protected void configureLineChart(JFreeChart chart) { CategoryPlot plot = chart.getCategoryPlot(); final DrawingSupplier supplier = new DefaultDrawingSupplier( DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, // Draw a small diamond new Shape[] { new Polygon(new int[] {3, 0, -3, 0}, new int[] {0, 3, 0, -3}, 4) } ); plot.setDomainGridlinePaint(Color.black); plot.setRangeGridlinePaint(Color.black); plot.setDrawingSupplier(supplier); LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setShapesVisible(true); renderer.setStroke(new BasicStroke(2.0f)); CategoryAxis axis = plot.getDomainAxis(); axis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90); }
/** * Utility method to set the default style of the Line Charts * * @param chart {@link JFreeChart} to style * @param showShapes indicate if shapes along the line will be shown */ private static void setLineChartDefaults(JFreeChart chart, boolean showShapes) { ChartUtil.setDefaults(chart); CategoryPlot plot = (CategoryPlot) chart.getPlot(); // renderer LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setBaseItemLabelFont(ChartDefaults.defaultFont); renderer.setBaseItemLabelPaint(ChartDefaults.axisLabelColor); for (int j = 0; j < ChartDefaults.darkColors.length; j++) { renderer.setSeriesPaint(j, ChartDefaults.darkColors[j]); } renderer.setBaseShapesVisible(showShapes); renderer.setBaseStroke(ChartDefaults.defaultStroke); renderer.setStroke(ChartDefaults.defaultStroke); }
renderer.setStroke(new BasicStroke(2.0f)); ColorPalette.apply(renderer);
renderer.setStroke(new BasicStroke(2.0f)); ColorPalette.apply(renderer);
renderer.setStroke(new BasicStroke(2.0f)); ColorPalette.apply(renderer);
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; }
lineRenderer.setStroke( JFreeChartEngine.getLineStyleStroke( chartDefinition.getLineStyle(), chartDefinition .getLineWidth() ) ); lineRenderer.setShapesVisible( chartDefinition.isMarkersVisible() );