Example usage for org.jfree.chart.title LegendTitle setItemFont

List of usage examples for org.jfree.chart.title LegendTitle setItemFont

Introduction

In this page you can find the example usage for org.jfree.chart.title LegendTitle setItemFont.

Prototype

public void setItemFont(Font font) 

Source Link

Document

Sets the item font and sends a TitleChangeEvent to all registered listeners.

Usage

From source file:com.ohalo.cn.awt.JFreeChartTest3.java

public static void main(String[] args) throws Exception {
    JFreeChart chart = ChartFactory.createPieChart("???", getDataset(), true, true,
            false);/*www  . j av  a 2 s . c  o m*/
    chart.setTitle(new TextTitle("??", new Font("", Font.BOLD + Font.ITALIC, 20)));

    LegendTitle legend = chart.getLegend(0);// Legend
    legend.setItemFont(new Font("", Font.BOLD, 14));
    PiePlot plot = (PiePlot) chart.getPlot();// Plot
    plot.setLabelFont(new Font("", Font.BOLD, 16));

    OutputStream os = new FileOutputStream("company.jpeg");// ??FileOutputStream?
    ChartUtilities.writeChartAsJPEG(os, chart, 1000, 800);
    // ??applicationchart??JPEG?3?4?

    os.close();// ?
}

From source file:org.jfree.chart.demo.XYTitleAnnotationDemo1.java

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Legal & General Unit Trust Prices", "Date",
            "Price Per Unit", xydataset, false, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    xyplot.setDomainCrosshairVisible(true);
    xyplot.setRangeCrosshairVisible(true);
    LegendTitle legendtitle = new LegendTitle(xyplot);
    legendtitle.setItemFont(new Font("Dialog", 0, 9));
    legendtitle.setBackgroundPaint(new Color(200, 200, 255, 100));
    legendtitle.setFrame(new BlockBorder(Color.white));
    legendtitle.setPosition(RectangleEdge.BOTTOM);
    XYTitleAnnotation xytitleannotation = new XYTitleAnnotation(0.97999999999999998D, 0.02D, legendtitle,
            RectangleAnchor.BOTTOM_RIGHT);
    xytitleannotation.setMaxWidth(0.47999999999999998D);
    xyplot.addAnnotation(xytitleannotation);
    org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer();
    if (xyitemrenderer instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer;
        xylineandshaperenderer.setBaseShapesVisible(true);
        xylineandshaperenderer.setBaseShapesFilled(true);
    }//from w  w w  .  ja v  a 2 s. c o m
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
    ValueAxis valueaxis = xyplot.getRangeAxis();
    valueaxis.setLowerMargin(0.34999999999999998D);
    return jfreechart;
}

From source file:com.ouc.cpss.view.ProfitChartBuilder.java

public static JFreeChart createJFreeChart(CategoryDataset dataset) {

    JFreeChart chart = ChartFactory.createLineChart("?", "", "?",
            dataset, PlotOrientation.VERTICAL, true, true, false);
    // ?// ww  w .j a  va  2 s . co  m
    LegendTitle legendTitle = chart.getLegend(0);
    // 
    legendTitle.setItemFont(new Font("", Font.BOLD, 18));
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    // ?
    org.jfree.chart.axis.CategoryAxis categoryAxis = plot.getDomainAxis();
    // 
    categoryAxis.setLabelFont(new Font("", Font.BOLD, 18));

    // 
    categoryAxis.setTickLabelFont(new Font("", Font.BOLD, 12));
    // ?
    NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis();
    // 
    numberAxis.setLabelFont(new Font("", Font.BOLD, 14));

    numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());//

    CategoryItemRenderer xylineandshaperenderer = plot.getRenderer();
    xylineandshaperenderer.setBaseItemLabelsVisible(true);
    xylineandshaperenderer.setBasePositiveItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE2, TextAnchor.BASELINE_RIGHT));
    xylineandshaperenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    return chart;
}

From source file:uk.ac.lkl.cram.ui.chart.TLALearningTypeChartFactory.java

