Example usage for org.jfree.chart.plot XYPlot XYPlot

List of usage examples for org.jfree.chart.plot XYPlot XYPlot

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot XYPlot.

Prototype

public XYPlot(XYDataset dataset, ValueAxis domainAxis, ValueAxis rangeAxis, XYItemRenderer renderer) 

Source Link

Document

Creates a new plot with the specified dataset, axes and renderer.

Usage

From source file:com.charts.OneYearChart.java

public OneYearChart(YStockQuote currentStock) throws ParseException {

    DateAxis domainAxis = new DateAxis("Date");
    NumberAxis rangeAxis = new NumberAxis("Price");
    CandlestickRenderer renderer = new CandlestickRenderer();
    XYDataset dataset = getDataSet(currentStock);

    XYPlot mainPlot = new XYPlot(dataset, domainAxis, rangeAxis, renderer);

    //Do some setting up, see the API Doc
    renderer.setSeriesPaint(0, Color.BLACK);

    renderer.setDrawVolume(false);//from   ww w  . ja v a  2 s.c o  m
    rangeAxis.setAutoRangeIncludesZero(false);

    domainAxis.setDateFormatOverride(new SimpleDateFormat("dd-MM-yy"));
    domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);

    //Now create the chart and chart panel
    JFreeChart chart = new JFreeChart(currentStock.get_name(), null, mainPlot, false);
    chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(900, 400));

    XYPlot plot = (XYPlot) chart.getPlot();
    LegendTitle legend = new LegendTitle(plot);
    chart.addLegend(legend);
    chart.getLegend().setVisible(true);
    chart.getLegend().setPosition(RectangleEdge.BOTTOM);

    ValueAxis yAxis = (ValueAxis) plot.getRangeAxis();
    DateAxis xAxis = (DateAxis) plot.getDomainAxis();

    xAxis.setDateFormatOverride(new SimpleDateFormat("MMM y"));
    xAxis.setAutoTickUnitSelection(true);
    xAxis.setAutoRange(true);
    renderer.setAutoWidthFactor(0.5);
    renderer.setUpPaint(Color.green);
    renderer.setDownPaint(new Color(0xc0, 0x00, 0x00));
    renderer.setSeriesPaint(0, Color.black);
    StandardXYItemRenderer renderer1 = new StandardXYItemRenderer();
    renderer1.setSeriesPaint(0, Color.BLUE);
    TimeSeries movingAverage30 = MovingAverage.createMovingAverage(close, "MA(30)", 30, 0);
    Double currMA30 = (Double) movingAverage30.getDataItem(movingAverage30.getItemCount() - 1).getValue();
    currMA30 = Math.round(currMA30 * 100.0) / 100.0;
    movingAverage30.setKey("MA(30): " + currMA30);
    TimeSeriesCollection collection = new TimeSeriesCollection();
    collection.addSeries(movingAverage30);
    plot.setDataset(1, collection);
    plot.setRenderer(1, renderer1);

    chartPanel.revalidate();
    chartPanel.repaint();
    chartPanel.revalidate();
    chartPanel.repaint();
}

From source file:com.charts.OneMonthChart.java

