Example usage for org.jfree.chart ChartPanel setRangeZoomable

List of usage examples for org.jfree.chart ChartPanel setRangeZoomable

Introduction

In this page you can find the example usage for org.jfree.chart ChartPanel setRangeZoomable.

Prototype

public void setRangeZoomable(boolean flag) 

Source Link

Document

A flag that controls mouse-based zooming on the vertical axis.

Usage

From source file:com.att.aro.ui.view.overviewtab.FileTypesChartPanel.java

/**
 * /*from w  w  w  .ja  v a  2s . c om*/
 * @return
 */
public JPanel layoutDataPanel() {

    setLayout(new BorderLayout());

    JFreeChart chart = initializeChart();

    ChartPanel chartPanel = new ChartPanel(chart, WIDTH, HEIGHT, 400, ChartPanel.DEFAULT_MINIMUM_DRAW_HEIGHT,
            ChartPanel.DEFAULT_MAXIMUM_DRAW_WIDTH, ChartPanel.DEFAULT_MAXIMUM_DRAW_HEIGHT, USER_BUFFER,
            PROPERTIES, COPY, SAVE, PRINT, ZOOM, TOOL_TIPS);

    chartPanel.setDomainZoomable(false);
    chartPanel.setRangeZoomable(false);
    add(chartPanel, BorderLayout.CENTER);

    return this;
}

From source file:com.att.aro.ui.view.overviewtab.TraceBenchmarkChartPanel.java

/**
 * //  w  w  w .j a  va2 s .  co  m
 * @return
 */
public JPanel layoutDataPanel() {
    setLayout(new BorderLayout());

    JFreeChart chart = initializeChart();

    ChartPanel chartPanel = new ChartPanel(chart, WIDTH, HEIGHT, ChartPanel.DEFAULT_MINIMUM_DRAW_WIDTH + 100,
            100, ChartPanel.DEFAULT_MAXIMUM_DRAW_WIDTH, ChartPanel.DEFAULT_MAXIMUM_DRAW_HEIGHT, USER_BUFFER,
            PROPERTIES, COPY, SAVE, PRINT, ZOOM, TOOL_TIPS);
    chartPanel.setDomainZoomable(false);
    chartPanel.setRangeZoomable(false);
    add(chartPanel, BorderLayout.CENTER);

    return this;
}

From source file:com.att.aro.ui.view.overviewtab.ConnectionStatisticsChartPanel.java

public JPanel layoutDataPanel() {
    setLayout(new BorderLayout());

    JFreeChart chart = initializeChart();

    ChartPanel chartPanel = new ChartPanel(chart, WIDTH, HEIGHT, ChartPanel.DEFAULT_MINIMUM_DRAW_WIDTH + 100,
            100, ChartPanel.DEFAULT_MAXIMUM_DRAW_WIDTH, ChartPanel.DEFAULT_MAXIMUM_DRAW_HEIGHT, USER_BUFFER,
            PROPERTIES, COPY, SAVE, PRINT, ZOOM, TOOL_TIPS);

    chartPanel.setDomainZoomable(false);
    chartPanel.setRangeZoomable(false);
    add(chartPanel, BorderLayout.CENTER);

    return this;
}

From source file:com.att.aro.main.ProperSessionTerminationPanel.java

/**
 * Initializes the Panel for Proper Session Termination plot.
 *///  www .  ja  v  a  2 s  .co  m
