Example usage for org.jfree.chart.axis DateAxis DateAxis

List of usage examples for org.jfree.chart.axis DateAxis DateAxis

Introduction

In this page you can find the example usage for org.jfree.chart.axis DateAxis DateAxis.

Prototype

public DateAxis(String label) 

Source Link

Document

Creates a date axis with the specified label.

Usage

From source file:org.ietr.preesm.mapper.ui.BestCostPlotter.java

/**
 * Creates a chart./*from w w w  .  java 2 s.c om*/
 * 
 * @return A chart.
 */
private JFreeChart createChart(String title) {

    final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new DateAxis("Time"));
    this.datasets = new TimeSeriesCollection[subplotCount];

    for (int i = 0; i < subplotCount; i++) {
        this.lastValue[i] = 100.0;
        final TimeSeries series = new TimeSeries("Real Time", Millisecond.class);
        this.datasets[i] = new TimeSeriesCollection(series);
        final NumberAxis rangeAxis = new NumberAxis("Schedule");
        rangeAxis.setAutoRangeIncludesZero(false);
        final XYPlot subplot = new XYPlot(this.datasets[i], null, rangeAxis, new XYLineAndShapeRenderer());

        subplot.setBackgroundPaint(Color.white);
        subplot.setDomainGridlinePaint(Color.lightGray);
        subplot.setRangeGridlinePaint(Color.lightGray);
        plot.add(subplot);
    }

    final JFreeChart chart = new JFreeChart(title, plot);

    chart.removeLegend();
    // chart.getLegend().setPosition(RectangleEdge.BOTTOM);

    chart.setBorderPaint(Color.lightGray);
    chart.setBorderVisible(true);

    Paint p = GanttPlotter.getBackgroundColorGradient();
    chart.setBackgroundPaint(p);

    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.black);

    final ValueAxis axis = plot.getDomainAxis();
    axis.setAutoRange(true);

    return chart;

}

From source file:org.esa.beam.visat.toolviews.diag.TileCacheMonitor.java

/**
 * Creates a new monitor panel.//  w  w w .  j a  v a  2  s. co m
 *
 * @return the monitor panel
 */
public JPanel createPanel() {

    JPanel mainPanel = new JPanel(new BorderLayout());
    CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new DateAxis("Time"));
    this.datasets = new TimeSeriesCollection[4];
    this.datasets[0] = addSubPlot(plot, "#Tiles");
    this.datasets[1] = addSubPlot(plot, "#Hits");
    this.datasets[2] = addSubPlot(plot, "#Misses");
    this.datasets[3] = addSubPlot(plot, "Mem (kB)");

    JFreeChart chart = new JFreeChart(plot);
    LegendTitle legend = (LegendTitle) chart.getSubtitle(0);
    legend.setPosition(RectangleEdge.RIGHT);
    legend.setMargin(new RectangleInsets(UnitType.ABSOLUTE, 0, 4, 0, 4));
    chart.setBorderPaint(Color.black);
    chart.setBorderVisible(true);
    chart.setBackgroundPaint(Color.white);

    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(4, 4, 4, 4));
    ValueAxis axis = plot.getDomainAxis();
    axis.setAutoRange(true);
    axis.setFixedAutoRange(60000.0); // 60 seconds

    textarea = new JTextArea();
    tableModel = new TileCacheTableModel();
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 470));
    chartPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    tabbedPane = new JTabbedPane();
    tabbedPane.add(CACHE_INFO_TAB, new JScrollPane(textarea));
    tabbedPane.add(CACHE_CHART_TAB, chartPanel);
    tabbedPane.add(IMAGES_TAB, new JScrollPane(new JTable(tableModel)));
    tabbedPane.setSelectedIndex(0);

    mainPanel.add(tabbedPane);

    return mainPanel;
}

From source file:org.hxzon.demo.jfreechart.DatasetVisibleDemo.java

private static JFreeChart createTimeSeriesChart(XYDataset dataset) {
    //DomainAxis//from w w  w .  j  ava2s  .c o m
    DateAxis timeAxis = new DateAxis("");
    timeAxis.setLowerMargin(0.02); // reduce the default margins
    timeAxis.setUpperMargin(0.02);
    timeAxis.setDateFormatOverride(new SimpleDateFormat("MM-yyyy"));
    //RangeAxis
    NumberAxis valueAxis = new NumberAxis("");
    valueAxis.setAutoRangeIncludesZero(false); // override default
    //        valueAxis.setAutoRange(false);
    //        valueAxis.setDefaultAutoRange(new Range(100, 1150));
    //Renderer
    XYToolTipGenerator toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance();
    XYURLGenerator urlGenerator = null;
    //            urlGenerator = new StandardXYURLGenerator();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
    renderer.setBaseToolTipGenerator(toolTipGenerator);
    renderer.setURLGenerator(urlGenerator);
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);
    renderer.setDrawSeriesLineAsPath(true);
    //Plot
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
    plot.setRenderer(renderer);
    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);
    //        plot.setRangePannable(true);
    //chart
    JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);

    chart.setBackgroundPaint(Color.white);
    return chart;
}