public OneMonthChart(YStockQuote currentStock) throws ParseException {

    DateAxis domainAxis = new DateAxis("Date");
    NumberAxis rangeAxis = new NumberAxis("Price");
    CandlestickRenderer renderer = new CandlestickRenderer();
    XYDataset dataset = getDataSet(currentStock);

    XYPlot mainPlot = new XYPlot(dataset, domainAxis, rangeAxis, renderer);

    //Do some setting up, see the API Doc
    renderer.setSeriesPaint(0, Color.BLACK);
    renderer.setDrawVolume(false);//from  w w  w  . j  a va  2 s  .co m
    rangeAxis.setAutoRangeIncludesZero(false);

    domainAxis.setVerticalTickLabels(true);
    domainAxis.setDateFormatOverride(new SimpleDateFormat("dd-MM-yy"));
    domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);

    //Now create the chart and chart panel
    JFreeChart chart = new JFreeChart(currentStock.get_name(), null, mainPlot, false);
    chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(600, 300));

    XYPlot plot = (XYPlot) chart.getPlot();
    LegendTitle legend = new LegendTitle(plot);
    chart.addLegend(legend);
    chart.getLegend().setVisible(true);
    chart.getLegend().setPosition(RectangleEdge.BOTTOM);

    ValueAxis yAxis = (ValueAxis) plot.getRangeAxis();
    DateAxis xAxis = (DateAxis) plot.getDomainAxis();
    Date now = new Date();
    SegmentedTimeline segmentedTimeline = SegmentedTimeline.newMondayThroughFridayTimeline();
    Calendar[][] holidays = DayRange.getHolidayDates();
    int len = holidays.length;

    for (int i = 0; i < holidays[0].length; i++) {
        Calendar day = Calendar.getInstance(TimeZone.getTimeZone("EST"));
        day.set(Calendar.YEAR, holidays[0][i].get(Calendar.YEAR));
        day.set(Calendar.MONTH, holidays[0][i].get(Calendar.MONTH));
        day.set(Calendar.DAY_OF_MONTH, holidays[0][i].get(Calendar.DAY_OF_MONTH));
        day.set(Calendar.HOUR_OF_DAY, 9);
        segmentedTimeline.addException(day.getTime());

    }

    xAxis.setTimeline(segmentedTimeline);
    //xAxis.setVerticalTickLabels(true);
    xAxis.setDateFormatOverride(new SimpleDateFormat("MMM-dd"));
    xAxis.setAutoTickUnitSelection(false);
    xAxis.setAutoRange(false);
    renderer.setAutoWidthFactor(0.5);
    renderer.setUpPaint(Color.green);
    renderer.setDownPaint(new Color(0xc0, 0x00, 0x00));
    renderer.setSeriesPaint(0, Color.black);

    StandardXYItemRenderer renderer1 = new StandardXYItemRenderer();
    renderer1.setSeriesPaint(0, Color.BLUE);
    TimeSeries movingAverage30 = MovingAverage.createMovingAverage(close, "MA(30)", 30, 0);
    Double currMA30 = (Double) movingAverage30.getDataItem(movingAverage30.getItemCount() - 1).getValue();
    currMA30 = Math.round(currMA30 * 100.0) / 100.0;
    movingAverage30.setKey("MA(30): " + currMA30);
    TimeSeriesCollection collection = new TimeSeriesCollection();
    collection.addSeries(movingAverage30);
    plot.setDataset(1, collection);
    plot.setRenderer(1, renderer1);

    chartPanel.revalidate();
    chartPanel.repaint();
    chartPanel.revalidate();
    chartPanel.repaint();
}

From source file:com.charts.ThreeMonthChart.java