private void initialize() {
    JFreeChart chart = ChartFactory.createBarChart(rb.getString("overview.sessionoverview.title"), null, null,
            createDataset(null), PlotOrientation.HORIZONTAL, false, false, false);
    chart.setBackgroundPaint(this.getBackground());
    chart.getTitle().setFont(AROUIManager.HEADER_FONT);

    this.plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.gray);
    plot.setRangeGridlinePaint(Color.gray);
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setMaximumCategoryLabelWidthRatio(1.0f);
    domainAxis.setMaximumCategoryLabelLines(2);
    domainAxis.setLabelFont(AROUIManager.LABEL_FONT);
    domainAxis.setTickLabelFont(AROUIManager.LABEL_FONT);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setLabel(rb.getString("analysisresults.percentage"));
    rangeAxis.setRange(0.0, 100.0);
    rangeAxis.setTickUnit(new NumberTickUnit(10));
    rangeAxis.setLabelFont(AROUIManager.LABEL_FONT);
    rangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT);

    BarRenderer renderer = new StackedBarRenderer();
    renderer.setBasePaint(AROUIManager.CHART_BAR_COLOR);
    renderer.setAutoPopulateSeriesPaint(false);
    renderer.setBaseItemLabelGenerator(new PercentLabelGenerator());
    renderer.setBaseItemLabelsVisible(true);
    renderer.setBaseItemLabelPaint(Color.black);

    // Make second bar in stack invisible
    renderer.setSeriesItemLabelsVisible(1, false);
    renderer.setSeriesPaint(1, new Color(0, 0, 0, 0));

    ItemLabelPosition insideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE3,
            TextAnchor.CENTER_RIGHT);
    renderer.setBasePositiveItemLabelPosition(insideItemlabelposition);

    ItemLabelPosition outsideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3,
            TextAnchor.CENTER_LEFT);
    renderer.setPositiveItemLabelPositionFallback(outsideItemlabelposition);

    renderer.setBarPainter(new StandardBarPainter());
    renderer.setShadowVisible(false);
    renderer.setMaximumBarWidth(BAR_WIDTH_PERCENT);

    renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() {
        @Override
        public String generateToolTip(CategoryDataset arg0, int arg1, int arg2) {
            String sessionInfo = "";
            switch (arg2) {
            case SESSION_TERMINATION:
                sessionInfo = rb.getString("tooltip.sessionTermination");
                break;
            case SESSION_TIGHT_CONN:
                sessionInfo = rb.getString("tooltip.sessionTightConn");
                break;
            case SESSION_BURST:
                sessionInfo = rb.getString("tooltip.sessionBurst");
                break;
            case SESSION_LONG_BURST:
                sessionInfo = rb.getString("tooltip.sessionLongBurst");
                break;
            }

            return sessionInfo;
        }
    });

    plot.setRenderer(renderer);
    plot.getDomainAxis().setMaximumCategoryLabelLines(2);

    ChartPanel chartPanel = new ChartPanel(chart, WIDTH, HEIGHT, ChartPanel.DEFAULT_MINIMUM_DRAW_WIDTH + 100,
            100, ChartPanel.DEFAULT_MAXIMUM_DRAW_WIDTH, ChartPanel.DEFAULT_MAXIMUM_DRAW_HEIGHT, USER_BUFFER,
            PROPERTIES, COPY, SAVE, PRINT, ZOOM, TOOL_TIPS);

    chartPanel.setDomainZoomable(false);
    chartPanel.setRangeZoomable(false);
    this.add(chartPanel, BorderLayout.CENTER);
}

From source file:com.att.aro.main.TraceOverviewPanel.java

/**
 * Initializes the Main panel and its various components.
 *//*www  . ja va 2s.c om*/