From source file:com.bdb.weather.display.summary.HighLowMedianTempPanel.java

/**
 * Constructor./*w w  w  . ja  v  a 2  s.  co  m*/
 * 
 * @param interval The interval for which this graph is being used. Intervals are typically day, week, month or year.
 * @param launcher A class that is used to launch sub-views when a data item is double-clicked
 * @param supporter A class that aids in the generalization of this graph
 */
@SuppressWarnings("LeakingThisInConstructor")
public HighLowMedianTempPanel(SummaryInterval interval, ViewLauncher launcher, SummarySupporter supporter) {
    this.setPrefSize(500, 300);
    this.interval = interval;
    tableHeadings = getTableColumnLabels();
    chart = ChartFactory.createXYLineChart("", "", "", null, PlotOrientation.VERTICAL, true, true, true);
    plot = (XYPlot) chart.getPlot();
    viewLauncher = launcher;
    this.supporter = supporter;

    StandardXYToolTipGenerator ttgen = new StandardXYToolTipGenerator(
            StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, interval.getLegacyFormat(),
            Temperature.getDefaultFormatter());

    diffRenderer.setBaseToolTipGenerator(ttgen);

    plot.setRenderer(LOW_DATASET, diffRenderer);
    plot.setRenderer(HIGH_DATASET, diffRenderer);
    plot.setRenderer(MEDIAN_DATASET, diffRenderer);

    valueAxis.setAutoRangeIncludesZero(false);

    plot.setRangeCrosshairLockedOnData(true);
    plot.setRangeCrosshairVisible(true);
    plot.setDomainCrosshairLockedOnData(true);
    plot.setDomainCrosshairVisible(true);

    plot.setRangeAxis(valueAxis);
    dateAxis = new DateAxis("Date");
    dateAxis.setDateFormatOverride(interval.getLegacyFormat());
    dateAxis.setVerticalTickLabels(true);
    //dateAxis.setTickUnit(interval.getDateTickUnit());

    plot.setDomainAxis(dateAxis);

    chartViewer = new ChartViewer(chart);
    chartViewer.setPrefSize(500, 300);
    chartViewer.addChartMouseListener(this);

    dataTable = new TableView();

    for (int i = 0; i < tableHeadings.length; i++) {
        TableColumn col = new TableColumn();
        //col.setHeaderValue(tableHeadings[i]);
        //col.setModelIndex(i);
        //colModel.addColumn(col);
    }

    this.setTabContents(chartViewer, dataTable);
}

From source file:com.mothsoft.alexis.web.ChartServlet.java