public ThreeMonthChart(YStockQuote currentStock) throws ParseException {

    DateAxis domainAxis = new DateAxis("Date");
    NumberAxis rangeAxis = new NumberAxis("Price");
    CandlestickRenderer renderer = new CandlestickRenderer();
    XYDataset dataset = getDataSet(currentStock);

    XYPlot mainPlot = new XYPlot(dataset, domainAxis, rangeAxis, renderer);

    //Do some setting up, see the API Doc
    renderer.setSeriesPaint(0, Color.BLACK);
    renderer.setDrawVolume(false);// w  w  w  . j  ava  2  s . c o  m
    rangeAxis.setAutoRangeIncludesZero(false);

    domainAxis.setDateFormatOverride(new SimpleDateFormat("dd-MM-yy"));
    domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);

    //Now create the chart and chart panel
    JFreeChart chart = new JFreeChart(currentStock.get_name(), null, mainPlot, false);
    chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(600, 300));

    XYPlot plot = (XYPlot) chart.getPlot();
    LegendTitle legend = new LegendTitle(plot);
    chart.addLegend(legend);
    chart.getLegend().setVisible(true);
    chart.getLegend().setPosition(RectangleEdge.BOTTOM);
    ValueAxis yAxis = (ValueAxis) plot.getRangeAxis();
    DateAxis xAxis = (DateAxis) plot.getDomainAxis();
    Date now = new Date();
    SegmentedTimeline segmentedTimeline = SegmentedTimeline.newMondayThroughFridayTimeline();
    Calendar[][] holidays = DayRange.getHolidayDates();
    int len = holidays.length;

    for (int i = 0; i < holidays[0].length; i++) {
        Calendar day = Calendar.getInstance(TimeZone.getTimeZone("EST"));
        day.set(Calendar.YEAR, holidays[0][i].get(Calendar.YEAR));
        day.set(Calendar.MONTH, holidays[0][i].get(Calendar.MONTH));
        day.set(Calendar.DAY_OF_MONTH, holidays[0][i].get(Calendar.DAY_OF_MONTH));
        day.set(Calendar.HOUR_OF_DAY, 9);
        segmentedTimeline.addException(day.getTime());

    }

    xAxis.setTimeline(segmentedTimeline);
    //xAxis.setVerticalTickLabels(true);
    xAxis.setDateFormatOverride(new SimpleDateFormat("MMM y"));
    xAxis.setAutoTickUnitSelection(true);
    xAxis.setAutoRange(true);
    renderer.setAutoWidthFactor(0.5);
    renderer.setUpPaint(Color.green);
    renderer.setDownPaint(new Color(0xc0, 0x00, 0x00));
    renderer.setSeriesPaint(0, Color.black);

    StandardXYItemRenderer renderer1 = new StandardXYItemRenderer();
    renderer1.setSeriesPaint(0, Color.BLUE);
    TimeSeries movingAverage30 = MovingAverage.createMovingAverage(close, "MA(30)", 30, 0);
    Double currMA30 = (Double) movingAverage30.getDataItem(movingAverage30.getItemCount() - 1).getValue();
    currMA30 = Math.round(currMA30 * 100.0) / 100.0;
    movingAverage30.setKey("MA(30): " + currMA30);
    TimeSeriesCollection collection = new TimeSeriesCollection();
    collection.addSeries(movingAverage30);
    plot.setDataset(1, collection);
    plot.setRenderer(1, renderer1);

    chartPanel.revalidate();
    chartPanel.repaint();
    chartPanel.revalidate();
    chartPanel.repaint();
}

From source file:peakmlviewer.dialog.PCADialog.java

public PCADialog(MainWnd mainwnd, Shell parent, String title) {
    super(parent, SWT.NONE);

    // save the parent pointer
    this.title = title;
    this.parent = parent;

    this.mainwnd = mainwnd;

    // create the window and set its properties
    shell = new Shell(parent, SWT.EMBEDDED | SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
    shell.setSize(500, 300);/*from w w w .j  a  v  a 2  s  . c  o  m*/
    shell.setText(title);

    // create the jfreechart
    plot = new XYPlot(collection, new NumberAxis("principal component 1"),
            new NumberAxis("principal component 2"), new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES));
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinesVisible(true);
    plot.getRenderer().setBaseItemLabelsVisible(true);
    plot.getRenderer().setBaseItemLabelGenerator(new XYItemLabelGenerator() {
        public String generateLabel(XYDataset dataset, int series, int item) {
            return labels[item];
        }
    });

    chart = new JFreeChart("Principle Component Analysis", plot);
    chart.removeLegend();
    chart.setBackgroundPaint(Color.WHITE);
    chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    // add the components
    // --------------------------------------------------------------------------------
    // This uses the SWT-trick for embedding awt-controls in an SWT-Composit.
    try {
        System.setProperty("sun.awt.noerasebackground", "true");
    } catch (NoSuchMethodError error) {
        ;
    }

    java.awt.Frame frame = org.eclipse.swt.awt.SWT_AWT.new_Frame(shell);

    // create a new ChartPanel, without the popup-menu (5x false)
    frame.add(new ChartPanel(chart, false, false, false, false, false));
    // --------------------------------------------------------------------------------
}

From source file:com.charts.SixMonthChart.java

