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

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

Introduction

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

Prototype

public ValueAxis getRangeAxis() 

Source Link

Document

Returns the range axis for the plot.

Usage

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

/**
 * A demonstration application showing some bugs with tick labels in version 0.9.13
 *
 * @param title  the frame title.//from  w  ww  .  j  a v a  2 s  .c o m
 */
public XYTickLabelDemo(final String title) {

    super(title);
    this.chart = createChart();
    final ChartPanel chartPanel = new ChartPanel(this.chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(600, 270));

    final JPanel mainPanel = new JPanel(new BorderLayout());
    setContentPane(mainPanel);
    mainPanel.add(chartPanel);

    final JPanel optionsPanel = new JPanel();
    mainPanel.add(optionsPanel, BorderLayout.SOUTH);

    this.symbolicAxesCheckBox = new JCheckBox("Symbolic axes");
    this.symbolicAxesCheckBox.addActionListener(this);
    optionsPanel.add(this.symbolicAxesCheckBox);

    this.verticalTickLabelsCheckBox = new JCheckBox("Tick labels vertical");
    this.verticalTickLabelsCheckBox.addActionListener(this);
    optionsPanel.add(this.verticalTickLabelsCheckBox);

    this.fontSizeTextField = new JTextField(3);
    this.fontSizeTextField.addActionListener(this);
    optionsPanel.add(new JLabel("Font size:"));
    optionsPanel.add(this.fontSizeTextField);
    final ValueAxis axis = this.chart.getXYPlot().getDomainAxis();
    this.fontSizeTextField.setText(DEFAULT_FONT_SIZE + "");

    final XYPlot plot = this.chart.getXYPlot();
    Font ft = axis.getTickLabelFont();
    ft = ft.deriveFont((float) DEFAULT_FONT_SIZE);
    plot.getDomainAxis().setTickLabelFont(ft);
    plot.getRangeAxis().setTickLabelFont(ft);
    plot.getDomainAxis(1).setTickLabelFont(ft);
    plot.getRangeAxis(1).setTickLabelFont(ft);

    this.horizontalPlotCheckBox = new JCheckBox("Plot horizontal");
    this.horizontalPlotCheckBox.addActionListener(this);
    optionsPanel.add(this.horizontalPlotCheckBox);
}

From source file:com.charts.FiveYearChart.java