private void doLineGraph(final HttpServletRequest request, final HttpServletResponse response,
        final String title, final String[] dataSetIds, final Integer width, final Integer height,
        final Integer numberOfSamples) throws ServletException, IOException {

    final DataSetService dataSetService = WebApplicationContextUtils
            .getWebApplicationContext(this.getServletContext()).getBean(DataSetService.class);

    final OutputStream out = response.getOutputStream();
    response.setContentType("image/png");
    response.setHeader("Cache-Control", "max-age: 5; must-revalidate");

    final XYSeriesCollection seriesCollection = new XYSeriesCollection();

    final DateAxis dateAxis = new DateAxis(title != null ? title : "Time");
    final DateTickUnit unit = new DateTickUnit(DateTickUnit.HOUR, 1);
    final DateFormat chartFormatter = new SimpleDateFormat("ha");
    dateAxis.setDateFormatOverride(chartFormatter);
    dateAxis.setTickUnit(unit);//from   w  ww  .j a va  2s  .  c  om
    dateAxis.setLabelFont(DEFAULT_FONT);
    dateAxis.setTickLabelFont(DEFAULT_FONT);

    if (numberOfSamples > 12) {
        dateAxis.setTickLabelFont(
                new Font(DEFAULT_FONT.getFamily(), Font.PLAIN, (int) (DEFAULT_FONT.getSize() * .8)));
    }

    final NumberAxis yAxis = new NumberAxis("Activity");

    final StandardXYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES);

    int colorCounter = 0;

    if (dataSetIds != null) {
        for (final String dataSetIdString : dataSetIds) {
            final Long dataSetId = Long.valueOf(dataSetIdString);
            final DataSet dataSet = dataSetService.get(dataSetId);

            // go back for numberOfSamples, but include current hour
            final Calendar calendar = new GregorianCalendar();
            calendar.add(Calendar.HOUR_OF_DAY, -1 * (numberOfSamples - 1));
            calendar.set(Calendar.MINUTE, 0);
            calendar.set(Calendar.SECOND, 0);
            calendar.set(Calendar.MILLISECOND, 0);
            final Timestamp startDate = new Timestamp(calendar.getTimeInMillis());

            calendar.add(Calendar.HOUR_OF_DAY, numberOfSamples);
            calendar.set(Calendar.MINUTE, 59);
            calendar.set(Calendar.SECOND, 59);
            calendar.set(Calendar.MILLISECOND, 999);
            final Timestamp endDate = new Timestamp(calendar.getTimeInMillis());

            logger.debug(String.format("Generating chart for period: %s to %s", startDate.toString(),
                    endDate.toString()));

            final List<DataSetPoint> dataSetPoints = dataSetService
                    .findAndAggregatePointsGroupedByUnit(dataSetId, startDate, endDate, TimeUnits.HOUR);

            final boolean hasData = addSeries(seriesCollection, dataSet.getName(), dataSetPoints, startDate,
                    numberOfSamples, renderer);

            if (dataSet.isAggregate()) {
                renderer.setSeriesPaint(seriesCollection.getSeriesCount() - 1, Color.BLACK);
            } else if (hasData) {
                renderer.setSeriesPaint(seriesCollection.getSeriesCount() - 1,
                        PAINTS[colorCounter++ % PAINTS.length]);
            } else {
                renderer.setSeriesPaint(seriesCollection.getSeriesCount() - 1, Color.LIGHT_GRAY);
            }
        }
    }

    final XYPlot plot = new XYPlot(seriesCollection, dateAxis, yAxis, renderer);

    // create the chart...
    final JFreeChart chart = new JFreeChart(plot);

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    plot.setBackgroundPaint(new Color(253, 253, 253));
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

    // set the range axis to display integers only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setLabelFont(DEFAULT_FONT);
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setLowerBound(0.00d);

    ChartUtilities.writeChartAsPNG(out, chart, width, height);
}

From source file:com.unicornlabs.kabouter.gui.power.PowerPanel.java

/**
 * Sets the chart data and title//from  www  .ja  v  a 2 s  .c  om
 *
 * @param logs the list of power logs
 * @param title the title of the chart
 */
public void setupChart(ArrayList<Powerlog> logs, String title) {

    myDataSeriesMap.clear();

    //Create a collection to store the series
    dataset = new XYSeriesCollection();

    //Add each of the logs to the series
    for (Powerlog p : logs) {
        XYSeries deviceSeries = myDataSeriesMap.get(p.getId().getDeviceid());

        if (deviceSeries == null) {
            deviceSeries = new XYSeries(p.getId().getDeviceid());
            myDataSeriesMap.put(p.getId().getDeviceid(), deviceSeries);
            dataset.addSeries(deviceSeries);
        }

        deviceSeries.add(p.getId().getLogtime().getTime(), p.getPower());
    }

    //Create a custom date axis to display dates on the X axis
    DateAxis dateAxis = new DateAxis("Date");
    //Make the labels vertical
    dateAxis.setVerticalTickLabels(true);

    //Create the power axis
    NumberAxis powerAxis = new NumberAxis("Power");

    //Set both axes to auto range for their values
    powerAxis.setAutoRange(true);
    dateAxis.setAutoRange(true);

    //Create the tooltip generator
    StandardXYToolTipGenerator ttg = new StandardXYToolTipGenerator("{0}: {2}",
            new SimpleDateFormat("yyyy/MM/dd HH:mm"), NumberFormat.getInstance());

    //Set the renderer
    StandardXYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.LINES, ttg, null);

    //Create the plot
    XYPlot plot = new XYPlot(dataset, dateAxis, powerAxis, renderer);

    //Create the chart
    myChart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true);

    //Attach the chart to the panel
    ((ChartPanel) chartPanel).setChart(myChart);
    //Set max draw size to 2560x1440
    ((ChartPanel) chartPanel).setMaximumDrawHeight(1440);
    ((ChartPanel) chartPanel).setMaximumDrawWidth(2560);
}

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