public SixMonthChart(YStockQuote currentStock) throws ParseException {

    DateAxis domainAxis = new DateAxis("Date");
    NumberAxis rangeAxis = new NumberAxis("Price");
    CandlestickRenderer renderer = new CandlestickRenderer();
    XYDataset dataset = getDataSet(currentStock);

    XYPlot mainPlot = new XYPlot(dataset, domainAxis, rangeAxis, renderer);

    //Do some setting up, see the API Doc
    renderer.setSeriesPaint(0, Color.BLACK);
    renderer.setDrawVolume(false);//  w  w w  .  j a  v  a 2 s.c o m
    rangeAxis.setAutoRangeIncludesZero(false);

    domainAxis.setDateFormatOverride(new SimpleDateFormat("dd-MM-yy"));
    domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);

    //Now create the chart and chart panel
    JFreeChart chart = new JFreeChart(currentStock.get_name(), null, mainPlot, false);
    chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(600, 300));

    XYPlot plot = (XYPlot) chart.getPlot();

    LegendTitle legend = new LegendTitle(plot);

    chart.addLegend(legend);
    chart.getLegend().setVisible(true);
    chart.getLegend().setPosition(RectangleEdge.BOTTOM);

    ValueAxis yAxis = (ValueAxis) plot.getRangeAxis();
    DateAxis xAxis = (DateAxis) plot.getDomainAxis();
    Date now = new Date();
    SegmentedTimeline segmentedTimeline = SegmentedTimeline.newMondayThroughFridayTimeline();
    Calendar[][] holidays = DayRange.getHolidayDates();
    int len = holidays.length;

    for (int i = 0; i < holidays[0].length; i++) {
        Calendar day = Calendar.getInstance(TimeZone.getTimeZone("EST"));
        day.set(Calendar.YEAR, holidays[0][i].get(Calendar.YEAR));
        day.set(Calendar.MONTH, holidays[0][i].get(Calendar.MONTH));
        day.set(Calendar.DAY_OF_MONTH, holidays[0][i].get(Calendar.DAY_OF_MONTH));
        day.set(Calendar.HOUR_OF_DAY, 9);
        segmentedTimeline.addException(day.getTime());

    }

    xAxis.setTimeline(segmentedTimeline);
    //xAxis.setVerticalTickLabels(true);
    xAxis.setDateFormatOverride(new SimpleDateFormat("MMM y"));
    xAxis.setAutoTickUnitSelection(true);
    xAxis.setAutoRange(true);
    renderer.setAutoWidthFactor(0.5);
    renderer.setUpPaint(Color.green);
    renderer.setDownPaint(new Color(0xc0, 0x00, 0x00));
    renderer.setSeriesPaint(0, Color.black);

    StandardXYItemRenderer renderer1 = new StandardXYItemRenderer();
    renderer1.setSeriesPaint(0, Color.BLUE);
    TimeSeries movingAverage30 = MovingAverage.createMovingAverage(close, "MA(30)", 30, 0);
    Double currMA30 = (Double) movingAverage30.getDataItem(movingAverage30.getItemCount() - 1).getValue();
    currMA30 = Math.round(currMA30 * 100.0) / 100.0;
    movingAverage30.setKey("MA(30): " + currMA30);
    TimeSeriesCollection collection = new TimeSeriesCollection();
    collection.addSeries(movingAverage30);
    plot.setDataset(1, collection);
    plot.setRenderer(1, renderer1);

    chartPanel.revalidate();
    chartPanel.repaint();
    chartPanel.revalidate();
    chartPanel.repaint();
}

From source file:com.charts.TenYearChart.java