private static JFreeChart createChart(PieDataset dataset) {
    //Create a pie chart from the chart factory with no title, a legend and no tooltips
    JFreeChart chart = ChartFactory.createPieChart(null, dataset, true, false, false);
    //Set the background colour of the chart
    Paint backgroundPaint = Color.white;
    chart.setBackgroundPaint(backgroundPaint);
    //Get the plot from the chart
    PiePlot plot = (PiePlot) chart.getPlot();
    //Set the background colour of the plot to be the same as the chart
    plot.setBackgroundPaint(backgroundPaint);
    //Remove shadows from the plot
    plot.setShadowXOffset(0);//from www  .java2s .  c o m
    plot.setShadowYOffset(0);
    //Remove the outline from the plot
    plot.setOutlineVisible(false);
    //Remove the labels from the plot
    plot.setLabelGenerator(null);
    //Set the colours for the segments
    plot.setSectionPaint(LearningTypeChartMaker.ACQUISITION, LearningTypeChartMaker.ACQUISITION_COLOR);
    plot.setSectionPaint(LearningTypeChartMaker.COLLABORATION, LearningTypeChartMaker.COLLABORATION_COLOR);
    plot.setSectionPaint(LearningTypeChartMaker.DISCUSSION, LearningTypeChartMaker.DISCUSSION_COLOR);
    plot.setSectionPaint(LearningTypeChartMaker.INQUIRY, LearningTypeChartMaker.INQUIRY_COLOR);
    plot.setSectionPaint(LearningTypeChartMaker.PRACTICE, LearningTypeChartMaker.PRACTICE_COLOR);
    plot.setSectionPaint(LearningTypeChartMaker.PRODUCTION, LearningTypeChartMaker.PRODUCTION_COLOR);
    //Get the legend from the chart
    LegendTitle legend = chart.getLegend();
    //Set the font of the legend to be the same as the platform UI
    legend.setItemFont(UIManager.getFont("Label.font"));
    //Set the background colour of the legend to be the same as the chart
    legend.setBackgroundPaint(backgroundPaint);
    //Remove the border from the legend
    legend.setFrame(BlockBorder.NONE);
    //Locate the legend to the right of the plot
    legend.setPosition(RectangleEdge.RIGHT);
    return chart;
}

From source file:org.jfree.experimental.chart.demo.XYTitleAnnotationDemo1.java

/**
 * Creates a chart.//from w w  w .  j  a  va2 s.c om
 * 
 * @param dataset  a dataset.
 * 
 * @return A chart.
 */
private static JFreeChart createChart(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createTimeSeriesChart("Legal & General Unit Trust Prices", // title
            "Date", // x-axis label
            "Price Per Unit", // y-axis label
            dataset, // data
            false, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    LegendTitle lt = new LegendTitle(plot);
    lt.setItemFont(new Font("Dialog", Font.PLAIN, 9));
    lt.setBackgroundPaint(new Color(200, 200, 255, 100));
    lt.setFrame(new BlockBorder(Color.white));
    lt.setPosition(RectangleEdge.BOTTOM);
    XYTitleAnnotation ta = new XYTitleAnnotation(0.98, 0.02, lt, RectangleAnchor.BOTTOM_RIGHT);

    ta.setMaxWidth(0.48);
    plot.addAnnotation(ta);

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
    }

    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));

    ValueAxis yAxis = plot.getRangeAxis();
    yAxis.setLowerMargin(0.35);
    return chart;

}

From source file:org.gbif.portal.web.util.ChartUtils.java

/**
 * Writes out the image using the supplied file name.
 * /* w ww.ja v  a  2 s. c o  m*/
 * @param legend
 * @param fileName
 * @return
 */