private void initialize() {
    JFreeChart chart = ChartFactory.createBarChart(rb.getString("overview.traceoverview.title"), null, null,
            createDataset(null), PlotOrientation.HORIZONTAL, false, true, false);
    chart.setBackgroundPaint(this.getBackground());
    chart.getTitle().setFont(AROUIManager.HEADER_FONT);

    this.plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.gray);
    plot.setRangeGridlinePaint(Color.gray);
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);

    CategoryAxis valueRangeAxis = plot.getDomainAxis();
    valueRangeAxis.setMaximumCategoryLabelWidthRatio(1.0f);
    valueRangeAxis.setMaximumCategoryLabelLines(2);
    valueRangeAxis.setLabelFont(AROUIManager.LABEL_FONT);
    valueRangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setLabel(rb.getString("analysisresults.percentile"));
    rangeAxis.setRange(0.0, 100.0);
    rangeAxis.setTickUnit(new NumberTickUnit(10));
    rangeAxis.setLabelFont(AROUIManager.LABEL_FONT);
    rangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT);

    BarRenderer renderer = new StackedBarRenderer();
    renderer.setBasePaint(AROUIManager.CHART_BAR_COLOR);
    renderer.setAutoPopulateSeriesPaint(false);
    renderer.setBaseItemLabelGenerator(new PercentLabelGenerator());
    renderer.setBaseItemLabelsVisible(true);
    renderer.setBaseItemLabelPaint(Color.black);

    // Make second bar in stack invisible
    renderer.setSeriesItemLabelsVisible(1, false);
    renderer.setSeriesPaint(1, new Color(0, 0, 0, 0));

    ItemLabelPosition insideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE3,
            TextAnchor.CENTER_RIGHT);
    renderer.setBasePositiveItemLabelPosition(insideItemlabelposition);

    ItemLabelPosition outsideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3,
            TextAnchor.CENTER_LEFT);
    renderer.setPositiveItemLabelPositionFallback(outsideItemlabelposition);

    renderer.setBarPainter(new StandardBarPainter());
    renderer.setShadowVisible(false);
    renderer.setMaximumBarWidth(BAR_WIDTH_PERCENT);
    renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() {
        @Override
        public String generateToolTip(CategoryDataset arg0, int arg1, int arg2) {
            String traceInfo = "";
            switch (arg2) {
            case TRACE_AVERAGE:
                traceInfo = rb.getString("tooltip.traceAnalysis.avg");
                break;
            case TRACE_ENERGY:
                traceInfo = rb.getString("tooltip.traceAnalysis.engy");
                break;
            case TRACE_OVERHEAD:
                traceInfo = rb.getString("tooltip.traceAnalysis.ovrhd");
                break;
            }

            return traceInfo;
        }
    });

    plot.setRenderer(renderer);
    plot.getDomainAxis().setMaximumCategoryLabelLines(2);

    ChartPanel chartPanel = new ChartPanel(chart, WIDTH, HEIGHT, ChartPanel.DEFAULT_MINIMUM_DRAW_WIDTH + 100,
            100, ChartPanel.DEFAULT_MAXIMUM_DRAW_WIDTH, ChartPanel.DEFAULT_MAXIMUM_DRAW_HEIGHT, USER_BUFFER,
            PROPERTIES, COPY, SAVE, PRINT, ZOOM, TOOL_TIPS);
    chartPanel.setDomainZoomable(false);
    chartPanel.setRangeZoomable(false);
    this.add(chartPanel, BorderLayout.CENTER);
}

From source file:loci.slim.ui.ExcitationGraph.java

/**
 * Creates a JFreeChart graph showing the excitation or instrument response
 * decay curve.//from   w  ww .  j a  va 2 s .co  m
 *
 * @param start time value
 * @param stop time value
 * @param base value
 * @param bins number of bins
 * @param timeInc time increment per bin
 */
ExcitationGraph(final double start, final double stop, final double base, final int bins, final double[] values,
        final double timeInc) {
    _start = start;
    _stop = stop;
    _base = base;
    _bins = bins;

    // compute maximum values for width and height
    _maxHorzValue = timeInc * bins;
    _maxVertValue = 0.0f;
    for (final double value : values) {
        if (value > _maxVertValue) {
            _maxVertValue = value;
        }
    }

    // create the chart
    final JFreeChart chart = createChart(bins, timeInc, values);
    final ChartPanel chartPanel = new ChartPanel(chart, true, true, true, false, true);
    chartPanel.setDomainZoomable(false);
    chartPanel.setRangeZoomable(false);
    chartPanel.setPreferredSize(SIZE);

    // Add JXLayer to draw/drag start/stop bars
    _layer = new JXLayer<JComponent>(chartPanel);
    _startStopBaseDraggingUI = new StartStopBaseDraggingUI<JComponent>(chartPanel, _excitationPlot, this,
            _maxHorzValue, _maxVertValue);
    _layer.setUI(_startStopBaseDraggingUI);

    // IJ.log("ExcitationGraph start " + start + " stop " + stop + " base " +
    // base);
    // initialize the vertical bars that show start and stop time bins and
    // the horizontal bar with the base count.
    _startStopBaseDraggingUI.setStartStopBaseValues(_start, _stop, _base);
}

From source file:loci.slim2.process.interactive.ui.DefaultExcitationGraph.java

/**
 * Creates a JFreeChart graph showing the excitation or instrument response
 * decay curve.//from w w w .  jav a  2s. co m
 *
 * @param start time value
 * @param stop time value
 * @param base value
 * @param bins number of bins
 * @param timeInc time increment per bin
 */