public TenYearChart(YStockQuote currentStock) throws ParseException {
    DateAxis domainAxis = new DateAxis("Date");
    NumberAxis rangeAxis = new NumberAxis("Price");
    CandlestickRenderer renderer = new CandlestickRenderer();
    XYDataset dataset = getDataSet(currentStock);

    XYPlot mainPlot = new XYPlot(dataset, domainAxis, rangeAxis, renderer);

    //Do some setting up, see the API Doc
    renderer.setBaseToolTipGenerator(//from  w ww .j  a  va  2  s .c o  m
            new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
                    new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00")));

    renderer.setDrawVolume(false);
    rangeAxis.setAutoRangeIncludesZero(false);

    domainAxis.setDateFormatOverride(new SimpleDateFormat("dd-MM-yy"));
    domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);

    //Now create the chart and chart panel
    JFreeChart chart = new JFreeChart(currentStock.get_name(), null, mainPlot, false);

    chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(900, 400));

    XYPlot plot = (XYPlot) chart.getPlot();
    LegendTitle legend = new LegendTitle(plot);
    chart.addLegend(legend);
    chart.getLegend().setVisible(true);
    chart.getLegend().setPosition(RectangleEdge.BOTTOM);

    ValueAxis yAxis = (ValueAxis) plot.getRangeAxis();
    DateAxis xAxis = (DateAxis) plot.getDomainAxis();

    xAxis.setDateFormatOverride(new SimpleDateFormat("MMM y"));
    xAxis.setAutoTickUnitSelection(true);
    xAxis.setAutoRange(true);
    renderer.setAutoWidthFactor(0.5);
    renderer.setUpPaint(Color.green);
    renderer.setDownPaint(new Color(0xc0, 0x00, 0x00));
    renderer.setSeriesPaint(0, Color.BLACK);
    StandardXYItemRenderer renderer1 = new StandardXYItemRenderer();
    renderer1.setSeriesPaint(0, Color.BLUE);
    TimeSeries movingAverage30 = MovingAverage.createMovingAverage(close, "MA(30)", 30, 0);
    Double currMA30 = (Double) movingAverage30.getDataItem(movingAverage30.getItemCount() - 1).getValue();
    currMA30 = Math.round(currMA30 * 100.0) / 100.0;
    movingAverage30.setKey("MA(30): " + currMA30);
    TimeSeriesCollection collection = new TimeSeriesCollection();
    collection.addSeries(movingAverage30);
    plot.setDataset(1, collection);
    plot.setRenderer(1, renderer1);

    chartPanel.revalidate();
    chartPanel.repaint();
    chartPanel.revalidate();
    chartPanel.repaint();
}

From source file:electroStaticUI.DrawElectricFieldLines.java

public DrawElectricFieldLines(CustomMapper cMapper) {
    mapper = cMapper;/*from  w  ww. j  a  va2s.c  o m*/
    sumTotalVector();
    createDataset();
    renderer = new VectorRenderer();
    graph = new XYPlot(dataSet, new NumberAxis("Axis X"), new NumberAxis("Axis Y"), renderer);
    eFieldChart = new JFreeChart(graph);
    eFieldChart.setTitle("Electric Field Vectors");
    graphChart = new ChartPanel(eFieldChart);
    graphChart.setVisible(true);
}

From source file:org.spf4j.perf.impl.chart.Charts.java

public static JFreeChart createHeatJFreeChart(final String[] dsNames, final double[][] values,
        final long startTimeMillis, final long stepMillis, final String uom, final String chartName) {
    final QuantizedXYZDatasetImpl dataSet = new QuantizedXYZDatasetImpl(dsNames, values, startTimeMillis,
            stepMillis);/*from   w  ww . j a v  a2  s. c  om*/
    NumberAxis xAxis = new NumberAxis("Time");
    xAxis.setStandardTickUnits(dataSet.createXTickUnits());
    xAxis.setLowerMargin(0);
    xAxis.setUpperMargin(0);
    xAxis.setVerticalTickLabels(true);
    NumberAxis yAxis = new NumberAxis(uom);
    yAxis.setStandardTickUnits(dataSet.createYTickUnits());
    yAxis.setLowerMargin(0);
    yAxis.setUpperMargin(0);
    XYBlockRenderer renderer = new XYBlockRenderer();
    PaintScale scale;
    if (dataSet.getMinValue() >= dataSet.getMaxValue()) {
        if (dataSet.getMinValue() == Double.POSITIVE_INFINITY) {
            scale = new InverseGrayScale(0, 1);
        } else {
            scale = new InverseGrayScale(dataSet.getMinValue(), dataSet.getMaxValue() + 1);
        }
    } else {
        scale = new InverseGrayScale(dataSet.getMinValue(), dataSet.getMaxValue());
    }
    renderer.setPaintScale(scale);
    renderer.setBlockWidth(1);
    renderer.setBlockHeight(1);
    XYPlot plot = new XYPlot(dataSet, xAxis, yAxis, renderer);
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    plot.setRangeMinorGridlinesVisible(false);
    JFreeChart chart = new JFreeChart(chartName, plot);
    PaintScaleLegend legend = new PaintScaleLegend(scale, new NumberAxis("Count"));
    legend.setMargin(0, 5, 0, 5);
    chart.addSubtitle(legend);
    chart.removeLegend();
    chart.setBackgroundPaint(Color.white);
    return chart;
}

From source file:lu.lippmann.cdb.common.gui.ts.TimeSeriesChartUtil.java