/**
 * Creates a ContourPlot chart.// w  ww . j  a v  a  2s.co m
 *
 * @return the chart.
 */
private JFreeChart createContourPlot() {

    final String title = "Contour Plot";
    final String xAxisLabel = "X Values";
    final String yAxisLabel = "Y Values";
    final String zAxisLabel = "Color Values";

    if (xIsDate) {
        this.xAxis = new DateAxis(xAxisLabel);
        xIsLog = false; // force axis to be linear when displaying dates
    } else {
        if (xIsLog) {
            this.xAxis = new LogarithmicAxis(xAxisLabel);
        } else {
            this.xAxis = new NumberAxis(xAxisLabel);
        }
    }

    if (yIsLog) {
        this.yAxis = new LogarithmicAxis(yAxisLabel);
    } else {
        this.yAxis = new NumberAxis(yAxisLabel);
    }

    if (zIsLog) {
        this.zColorBar = new ColorBar(zAxisLabel);
    } else {
        this.zColorBar = new ColorBar(zAxisLabel);
    }

    if (this.xAxis instanceof NumberAxis) {
        ((NumberAxis) this.xAxis).setAutoRangeIncludesZero(false);
        ((NumberAxis) this.xAxis).setInverted(xIsInverted);
    }

    this.yAxis.setAutoRangeIncludesZero(false);

    this.yAxis.setInverted(yIsInverted);

    if (!xIsDate) {
        ((NumberAxis) this.xAxis).setLowerMargin(0.0);
        ((NumberAxis) this.xAxis).setUpperMargin(0.0);
    }

    this.yAxis.setLowerMargin(0.0);
    this.yAxis.setUpperMargin(0.0);

    this.zColorBar.getAxis().setInverted(zIsInverted);
    this.zColorBar.getAxis().setTickMarksVisible(true);

    final ContourDataset data = createDataset();

    final ContourPlot plot = new ContourPlot(data, this.xAxis, this.yAxis, this.zColorBar);

    if (xIsDate) {
        ratio = Math.abs(ratio); // don't use plot units for ratios when x axis is date
    }
    plot.setDataAreaRatio(ratio);

    final JFreeChart chart = new JFreeChart(title, null, plot, false);
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.green));

    return chart;

}

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

/**
 * Creates a ContourPlot chart.//from  ww  w. ja  v  a2  s  .c  o m
 *
 * @return the ContourPlot chart.
 */
private JFreeChart createContourPlot() {

    final String title = "Contour Plot";
    final String xAxisLabel = "X Values";
    final String yAxisLabel = "Y Values";
    final String zAxisLabel = "Color Values";

    if (xIsDate) {
        this.xAxis = new DateAxis(xAxisLabel);
        xIsLog = false; // force axis to be linear when displaying dates
    } else {
        if (xIsLog) {
            this.xAxis = new LogarithmicAxis(xAxisLabel);
        } else {
            this.xAxis = new NumberAxis(xAxisLabel);
        }
    }

    if (yIsLog) {
        this.yAxis = new LogarithmicAxis(yAxisLabel);
    } else {
        this.yAxis = new NumberAxis(yAxisLabel);
    }

    if (zIsLog) {
        this.zColorBar = new ColorBar(zAxisLabel);
    } else {
        this.zColorBar = new ColorBar(zAxisLabel);
    }

    if (this.xAxis instanceof NumberAxis) {
        ((NumberAxis) this.xAxis).setAutoRangeIncludesZero(false);
        ((NumberAxis) this.xAxis).setInverted(xIsInverted);
    }

    this.yAxis.setAutoRangeIncludesZero(false);

    this.yAxis.setInverted(yIsInverted);

    if (!xIsDate) {
        ((NumberAxis) this.xAxis).setLowerMargin(0.0);
        ((NumberAxis) this.xAxis).setUpperMargin(0.0);
    }

    this.yAxis.setLowerMargin(0.0);
    this.yAxis.setUpperMargin(0.0);

    if (!xIsDate) {
        this.xAxis.setRange(10.5, 15.0);
    }
    this.yAxis.setRange(3.5, 7.0);

    this.zColorBar.getAxis().setInverted(zIsInverted);
    this.zColorBar.getAxis().setTickMarksVisible(true);

    final ContourDataset data = createDataset();

    final ContourPlot plot = new ContourPlot(data, this.xAxis, this.yAxis, this.zColorBar);

    if (xIsDate) {
        ratio = Math.abs(ratio); // don't use plot units for ratios when x axis is date
    }

    if (asPoints) {
        plot.setRenderAsPoints(true);
    }
    plot.setDataAreaRatio(ratio);

    if (annotate) {
        if (asPoints) {
            final Number[] xValues = data.getXValues();
            final Number[] yValues = data.getYValues();
            //Number[] zValues = data.getZValues();

            final Font font = new Font("SansSerif", Font.PLAIN, 20);

            for (int i = 0; i < xValues.length; i++) {
                final XYTextAnnotation xyAnn = new XYTextAnnotation(Integer.toString(i),
                        xValues[i].doubleValue(), yValues[i].doubleValue());
                xyAnn.setFont(font);
                plot.addAnnotation(xyAnn);
            }
        } else {
            final Font font = new Font("SansSerif", Font.PLAIN, 20);

            for (int i = 0; i < this.tmpDoubleX.length; i++) {
                final XYTextAnnotation xyAnn = new XYTextAnnotation(Integer.toString(i), this.tmpDoubleX[i],
                        this.tmpDoubleY[i]);
                xyAnn.setFont(font);
                plot.addAnnotation(xyAnn);
            }
        }

    }

    if (fillOutline || drawOutline) {
        initShoreline();
        plot.setClipPath(new ClipPath(this.xOutline, this.yOutline, true, fillOutline, drawOutline));
    }

    final JFreeChart chart = new JFreeChart(title, null, plot, false);

    // then customise it a little...
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.green));

    return chart;

}