DefaultExcitationGraph(final double start, final double stop, final double base, final int bins,
        final double[] values, final double timeInc) {
    this.start = start;
    this.stop = stop;
    this.base = base;
    this.bins = bins;

    // compute maximum values for width and height
    maxHorzValue = timeInc * bins;
    maxVertValue = 0.0f;
    for (final double value : values) {
        if (value > maxVertValue) {
            maxVertValue = value;
        }
    }

    // create the chart
    final JFreeChart chart = createChart(bins, timeInc, values);
    final ChartPanel chartPanel = new ChartPanel(chart, true, true, true, false, true);
    chartPanel.setDomainZoomable(false);
    chartPanel.setRangeZoomable(false);
    chartPanel.setPreferredSize(SIZE);

    // Add JXLayer to draw/drag start/stop bars
    layer = new JXLayer<JComponent>(chartPanel);
    startStopBaseDraggingUI = new StartStopBaseDraggingUI<JComponent>(chartPanel, excitationPlot, this,
            maxHorzValue, maxVertValue);
    layer.setUI(startStopBaseDraggingUI);

    // initialize the vertical bars that show start and stop time bins and
    // the horizontal bar with the base count.
    startStopBaseDraggingUI.setStartStopBaseValues(start, stop, base);
}

From source file:desmoj.extensions.grafic.util.Plotter.java

/**
  * Build a JPanel with plotType of a DesmoJ time-series dataset.
 * When allowMultipleValues is set, multiple range values of a time value are allowed.
 * In the opposite Case only the last range value of a time value is accepted.
 * In the case ts.getShowTimeSpansInReport() the data values are interpreted as
 * a timespan in a appropriate time unit. 
  * @param ts               DesmoJ time-series dataset
  * @param plotType          possible Values: 
  *                         Plotter.TimeSeries_ScatterPlot, 
  *                         Plotter.TimeSeries_StepChart
  *                         Plotter.TimeSeries_LinePlot
 * @param allowMultipleValues/*from w  ww  .  j av a  2s .  c o  m*/
 * @return
 */
private JPanel getTimeSeriesPanel(TimeSeries ts, int plotType, boolean allowMultipleValues) {
    JFreeChart chart;
    TimeSeriesDataSetAdapter dataset = new TimeSeriesDataSetAdapter(ts, allowMultipleValues);
    switch (plotType) {
    case Plotter.TimeSeries_LineChart:
        chart = ChartFactory.createXYLineChart(ts.getName(), "Time", "Observation", dataset,
                PlotOrientation.VERTICAL, false, false, false);
        break;
    case Plotter.TimeSeries_ScatterPlot:
        chart = ChartFactory.createScatterPlot(ts.getName(), "Time", "Observation", dataset,
                PlotOrientation.VERTICAL, false, false, false);
        break;
    case Plotter.TimeSeries_StepChart:
        chart = ChartFactory.createXYStepChart(ts.getName(), "Time", "Observation", dataset,
                PlotOrientation.VERTICAL, false, false, false);
        break;
    default:
        chart = ChartFactory.createScatterPlot(ts.getName(), "Time", "Observation", dataset,
                PlotOrientation.VERTICAL, false, false, false);
        break;
    }
    if (ts.getDescription() != null)
        chart.setTitle(ts.getDescription());

    XYPlot xyplot = (XYPlot) chart.getPlot();
    xyplot.setNoDataMessage("NO DATA");
    if (ts.getShowTimeSpansInReport() && !dataset.isValid())
        xyplot.setNoDataMessage("NO VALID TIMESPANS");
    xyplot.setDomainZeroBaselineVisible(false);
    xyplot.setRangeZeroBaselineVisible(false);

    DateAxis dateAxis = new DateAxis();
    xyplot.setDomainAxis(dateAxis);
    this.configureDomainAxis(dateAxis);

    String numberLabel;
    if (!dataset.isValid())
        numberLabel = "Unit: invalid";
    else if (ts.getShowTimeSpansInReport())
        numberLabel = "Unit: timespan [" + dataset.getRangeTimeUnit().name() + "]";
    else if (ts.getUnit() != null)
        numberLabel = "Unit: [" + ts.getUnit() + "]";
    else
        numberLabel = "Unit: unknown";
    NumberAxis numberAxis = new NumberAxis();
    xyplot.setRangeAxis(numberAxis);
    this.configureRangeAxis(numberAxis, numberLabel);

    XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    xylineandshaperenderer.setSeriesOutlinePaint(0, Color.black);
    xylineandshaperenderer.setUseOutlinePaint(true);

    ChartPanel panel = new ChartPanel(chart);
    panel.setVerticalAxisTrace(false);
    panel.setHorizontalAxisTrace(false);
    panel.setPopupMenu(null);
    panel.setDomainZoomable(false);
    panel.setRangeZoomable(false);

    return panel;
}