public static ChartPanel buildChartPanelForNominalAttribute(final Instances ds, final Attribute attr,
        final int dateIdx) {
    final TaskSeriesCollection localTaskSeriesCollection = new TaskSeriesCollection();
    final java.util.List<String> names = new ArrayList<String>();

    final Set<String> present = WekaDataStatsUtil.getPresentValuesForNominalAttribute(ds, attr.index());
    for (final String pr : present) {
        names.add(pr);/*from   www .ja v  a 2 s  .  c o  m*/
        localTaskSeriesCollection.add(new TaskSeries(pr));
    }

    final Calendar cal = Calendar.getInstance();
    try {
        for (final double[] dd : WekaTimeSeriesUtil.split(ds, attr.index())) {
            cal.setTimeInMillis((long) dd[0]);
            final Date start = cal.getTime();
            cal.setTimeInMillis((long) dd[1]);
            final Date end = cal.getTime();
            final String sd = ds.instance((int) dd[2]).stringValue(attr);
            localTaskSeriesCollection.getSeries(sd).add(new Task("T", start, end));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    final XYTaskDataset localXYTaskDataset = new XYTaskDataset(localTaskSeriesCollection);
    localXYTaskDataset.setTransposed(true);
    localXYTaskDataset.setSeriesWidth(0.6D);

    final DateAxis localDateAxis = new DateAxis(DATE_TIME_LABEL);
    final SymbolAxis localSymbolAxis = new SymbolAxis("", names.toArray(new String[names.size()]));
    localSymbolAxis.setGridBandsVisible(false);
    final XYBarRenderer localXYBarRenderer = new XYBarRenderer();
    localXYBarRenderer.setUseYInterval(true);
    localXYBarRenderer.setShadowVisible(false);
    final XYPlot localXYPlot = new XYPlot(localXYTaskDataset, localDateAxis, localSymbolAxis,
            localXYBarRenderer);

    final CombinedDomainXYPlot localCombinedDomainXYPlot = new CombinedDomainXYPlot(
            new DateAxis(DATE_TIME_LABEL));
    localCombinedDomainXYPlot.add(localXYPlot);
    final JFreeChart localJFreeChart = new JFreeChart("", localCombinedDomainXYPlot);
    localJFreeChart.setBackgroundPaint(Color.white);

    final ChartPanel cp = new ChartPanel(localJFreeChart, true);
    cp.setBorder(new TitledBorder(attr.name()));
    return cp;
}

From source file:scheduler.benchmarker.manager.CreateSimpleSplineChart.java

public ChartPanel createChartPanel() {
    XYDataset dataset = createDataset();
    NumberAxis numberaxis = new NumberAxis("EMAILS");
    numberaxis.setAutoRangeIncludesZero(true);
    numberaxis.setRange(0, dataset.getItemCount(1));
    numberaxis.setVisible(false);/* w  w w  .j  av  a 2 s.c  o  m*/
    NumberAxis numberaxis1 = new NumberAxis("TIME CONSUMED");
    numberaxis1.setAutoRangeIncludesZero(false);
    XYSplineRenderer xysplinerenderer = new XYSplineRenderer();
    XYPlot xyplot = new XYPlot(dataset, numberaxis, numberaxis1, xysplinerenderer);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    //xyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D));
    JFreeChart jfreechart = new JFreeChart("PLAN VALUES FOR '" + sName + "' SCHEDULER",
            new Font(Font.SANS_SERIF, Font.PLAIN, 11), xyplot, true);
    chartPanel = new ChartPanel(jfreechart, true);

    //Creating listener
    chartPanel.addChartMouseListener(new ChartMouseListener() {
        @Override
        public void chartMouseClicked(ChartMouseEvent e) {
            ChartEntity entity = e.getEntity();
            if (entity != null && (entity instanceof XYItemEntity)) {
                XYItemEntity item = (XYItemEntity) entity;
                String chartTitle = "RULE ARRANGEMENT INFORMATION FOR EMAIL \""
                        + dataSource.get(item.getItem()).getEmailName() + "\"";
                createSubChart(
                        new CreateStackedBarChart3D(dataSource.get(item.getItem()), pluginColor, chartTitle)
                                .createChartPanel());
            }
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent e) {
            //DO NOTHING
        }

    });
    return chartPanel;
}