public static String writePieChartImageToTempFile(Map<String, Double> legend, String fileName) {

    String filePath = System.getProperty(tmpDirSystemProperty) + File.separator + fileName + defaultExtension;
    File fileToCheck = new File(filePath);
    if (fileToCheck.exists()) {
        return fileName + defaultExtension;
    }

    final DefaultPieDataset data = new DefaultPieDataset();
    Set<String> keys = legend.keySet();
    for (String key : keys) {
        logger.info("Adding key : " + key);
        data.setValue(key, legend.get(key));
    }

    // create a pie chart...
    final boolean withLegend = true;
    final JFreeChart chart = ChartFactory.createPieChart(null, data, withLegend, false, false);

    PiePlot piePlot = (PiePlot) chart.getPlot();
    piePlot.setLabelFont(new Font("Arial", Font.PLAIN, 10));
    piePlot.setLabelBackgroundPaint(Color.WHITE);

    LegendTitle lt = chart.getLegend();
    lt.setBackgroundPaint(Color.WHITE);
    lt.setWidth(300);
    lt.setBorder(0, 0, 0, 0);
    lt.setItemFont(new Font("Arial", Font.PLAIN, 11));

    chart.setPadding(new RectangleInsets(0, 0, 0, 0));
    chart.setBorderVisible(false);
    chart.setBackgroundImageAlpha(0);
    chart.setBackgroundPaint(Color.WHITE);
    chart.setBorderPaint(Color.LIGHT_GRAY);

    final BufferedImage image = new BufferedImage(300, 250, BufferedImage.TYPE_INT_RGB);
    KeypointPNGEncoderAdapter adapter = new KeypointPNGEncoderAdapter();
    adapter.setQuality(1);
    try {
        adapter.encode(image);
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    }
    final Graphics2D g2 = image.createGraphics();
    g2.setFont(new Font("Arial", Font.PLAIN, 11));
    final Rectangle2D chartArea = new Rectangle2D.Double(0, 0, 300, 250);

    // draw
    chart.draw(g2, chartArea, null, null);

    try {
        FileOutputStream fOut = new FileOutputStream(fileToCheck);
        ChartUtilities.writeChartAsPNG(fOut, chart, 300, 250);
        return fileToCheck.getName();
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
        return null;
    }
}

From source file:com.ouc.cpss.view.SupTradeChartBuilder.java

private static JFreeChart createJFreeChart(PieDataset dataset) {
    /**//from   w ww.j a  va  2s.c o  m
     * JFreeChart
     */
    //?     
    StandardChartTheme standardChartTheme = new StandardChartTheme("CN");
    //     
    standardChartTheme.setExtraLargeFont(new Font("", Font.BOLD, 20));
    //    
    standardChartTheme.setRegularFont(new Font("", Font.PLAIN, 15));
    //?     
    standardChartTheme.setLargeFont(new Font("", Font.PLAIN, 15));
    //?   
    ChartFactory.setChartTheme(standardChartTheme);
    //??  
    //createPieChart 2D; createPieChart3D  3D
    JFreeChart chart = ChartFactory.createPieChart("", dataset, true, true, false);

    //,?
    chart.setTitle(new TextTitle("", new Font("", Font.ITALIC, 22)));

    //?
    LegendTitle legend = chart.getLegend(0);
    //,ture,?
    legend.setItemFont(new Font("", Font.BOLD, 20));

    //?(??)
    PiePlot plot = (PiePlot) chart.getPlot();
    //?==?
    plot.setLabelFont(new Font("", Font.BOLD, 22));
    //
    plot.setBaseSectionOutlinePaint(Color.BLUE);
    //
    plot.setBaseSectionOutlineStroke(new BasicStroke(0.5f));
    //?,??,??
    plot.setDirection(Rotation.CLOCKWISE);//,Rotation.CLOCKWISE
    //()
    plot.setStartAngle(70);
    //???
    //plot.setExplodePercent(1, 0.5D);
    //plot.setExplodePercent("One", 0.5D);
    //,3D?
    plot.setExplodePercent(dataset.getKey(0), 0.1d);
    //
    plot.setLabelLinkPaint(Color.BLUE);
    //
    plot.setLabelOutlinePaint(Color.black);
    //
    plot.setLabelShadowPaint(Color.RED);
    //
    plot.setSectionPaint(1, Color.BLACK);
    // :,{0},{1},{2}?,???
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}:{1}\r\n{2}",
            NumberFormat.getNumberInstance(), new DecimalFormat("0.00%")));

    //
    plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}={2}"));
    //:(true),(false)
    plot.setCircular(true);
    //?
    plot.setNoDataMessage("??...");

    //???
    plot.setToolTipGenerator(new StandardPieToolTipGenerator());
    //
    //plot.setURLGenerator(new StandardPieURLGenerator("detail.jsp"));

    return chart;
}