From source file:loci.slim2.process.interactive.ui.DefaultDecayGraph.java

@Override
public JFrame init(final JFrame parentFrame, final int bins, final double timeInc,
        final PixelPicker pixelPicker) {
    if (null == frame || !frame.isVisible() || this.bins != bins || this.timeInc != timeInc) {
        // save incoming parameters
        this.bins = bins;
        this.timeInc = timeInc;
        maxValue = timeInc * bins;//from   w w  w  . ja  va  2 s  .  c om
        this.picker = pixelPicker;

        if (null != frame) {
            // delete existing frame
            frame.setVisible(false);
            frame.dispose();
        }

        // create the combined chart
        final JFreeChart chart = createCombinedChart(bins, timeInc);
        final ChartPanel panel = new ChartPanel(chart, true, true, true, false, true);
        panel.setDomainZoomable(false);
        panel.setRangeZoomable(false);
        panel.setPreferredSize(SIZE);

        // add start/stop vertical bar handling
        dataStart = transStop = null;
        final JXLayer<JComponent> layer = new JXLayer<JComponent>(panel);
        startStopDraggingUI = new StartStopDraggingUI<JComponent>(panel, decaySubPlot, this, maxValue);
        layer.setUI(startStopDraggingUI);

        // create a frame for the chart
        frame = new JFrame();
        final Container container = frame.getContentPane();
        container.setLayout(new BorderLayout());
        container.add(layer, BorderLayout.CENTER);

        final JPanel miscPane = new JPanel();
        miscPane.setLayout(new FlowLayout());
        final JLabel label1 = new JLabel(CHI_SQUARE);
        miscPane.add(label1);
        chiSqTextField = new JTextField(7);
        chiSqTextField.setEditable(false);
        miscPane.add(chiSqTextField);
        final JLabel label2 = new JLabel(PHOTON_COUNT);
        miscPane.add(label2);
        photonTextField = new JTextField(7);
        photonTextField.setEditable(false);
        miscPane.add(photonTextField);
        logCheckBox = new JCheckBox(LOGARITHMIC);
        logCheckBox.setSelected(logarithmic);
        logCheckBox.addItemListener(new ItemListener() {

            @Override
            public void itemStateChanged(final ItemEvent e) {
                logarithmic = logCheckBox.isSelected();
                NumberAxis photonAxis;
                if (logarithmic) {
                    photonAxis = new LogarithmicAxis(PHOTON_AXIS_LABEL);
                } else {
                    photonAxis = new NumberAxis(PHOTON_AXIS_LABEL);
                }
                decaySubPlot.setRangeAxis(photonAxis);
            }
        });
        miscPane.add(logCheckBox);
        container.add(miscPane, BorderLayout.SOUTH);

        System.out.println("size from prefs " + getSizeFromPreferences());
        // _frame.setSize(getSizeFromPreferences());
        // _frame.setMaximumSize(MAX_SIZE); // doesn't work; bug in Java
        frame.pack();
        frame.setLocationRelativeTo(parentFrame);
        frame.setVisible(true);
        frame.addComponentListener(new ComponentListener() {

            @Override
            public void componentHidden(final ComponentEvent e) {

            }

            @Override
            public void componentMoved(final ComponentEvent e) {

            }

            @Override
            public void componentResized(final ComponentEvent e) {
                // constrain maximum size
                boolean resize = false;
                final Dimension size = frame.getSize();
                System.out.println("COMPONENT RESIZED incoming size " + size);
                if (size.width > MAX_SIZE.width) {
                    size.width = MAX_SIZE.width;
                    resize = true;
                }
                if (size.height > MAX_SIZE.height) {
                    size.height = MAX_SIZE.height;
                    resize = true;
                }
                if (size.width < MIN_SIZE.width) {
                    size.width = MIN_SIZE.width;
                    resize = true;
                }
                if (size.height < MIN_SIZE.height) {
                    size.height = MIN_SIZE.height;
                    resize = true;
                }
                if (resize) {
                    frame.setSize(size);
                }
                System.out.println("save resized " + resize + " size " + size);
                saveSizeInPreferences(size);
            }

            @Override
            public void componentShown(final ComponentEvent e) {

            }
        });
        this.frame.addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosing(final WindowEvent e) {
                if (null != picker) {
                    // TODO ARG does not work if you use the name 'pixelPicker'
                    // (collides with local var; this.pP won't work).
                    picker.hideCursor();
                }
            }
        });
        this.frame.setSize(getSizeFromPreferences());
    }
    return this.frame;
}