public FiveYearChart(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  ww. j a v a  2  s. co  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.intel.stl.ui.common.view.ComponentFactory.java

public static JFreeChart createXYBarChart(String xAxisLabel, String yAxisLabel, IntervalXYDataset dataset,
        XYItemLabelGenerator labelGenerator) {
    if (dataset == null) {
        throw new IllegalArgumentException("No dataset.");
    }//from w ww  .ja  v a  2s  .  c o  m

    JFreeChart jfreechart = ChartFactory.createXYBarChart(null, xAxisLabel, false, yAxisLabel, dataset,
            PlotOrientation.VERTICAL, false, true, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(null);
    xyplot.setOutlinePaint(null);
    xyplot.setRangeGridlinePaint(UIConstants.INTEL_DARK_GRAY);

    NumberAxis axis = (NumberAxis) xyplot.getRangeAxis();
    axis.setRangeType(RangeType.POSITIVE);
    axis.setLabelFont(UIConstants.H5_FONT);
    xyplot.getDomainAxis().setLabelFont(UIConstants.H5_FONT);
    XYBarRenderer renderer = (XYBarRenderer) xyplot.getRenderer();
    renderer.setShadowVisible(false);
    renderer.setBaseItemLabelsVisible(true);
    if (labelGenerator != null) {
        renderer.setBaseItemLabelGenerator(labelGenerator);
    }
    renderer.setBaseItemLabelFont(UIConstants.H5_FONT);
    renderer.setBarPainter(new StandardXYBarPainter());
    renderer.setSeriesPaint(0, UIConstants.INTEL_BLUE);
    return jfreechart;
}

From source file:com.charts.MaxChart.java

public MaxChart(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  .  j  ava 2 s. co  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:se.lnu.cs.doris.metrics.SLOC.java

private void generateImage(ImageType type) throws Exception {
    if (this.m_mainDir == null) {
        throw new Exception("Base directory not set.");
    }/*  w w w .  j  a va2s  .co m*/

    XYSeries linesOfCodeTotal = new XYSeries("Total lines");
    XYSeries linesOfCode = new XYSeries("Lines of code");
    XYSeries linesOfComments = new XYSeries("Lines of comments");
    XYSeries baseLine = new XYSeries("index 100");

    for (File f : this.m_mainDir.listFiles()) {
        if (f.isDirectory() && !f.getName().contains(this.m_avoid)) {

            int commitNumber = Utilities.parseInt(f.getName());
            int slocd = 0;
            int slocmt = 0;
            int sloct = 0;

            for (File sd : f.listFiles()) {
                if (!sd.getName().toLowerCase().contains(this.m_avoid)) {
                    slocd += this.countLines(sd, false);
                    slocmt += this.countLines(sd, true);
                    sloct += slocd + slocmt;
                }
            }

            if (this.m_baseValueTotal < 0) {
                this.m_baseValueTotal = sloct;
                this.m_baseValueComments = slocmt;
                this.m_baseValueCode = slocd;

                sloct = 100;
                slocmt = 100;
                slocd = 100;
            } else {
                sloct = (int) ((double) sloct / (double) this.m_baseValueTotal * 100);
                slocmt = (int) ((double) slocmt / (double) this.m_baseValueComments * 100);
                slocd = (int) ((double) slocd / (double) this.m_baseValueCode * 100);
            }

            linesOfCodeTotal.add(commitNumber, sloct);
            linesOfCode.add(commitNumber, slocd);
            linesOfComments.add(commitNumber, slocmt);
            baseLine.add(commitNumber, 100);

        }
    }

    XYSeriesCollection collection = new XYSeriesCollection();

    collection.addSeries(linesOfCodeTotal);
    collection.addSeries(linesOfCode);
    collection.addSeries(linesOfComments);
    collection.addSeries(baseLine);

    JFreeChart chart = ChartFactory.createXYLineChart(
            "Source lines of code change for " + this.m_projectName + " \nBase value code: "
                    + this.m_baseValueCode + "\nBase value comments: " + this.m_baseValueComments,
            "Commit", "SLOC change %", collection, PlotOrientation.VERTICAL, true, true, false);

    XYPlot plot = chart.getXYPlot();

    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setTickUnit(new NumberTickUnit(2));

    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setTickUnit(new NumberTickUnit(10));

    switch (type) {
    case JPEG:
        ChartUtilities.saveChartAsJPEG(new File(this.m_mainDir.getAbsolutePath(), "sloc_chart.jpg"), chart,
                1000, 720);
        break;
    case PNG:
        ChartUtilities.saveChartAsPNG(new File(this.m_mainDir.getAbsolutePath(), "sloc_chart.png"), chart, 1000,
                720);
        break;
    default:
        break;
    }
}

From source file:it.cnr.istc.iloc.gui.StateVariableVisualizer.java

@Override
public Collection<XYPlot> getPlots(Type type) {
    Collection<IItem> instances = type.getInstances();
    Collection<XYPlot> plots = new ArrayList<>(instances.size());
    Map<IItem, Collection<Atom>> sv_atoms = new IdentityHashMap<>(instances.size());
    for (IItem i : type.getInstances()) {
        sv_atoms.put(i, new ArrayList<>());
    }/* www.j av  a  2 s .  c  o m*/
    for (Atom atom : ((StateVariable) type).getDefinedPredicates().stream()
            .flatMap(p -> p.getInstances().stream()).map(a -> (Atom) a)
            .filter(a -> a.state.evaluate().isSingleton() && a.state.evaluate().contains(AtomState.Active))
            .collect(Collectors.toList())) {
        for (IItem i : ((IEnumItem) atom.get(SCOPE)).getEnumVar().evaluate().getAllowedValues()) {
            if (sv_atoms.containsKey(i)) {
                sv_atoms.get(i).add(atom);
            }
        }
    }

    for (IItem sv : instances) {
        Collection<Atom> atoms = sv_atoms.get(sv);
        // For each pulse the atoms starting at that pulse
        Map<Double, Collection<Atom>> starting_atoms = new HashMap<>(atoms.size());
        // For each pulse the atoms ending at that pulse
        Map<Double, Collection<Atom>> ending_atoms = new HashMap<>(atoms.size());

        // The pulses of the timeline
        Set<Double> c_pulses = new HashSet<>(atoms.size() * 2);

        for (Atom atom : atoms) {
            double start = sv.getCore().evaluate(((IArithItem) atom.get("start")).getArithVar());
            double end = sv.getCore().evaluate(((IArithItem) atom.get("end")).getArithVar());

            if (!starting_atoms.containsKey(start)) {
                starting_atoms.put(start, new ArrayList<>());
            }
            starting_atoms.get(start).add(atom);

            if (!ending_atoms.containsKey(end)) {
                ending_atoms.put(end, new ArrayList<>());
            }
            ending_atoms.get(end).add(atom);

            c_pulses.add(start);
            c_pulses.add(end);
        }

        // we sort current pulses..
        Double[] c_pulses_array = c_pulses.toArray(new Double[c_pulses.size()]);
        Arrays.sort(c_pulses_array);

        XYIntervalSeriesCollection collection = new XYIntervalSeriesCollection();

        ValueXYIntervalSeries undefined = new ValueXYIntervalSeries("Undefined");
        ValueXYIntervalSeries sv_values = new ValueXYIntervalSeries("Values");
        ValueXYIntervalSeries conflicts = new ValueXYIntervalSeries("Conflicts");

        List<Atom> overlapping_atoms = new ArrayList<>();
        for (int i = 0; i < c_pulses_array.length - 1; i++) {
            if (starting_atoms.containsKey(c_pulses_array[i])) {
                overlapping_atoms.addAll(starting_atoms.get(c_pulses_array[i]));
            }
            if (ending_atoms.containsKey(c_pulses_array[i])) {
                overlapping_atoms.removeAll(ending_atoms.get(c_pulses_array[i]));
            }
            switch (overlapping_atoms.size()) {
            case 0:
                undefined.add(c_pulses_array[i], c_pulses_array[i], c_pulses_array[i + 1], 0, 0, 1,
                        new Atom[0]);
                break;
            case 1:
                sv_values.add(c_pulses_array[i], c_pulses_array[i], c_pulses_array[i + 1], 0, 0, 1,
                        overlapping_atoms.toArray(new Atom[overlapping_atoms.size()]));
                break;
            default:
                conflicts.add(c_pulses_array[i], c_pulses_array[i], c_pulses_array[i + 1], 0, 0, 1,
                        overlapping_atoms.toArray(new Atom[overlapping_atoms.size()]));
                break;
            }
        }

        collection.addSeries(undefined);
        collection.addSeries(sv_values);
        collection.addSeries(conflicts);

        XYBarRenderer renderer = new XYBarRenderer();
        renderer.setSeriesPaint(0, Color.lightGray);
        renderer.setSeriesPaint(1, new Color(100, 250, 100));
        renderer.setSeriesPaint(2, Color.pink);
        renderer.setBarPainter(new ReverseGradientXYBarPainter());
        renderer.setDrawBarOutline(true);
        renderer.setShadowXOffset(2);
        renderer.setShadowYOffset(2);
        renderer.setUseYInterval(true);

        renderer.setBaseItemLabelsVisible(true);
        renderer.setBaseItemLabelPaint(Color.black);
        Font font = new Font("SansSerif", Font.PLAIN, 9);
        renderer.setBaseItemLabelFont(font);
        XYItemLabelGenerator generator = (XYDataset dataset, int series,
                int item) -> toString(((ValueXYIntervalDataItem) ((XYIntervalSeriesCollection) dataset)
                        .getSeries(series).getDataItem(item)).atoms);
        ItemLabelPosition itLabPos = new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER);
        renderer.setBasePositiveItemLabelPosition(itLabPos);
        for (int i = 0; i < collection.getSeriesCount(); i++) {
            renderer.setSeriesItemLabelGenerator(i, generator);
            renderer.setSeriesItemLabelsVisible(i, true);
            renderer.setSeriesItemLabelPaint(i, Color.black);
            renderer.setSeriesItemLabelFont(i, font);
            renderer.setSeriesPositiveItemLabelPosition(i, itLabPos);
            renderer.setSeriesToolTipGenerator(i,
                    (XYDataset dataset, int series, int item) -> toString(
                            ((ValueXYIntervalDataItem) ((XYIntervalSeriesCollection) dataset).getSeries(series)
                                    .getDataItem(item)).atoms));
        }

        XYPlot plot = new XYPlot(collection, null, new NumberAxis(""), renderer);
        plot.getRangeAxis().setVisible(false);
        plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

        plots.add(plot);
    }

    return plots;
}

From source file:net.bioclipse.model.ScatterPlotMouseHandler.java

private double rangeValueTo2D(ChartPanel chartPanel, XYPlot plot, double value) {
    ChartRenderingInfo info = chartPanel.getChartRenderingInfo();
    Rectangle2D dataArea = info.getPlotInfo().getDataArea();
    Number y = plot.getRangeAxis().valueToJava2D(value, dataArea, plot.getRangeAxisEdge());

    return y.doubleValue();
}

From source file:ch.epfl.leb.sass.ijplugin.SimulatorStatusFrame.java

/** 
 * Creates a new status frame./* ww w  .j a va2s . c  o m*/
 * 
 * @param groundTruthYLabel The y-axis label for the ground truth signal.
 * @param analyzerYLabel The units output by the analyzer.
 * @param setpointYLabel The units of the controller setpoint.
 * @param outputYLabel The units output by the controller.
 */
public SimulatorStatusFrame(String groundTruthYLabel, String analyzerYLabel, String setpointYLabel,
        String outputYLabel) {
    String seriesLabel = "";
    String yLabel = "";
    CombinedDomainXYPlot combineddomainxyplot = new CombinedDomainXYPlot(new NumberAxis("Simulation Outputs"));
    Font yLabelFont = new Font("Dialog", Font.PLAIN, 10);
    datasets = new XYSeriesCollection[4];
    for (int i = 0; i < SUBPLOT_COUNT; i++) {
        switch (i) {
        case 0:
            seriesLabel = "True density";
            yLabel = groundTruthYLabel;
            break;
        case 1:
            seriesLabel = "Analyzer output";
            yLabel = analyzerYLabel;
            break;
        case 2:
            seriesLabel = "Setpoint";
            yLabel = setpointYLabel;
            break;
        case 3:
            seriesLabel = "Controller output";
            yLabel = outputYLabel;
            break;
        }

        XYSeries timeseries = new XYSeries(seriesLabel);
        datasets[i] = new XYSeriesCollection(timeseries);

        NumberAxis numberaxis = new NumberAxis(yLabel);
        numberaxis.setAutoRangeIncludesZero(false);
        numberaxis.setNumberFormatOverride(new DecimalFormat("###0.00"));
        XYPlot xyplot = new XYPlot(datasets[i], null, numberaxis, new StandardXYItemRenderer());
        xyplot.setBackgroundPaint(Color.lightGray);
        xyplot.setDomainGridlinePaint(Color.white);
        xyplot.setRangeGridlinePaint(Color.white);
        xyplot.getRangeAxis().setLabelFont(yLabelFont);
        combineddomainxyplot.add(xyplot);
    }

    JFreeChart jfreechart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, combineddomainxyplot, true);
    jfreechart.setBorderPaint(Color.black);
    jfreechart.setBorderVisible(true);
    jfreechart.setBackgroundPaint(Color.white);
    combineddomainxyplot.setBackgroundPaint(Color.lightGray);
    combineddomainxyplot.setDomainGridlinePaint(Color.white);
    combineddomainxyplot.setRangeGridlinePaint(Color.white);
    ValueAxis valueaxis = combineddomainxyplot.getDomainAxis();
    valueaxis.setAutoRange(true);
    // Number of frames to display
    valueaxis.setFixedAutoRange(2000D);

    ChartPanel chartpanel = new ChartPanel(jfreechart);

    chartpanel.setPreferredSize(new Dimension(800, 500));
    chartpanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    chartpanel.setVisible(true);

    JPanel jPanel = new JPanel();
    jPanel.setLayout(new BorderLayout());
    jPanel.add(chartpanel, BorderLayout.NORTH);

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    add(jPanel);
    pack();
    setVisible(true);

}

From source file:io.github.mzmine.modules.plots.chromatogram.ChromatogramPlotWindowController.java

public void handleZoomOut(Event e) {
    XYPlot plot = chartNode.getChart().getXYPlot();
    plot.getDomainAxis().setAutoRange(true);
    plot.getRangeAxis().setAutoRange(true);
}

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 www  .j  av a2 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();
}