From source file:org.eobjects.datacleaner.util.ChartUtils.java

public static void applyStyles(JFreeChart chart) {
    TextTitle title = chart.getTitle();//from   w w w. j ava  2  s  .c  o  m
    if (title != null) {
        title.setFont(WidgetUtils.FONT_HEADER1);
        title.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST);
    }

    for (int i = 0; i < chart.getSubtitleCount(); i++) {
        Title subtitle = chart.getSubtitle(i);
        if (subtitle instanceof TextTitle) {
            ((TextTitle) subtitle).setFont(WidgetUtils.FONT_NORMAL);
        }
    }

    LegendTitle legend = chart.getLegend();
    if (legend != null) {
        legend.setItemFont(WidgetUtils.FONT_SMALL);
    }

    // transparent background
    chart.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST);
    chart.setBorderVisible(false);

    final Plot plot = chart.getPlot();
    plot.setInsets(new RectangleInsets(UnitType.ABSOLUTE, 0d, 0d, 0d, 0d));
    plot.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST);
    plot.setOutlinePaint(WidgetUtils.BG_COLOR_BRIGHTEST);
    plot.setOutlineVisible(true);

    if (plot instanceof PiePlot) {
        // tweaks for pie charts
        final PiePlot piePlot = (PiePlot) plot;
        piePlot.setBaseSectionOutlinePaint(WidgetUtils.BG_COLOR_DARK);
        piePlot.setBaseSectionOutlineStroke(normalStroke);
        piePlot.setLabelFont(WidgetUtils.FONT_SMALL);
        piePlot.setLabelBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHT);
        piePlot.setLabelOutlineStroke(normalStroke);
        piePlot.setLabelPaint(WidgetUtils.BG_COLOR_DARK);
        piePlot.setSectionOutlinesVisible(false);
        piePlot.setLabelLinkStyle(PieLabelLinkStyle.QUAD_CURVE);
    } else if (plot instanceof CategoryPlot) {
        // tweaks for bar charts
        final CategoryPlot categoryPlot = (CategoryPlot) plot;

        int columnCount = categoryPlot.getDataset().getColumnCount();
        if (columnCount > 1) {
            categoryPlot.setDomainGridlinesVisible(true);
        } else {
            categoryPlot.setDomainGridlinesVisible(false);
        }
        categoryPlot.setDomainGridlinePaint(WidgetUtils.BG_COLOR_DARK);
        categoryPlot.setDomainGridlinePosition(CategoryAnchor.END);

        categoryPlot.getDomainAxis().setLabelFont(WidgetUtils.FONT_SMALL);
        categoryPlot.getDomainAxis().setTickLabelFont(WidgetUtils.FONT_SMALL);
        categoryPlot.getRangeAxis().setLabelFont(WidgetUtils.FONT_SMALL);
        categoryPlot.getRangeAxis().setTickLabelFont(WidgetUtils.FONT_SMALL);
        categoryPlot.setDrawingSupplier(new DCDrawingSupplier());

        final CategoryItemRenderer renderer = categoryPlot.getRenderer();
        renderer.setBaseOutlinePaint(WidgetUtils.BG_COLOR_DARK);
        renderer.setBaseOutlineStroke(wideStroke);

        if (renderer instanceof BarRenderer) {
            BarRenderer barRenderer = (BarRenderer) renderer;
            barRenderer.setShadowPaint(WidgetUtils.BG_COLOR_BRIGHT);
            barRenderer.setBarPainter(new StandardBarPainter());
        }

    } else if (plot instanceof XYPlot) {
        // tweaks for line charts
        final XYPlot xyPlot = (XYPlot) plot;

        xyPlot.setDrawingSupplier(new DCDrawingSupplier());

        xyPlot.getDomainAxis().setLabelFont(WidgetUtils.FONT_SMALL);
        xyPlot.getDomainAxis().setTickLabelFont(WidgetUtils.FONT_SMALL);
        xyPlot.getRangeAxis().setLabelFont(WidgetUtils.FONT_SMALL);
        xyPlot.getRangeAxis().setTickLabelFont(WidgetUtils.FONT_SMALL);

        final XYItemRenderer renderer = xyPlot.getRenderer();
        final int seriesCount = xyPlot.getSeriesCount();
        for (int i = 0; i < seriesCount; i++) {
            renderer.setSeriesStroke(i, wideStroke);
        }
    }
}