From source file:edu.ucla.stat.SOCR.chart.demo.XYAreaChartDemo2.java

/**
 * Creates a chart./* w ww .  j ava2 s.  com*/
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
protected JFreeChart createChart(XYDataset dataset) {
    JFreeChart chart = ChartFactory.createXYAreaChart(chartTitle, "Time", "Value", dataset,
            PlotOrientation.VERTICAL, !legendPanelOn, // legend
            true, // tool tips
            false // URLs
    );
    XYPlot plot = chart.getXYPlot();

    ValueAxis domainAxis = new DateAxis("Time");
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    plot.setDomainAxis(domainAxis);
    plot.setForegroundAlpha(0.5f);

    XYItemRenderer renderer = plot.getRenderer();
    renderer.setBaseToolTipGenerator(
            new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
                    new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("#,##0.00")));
    renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());
    // setXSummary(dataset);    X is time
    return chart;
}

From source file:org.hxzon.demo.jfreechart.DatasetVisibleDemo2.java

private static JFreeChart createTimeSeriesChart(XYDataset dataset) {
    //DomainAxis//from   ww  w .j a  v  a 2s .c o  m
    DateAxis timeAxis = new DateAxis("");
    timeAxis.setLowerMargin(0.02); // reduce the default margins
    timeAxis.setUpperMargin(0.02);
    timeAxis.setDateFormatOverride(new SimpleDateFormat("MM-yyyy"));
    //RangeAxis
    NumberAxis valueAxis = new NumberAxis("");
    valueAxis.setAutoRangeIncludesZero(false); // override default
    //        valueAxis.setDefaultAutoRange(new Range(100, 1150));
    //Renderer

    XYToolTipGenerator toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance();

    XYURLGenerator urlGenerator = null;
    //            urlGenerator = new StandardXYURLGenerator();

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
    renderer.setBaseToolTipGenerator(toolTipGenerator);
    renderer.setURLGenerator(urlGenerator);
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);
    renderer.setDrawSeriesLineAsPath(true);
    //AbstractRenderer.dataBoundsIncludesVisibleSeriesOnly
    renderer.setDataBoundsIncludesVisibleSeriesOnly(false);
    renderer.setBaseSeriesVisibleInLegend(true);
    //Plot
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null) {
        private static final long serialVersionUID = 1L;

        //            public void rendererChanged(RendererChangeEvent event) {
        //                // if the event was caused by a change to series visibility, then
        //                // the axis ranges might need updating...
        //                if (event.getSeriesVisibilityChanged()) {
        ////                    configureDomainAxes();
        ////                    configureRangeAxes();
        //                }
        //                fireChangeEvent();
        //            }
    };
    plot.setRenderer(renderer);
    plot.setBackgroundPaint(plotBackgroundPaint);
    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);
    //        plot.setRangePannable(true);
    //chart
    JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);

    chart.setBackgroundPaint(Color.white);
    valueAxis.setAutoRange(false);
    timeAxis.setAutoRange(false);
    return chart;
}