From source file:roaded.MainGUI.java

public void loadGraphInfo() {
    if (busyStatus) {
        infoBox("Please load 311 data first on the data tab.", "Message");
        return;/*from  w  w  w .j a va  2 s  .com*/
    }
    pieDataset.clear();

    // Store coordinates of each related ticket incident
    Coordinates coordinateData = new Coordinates();
    coords.clear();
    for (int i = 0; i < 12; i++) {
        int counter = 0;
        if (wardsSelected[i] == true) {
            for (TicketData entry : ticketObj.getData()) {
                if (i < 10) {
                    if (entry.getWard() != null && entry.getWard().compareTo("WARD 0" + (i + 1)) == 0) {
                        counter++;
                        coordinateData = new Coordinates();
                        coordinateData.setCoordinates(entry.getLoc_lat(), entry.getLoc_long());
                        coords.add(coordinateData);
                    }
                } else {
                    if (entry.getWard() != null && entry.getWard().compareTo("WARD 1" + (i - 9)) == 0) {
                        counter++;
                        coordinateData = new Coordinates();
                        coordinateData.setCoordinates(entry.getLoc_lat(), entry.getLoc_long());
                        coords.add(coordinateData);
                    }
                }
            }
            pieDataset.setValue("Ward " + (i + 1), counter);
            counter = 0;
        }

    }

    // Export to file so that pin mapper can retrieve it
    try {
        PrintStream out = new PrintStream(new FileOutputStream("plotData.txt"));
        for (Coordinates coord : coords) {
            out.println(coord);
        }
    } catch (FileNotFoundException ex) {
        Logger.getLogger(MainGUI.class.getName()).log(Level.SEVERE, null, ex);
    }

    // Loads the pie chart for all wards selected
    JFreeChart chart = ChartFactory.createPieChart(wardNumber, pieDataset);
    chart.removeLegend();
    PieChart.setLayout(new java.awt.BorderLayout());
    ChartPanel CP = new ChartPanel(chart);
    CP.addChartMouseListener(CML);
    CP.setPreferredSize(new Dimension(785, 440)); //size according to my window
    CP.setMouseWheelEnabled(true);
    PieChart.add(CP);

    //bargraph
    dataset.clear(); //resets bargraph when new wards are elected
    CategoryDataset dataset1 = createDataset1(); //uses dataset to create the bargraph
    JFreeChart chart1 = ChartFactory.createBarChart(
            // bargraph labels and orientation
            "Ward Incidents", "Wards", "Incidents", dataset1, PlotOrientation.VERTICAL, true, true, false);
    //bargraph settings
    DualAxis.setLayout(new java.awt.BorderLayout());
    chart1.setBackgroundPaint(Color.white);

    final CategoryPlot plot = chart1.getCategoryPlot();
    plot.setBackgroundPaint(new Color(0xEE, 0xEE, 0xFF));
    plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);

    final LineAndShapeRenderer renderer2 = new LineAndShapeRenderer();
    renderer2.setToolTipGenerator(new StandardCategoryToolTipGenerator());
    plot.setRenderer(1, renderer2);
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE);

    //bar graph chart panel creation 
    final ChartPanel chartPanel = new ChartPanel(chart1);
    chartPanel.setDomainZoomable(true);
    chartPanel.setRangeZoomable(true);
    chartPanel.setMouseZoomable(true);
    chartPanel.setMouseWheelEnabled(true);

    DualAxis.add(chartPanel);
}