From source file:y.graphs.ChartHelperELF.java

private static JFreeChart createChart(final TimeSeriesCollection dataset, Date from, Date to, Config config,
        ArrayList<ConfigSerie> series) {
    final JFreeChart chart = ChartFactory.createTimeSeriesChart(Config.getResource("MsgTitleMagGraph"),
            Config.getResource("TitleDate"), Config.getResource("MsgTitleMagGraphYAxis"), dataset, true, // include legend
            true, // tooltips
            false // urls
    );//from   w ww.  ja v  a2s. com

    chart.setBackgroundPaint(Color.white);

    final XYPlot plot = chart.getXYPlot();
    LegendTitle lt = new LegendTitle(plot);
    lt.setItemFont(new Font("Dialog", Font.PLAIN, 12));
    lt.setBackgroundPaint(Color.white);
    lt.setFrame(new BlockBorder(Color.white));
    lt.setVerticalAlignment(VerticalAlignment.CENTER);
    XYTitleAnnotation ta = new XYTitleAnnotation(config.getLegendX(), config.getLegendY(), lt,
            RectangleAnchor.TOP_RIGHT);
    ta.setMaxWidth(config.getLegendSize());
    plot.addAnnotation(ta);
    chart.removeLegend();

    plot.setBackgroundPaint(config.getColorBackgroundELF());
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    final Stroke lineStroke = new BasicStroke((float) config.getLineWidthELF());

    for (int si = 0; si < series.size(); si++) {
        final ConfigSerie cs = series.get(si);
        renderer.setSeriesLinesVisible(si, cs.isDrawLine());

        final float size = cs.getShapeSize();
        renderer.setSeriesShapesVisible(si, size > 0);
        if (size > 0)
            renderer.setSeriesShape(si, ShapeUtilities.createRegularCross(size, size));

        renderer.setSeriesStroke(si, lineStroke);
        //            renderer.setSeriesOutlineStroke(si, lineStroke);
        renderer.setSeriesPaint(si, cs.getColor());
    }
    plot.setRenderer(renderer);

    // x axis
    final DateAxis rangeAxis = (DateAxis) plot.getDomainAxis();
    //        rangeAxis.setStandardTickUnits(DateAxis.createStandardDateTickUnits()); // Returns a collection of standard date tick units that uses the default time zone. This collection will be used by default, but you are free to create your own collection if you want to
    rangeAxis.setAutoRange(true);
    //        rangeAxis.setRange(from, to);
    rangeAxis.setLowerMargin(0.01);
    rangeAxis.setUpperMargin(0.01);

    {
        final Font axisFont = config.getAxisFont();
        if (axisFont != null) {
            rangeAxis.setLabelFont(axisFont);
            plot.getRangeAxis().setLabelFont(axisFont);
        }
    }

    final String xaxisFmt = config.getAxisFormat();

    if (xaxisFmt == null || xaxisFmt.isEmpty()) {
        double diffInDays = (to.getTime() - from.getTime()) / (1000.0 * 60.0 * 60.0 * 24.0);
        if (diffInDays < 2)
            rangeAxis.setDateFormatOverride(
                    new SimpleDateFormat(Config.DEFAULT_TIMEFMT, DateFormatSymbols.getInstance()));
        else
            rangeAxis.setDateFormatOverride(
                    new SimpleDateFormat(Config.DEFAULT_SHORTTIMEFMT, DateFormatSymbols.getInstance()));
    } else
        rangeAxis.setDateFormatOverride(new SimpleDateFormat(xaxisFmt, DateFormatSymbols.getInstance()));

    final ValueAxis domain = plot.getRangeAxis();
    if (config.getForceYmin() != 0 || config.getForceYmax() != 0)
        domain.setRange(ElfValue.valueIntToDouble(config.getForceYmin()),
                ElfValue.valueIntToDouble(config.getForceYmax()));

    // title
    final Font titleFont = config.getTitleFont();
    if (titleFont != null)
        chart.getTitle().setFont(titleFont);

    return chart;
}

From source file:y.graphs.ChartHelperSRB.java

private static JFreeChart createChart(final TimeSeriesCollection dataset, Date from, Date to, Config config,
        ArrayList<ConfigSerie> series) {
    final JFreeChart chart = ChartFactory.createTimeSeriesChart(Config.getResource("MsgTitleSrbGraph"),
            Config.getResource("TitleDate"), Config.getResource("MsgTitleSrbGraphYAxis"), dataset, true, // include legend
            true, // tooltips
            false // urls
    );/*from   w ww .j  a  v a 2s .  c o  m*/

    chart.setBackgroundPaint(Color.white);

    final XYPlot plot = chart.getXYPlot();
    LegendTitle lt = new LegendTitle(plot);
    lt.setItemFont(new Font("Dialog", Font.PLAIN, 12));
    lt.setBackgroundPaint(Color.white);
    lt.setFrame(new BlockBorder(Color.white));
    lt.setVerticalAlignment(VerticalAlignment.CENTER);
    XYTitleAnnotation ta = new XYTitleAnnotation(config.getLegendX(), config.getLegendY(), lt,
            RectangleAnchor.TOP_RIGHT);
    ta.setMaxWidth(config.getLegendSize());
    plot.addAnnotation(ta);
    chart.removeLegend();

    plot.setBackgroundPaint(config.getColorBackgroundSRB());
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    final Stroke lineStroke = new BasicStroke((float) config.getLineWidthSRB());

    for (int si = 0; si < series.size(); si++) {
        final ConfigSerie cs = series.get(si);
        renderer.setSeriesLinesVisible(si, cs.isDrawLine());

        final float size = cs.getShapeSize();
        renderer.setSeriesShapesVisible(si, size > 0);
        if (size > 0)
            renderer.setSeriesShape(si, ShapeUtilities.createRegularCross(size, size));

        renderer.setSeriesStroke(si, lineStroke);
        //          renderer.setSeriesOutlineStroke(si, lineStroke);
        renderer.setSeriesPaint(si, cs.getColor());
    }
    plot.setRenderer(renderer);

    // x axis
    final DateAxis rangeAxis = (DateAxis) plot.getDomainAxis();
    //      rangeAxis.setStandardTickUnits(DateAxis.createStandardDateTickUnits()); // Returns a collection of standard date tick units that uses the default time zone. This collection will be used by default, but you are free to create your own collection if you want to
    rangeAxis.setAutoRange(true);
    //        rangeAxis.setRange(from, to);
    rangeAxis.setLowerMargin(0.01);
    rangeAxis.setUpperMargin(0.01);

    {
        final Font axisFont = config.getAxisFont();
        if (axisFont != null) {
            rangeAxis.setLabelFont(axisFont);
            plot.getRangeAxis().setLabelFont(axisFont);
        }
    }

    final String xaxisFmt = config.getAxisFormat();

    if (xaxisFmt == null || xaxisFmt.isEmpty()) {
        double diffInDays = (to.getTime() - from.getTime()) / (1000.0 * 60.0 * 60.0 * 24.0);
        if (diffInDays < 2)
            rangeAxis.setDateFormatOverride(
                    new SimpleDateFormat(Config.DEFAULT_TIMEFMT, DateFormatSymbols.getInstance()));
        else
            rangeAxis.setDateFormatOverride(
                    new SimpleDateFormat(Config.DEFAULT_SHORTTIMEFMT, DateFormatSymbols.getInstance()));
    } else
        rangeAxis.setDateFormatOverride(new SimpleDateFormat(xaxisFmt, DateFormatSymbols.getInstance()));

    final ValueAxis domain = plot.getRangeAxis();
    if (config.getForceYmin() != 0 || config.getForceYmax() != 0)
        domain.setRange(ElfValue.valueIntToDouble(config.getForceYmin()),
                ElfValue.valueIntToDouble(config.getForceYmax()));

    // title
    final Font titleFont = config.getTitleFont();
    if (titleFont != null)
        chart.getTitle().setFont(titleFont);

    return chart;
}