Example usage for org.jfree.data.time TimeSeriesCollection addSeries

List of usage examples for org.jfree.data.time TimeSeriesCollection addSeries

Introduction

In this page you can find the example usage for org.jfree.data.time TimeSeriesCollection addSeries.

Prototype

public void addSeries(TimeSeries series) 

Source Link

Document

Adds a series to the collection and sends a DatasetChangeEvent to all registered listeners.

Usage

From source file:org.jfree.data.time.TimeSeriesCollectionTest.java

/**
 * Tests the remove series method./*from   ww w  . ja v a 2  s.c  o m*/
 */
@Test
public void testRemoveSeries() {
    TimeSeriesCollection c1 = new TimeSeriesCollection();

    TimeSeries s1 = new TimeSeries("Series 1");
    TimeSeries s2 = new TimeSeries("Series 2");
    TimeSeries s3 = new TimeSeries("Series 3");
    TimeSeries s4 = new TimeSeries("Series 4");

    c1.addSeries(s1);
    c1.addSeries(s2);
    c1.addSeries(s3);
    c1.addSeries(s4);

    c1.removeSeries(s3);

    TimeSeries s = c1.getSeries(2);
    boolean b1 = s.equals(s4);
    assertTrue(b1);
}

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

/**
 * Creates a sample dataset./*ww w . j a  va 2s.  c o m*/
 *
 * @param count  the item count.
 * 
 * @return the dataset.
 */
private XYDataset createDirectionDataset(final int count) {
    final TimeSeriesCollection dataset = new TimeSeriesCollection();
    final TimeSeries s1 = new TimeSeries("Wind Direction", Minute.class);
    RegularTimePeriod start = new Minute();
    double direction = 180.0;
    for (int i = 0; i < count; i++) {
        s1.add(start, direction);
        start = start.next();
        direction = direction + (Math.random() - 0.5) * 15.0;
        if (direction < 0.0) {
            direction = direction + 360.0;
        } else if (direction > 360.0) {
            direction = direction - 360.0;
        }
    }
    dataset.addSeries(s1);
    return dataset;
}

From source file:org.mwc.debrief.sensorfusion.views.DataSupport.java

public static void tracksFor(final TrackWrapper primary, final WatchableList[] secondaries,
        final TimeSeriesCollection newData) {
    if (secondaries != null) {
        for (int i = 0; i < secondaries.length; i++) {
            final WatchableList thisS = secondaries[i];
            final TrackSeries thisT = new TrackSeries(thisS.getName(), thisS);
            final Enumeration<Editable> priPts = primary.getPositions();
            _previousVal = Double.NaN;
            while (priPts.hasMoreElements()) {
                final FixWrapper thisP = (FixWrapper) priPts.nextElement();
                final Watchable[] nearest = thisS.getNearestTo(thisP.getDTG());
                if (nearest != null)
                    if (nearest.length > 0) {
                        final Watchable thisLoc = nearest[0];
                        final WorldVector offset = thisLoc.getLocation().subtract(thisP.getLocation());
                        final double thisVal = MWC.Algorithms.Conversions.Rads2Degs(offset.getBearing());

                        thisT.add(create(thisP.getTime(), thisVal, thisP.getColor()));
                    }/*from   ww  w. j a  v  a  2 s .  com*/
            }
            if (!thisT.isEmpty())
                newData.addSeries(thisT);
        }
    }

}

From source file:org.paxle.tools.charts.impl.gui.ChartServlet.java

private JFreeChart createMemoryChart() {
    // init time series
    TimeSeries usedmemSeries = new TimeSeries("Used MEM", Minute.class);
    usedmemSeries.setMaximumItemAge(24 * 60);
    this.seriesMap.put(TSERIES_MEMORY_USAGE, usedmemSeries);

    // init collections and chart
    final TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(usedmemSeries);

    /*//w ww  .ja  v  a  2s. co m
     * INIT CHART
     */
    JFreeChart chart = ChartFactory.createTimeSeriesChart(null, "Time", "Memory [MB]", dataset, true, false,
            false);

    // change axis data format
    ((DateAxis) chart.getXYPlot().getDomainAxis()).setDateFormatOverride(new SimpleDateFormat("HH:mm"));

    long maxMemory = Runtime.getRuntime().maxMemory();
    if (maxMemory != Long.MAX_VALUE) {
        ((NumberAxis) chart.getXYPlot().getRangeAxis()).setRange(0,
                (double) maxMemory / (double) (1024 * 1024));
    }

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

From source file:skyc.ViewContent.java

private void b2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b2ActionPerformed
    // TODO add your handling code here:

    Statement stmt = null;/*from  w  w  w  . java2  s  .  co  m*/
    Connection currentCon = null;
    boolean rs = false;
    ResultSet rs2;
    String color;
    int Orderby = jComboBox2.getSelectedIndex();
    if (Orderby == 0)
        color = "r";
    else if (Orderby == 1)
        color = "b";

    else
        color = "g";
    TimeSeries series = new TimeSeries("", Day.class);
    currentCon = ConnectionManager.getConnection();
    try {
        stmt = currentCon.createStatement();
    } catch (SQLException ex) {
        Logger.getLogger(ViewContent.class.getName()).log(Level.SEVERE, null, ex);
    }
    String SelectQuery = "Select * from pics WHERE location = '" + location + "' AND date >= '" + fromstring
            + "' AND date <= '" + tostring + "' ORDER BY '" + color + "'";
    try {
        rs2 = stmt.executeQuery(SelectQuery);
        int i = 10;
        while (rs2.next()) {
            String r = rs2.getString("r").toString();
            String g = rs2.getString("g").toString();
            String b = rs2.getString("b").toString();
            String path = rs2.getString("pic_path").toString();

            ImageIcon imgThisImg = new ImageIcon(path);

            StringTokenizer st = new StringTokenizer(r, ".");
            r = st.nextToken();
            st = new StringTokenizer(g, ".");
            g = st.nextToken();
            st = new StringTokenizer(b, ".");
            b = st.nextToken();

            series.add(new Day(new Date("2015/04/" + i)), Integer.parseInt(b));
            i++;

            //  p1.setBackground(new Color(Integer.parseInt(r),Integer.parseInt(g),Integer.parseInt(b)) );

        }

    } catch (SQLException e2) {
        System.out.println("SQL error is: " + e2);

    }

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(series);

    JFreeChart chart = ChartFactory.createTimeSeriesChart("Change of sky color", // Title
            "Day", // X-Axis label
            "Ratio", // Y-Axis label
            dataset, // Dataset
            true, // Show legend
            true, //tooltips
            false //url
    );

    saveChart(chart);

    gr h = new gr();
    h.setVisible(true);
}

From source file:ec.ui.view.RevisionSaSeriesView.java

private void addStart(TimeSeriesCollection chartSeries, String name, TsPeriod start) {
    TsData ts = history_.series(name, start);
    if (ts != null) {
        TimeSeries chartTs = new TimeSeries("");
        int pos = start.minus(ts.getStart());
        Day day = new Day(start.middle());
        chartTs.add(day, ts.get(pos));/* w w w  .j a  v  a2s .  c  o m*/
        chartSeries.addSeries(chartTs);
    }
}

From source file:org.jfree.data.time.TimeSeriesCollectionTest.java

/**
 * This method provides a check for the bounds calculated using the
 * {@link DatasetUtilities#findDomainBounds(org.jfree.data.xy.XYDataset,
 * java.util.List, boolean)} method./*from  ww w  .  j  ava  2s  .  c  o m*/
 */
@Test
public void testFindDomainBounds() {
    TimeSeriesCollection dataset = new TimeSeriesCollection();
    List visibleSeriesKeys = new java.util.ArrayList();
    Range r = DatasetUtilities.findDomainBounds(dataset, visibleSeriesKeys, true);
    assertNull(r);

    TimeSeries s1 = new TimeSeries("S1");
    dataset.addSeries(s1);
    visibleSeriesKeys.add("S1");
    r = DatasetUtilities.findDomainBounds(dataset, visibleSeriesKeys, true);
    assertNull(r);

    // store the current time zone
    TimeZone saved = TimeZone.getDefault();
    TimeZone.setDefault(TimeZone.getTimeZone("Europe/Paris"));

    s1.add(new Year(2008), 8.0);
    r = DatasetUtilities.findDomainBounds(dataset, visibleSeriesKeys, true);
    assertEquals(1199142000000.0, r.getLowerBound(), EPSILON);
    assertEquals(1230764399999.0, r.getUpperBound(), EPSILON);

    TimeSeries s2 = new TimeSeries("S2");
    dataset.addSeries(s2);
    s2.add(new Year(2009), 9.0);
    s2.add(new Year(2010), 10.0);
    r = DatasetUtilities.findDomainBounds(dataset, visibleSeriesKeys, true);
    assertEquals(1199142000000.0, r.getLowerBound(), EPSILON);
    assertEquals(1230764399999.0, r.getUpperBound(), EPSILON);

    visibleSeriesKeys.add("S2");
    r = DatasetUtilities.findDomainBounds(dataset, visibleSeriesKeys, true);
    assertEquals(1199142000000.0, r.getLowerBound(), EPSILON);
    assertEquals(1293836399999.0, r.getUpperBound(), EPSILON);

    // restore the default time zone
    TimeZone.setDefault(saved);
}

From source file:Debrief.Tools.FilterOperations.ShowTimeVariablePlot3.java

/**
 * Collate the data points to plot// ww w  .  java  2 s .  c  om
 * 
 * @param primaryTrack
 *          the primary track
 * @param myOperation
 *          the calculation we're making
 * @param theTracks
 *          the selected set of tracks
 * @param start_time
 *          the start time selected
 * @param end_time
 *          the end time selected
 * @param provider
 *          the provider of the time offset used when plotting time-zero data
 * @return the dataset to plot
 * @see toteCalculation#isWrappableData
 * @see toteCalculation#calculate(Watchable primary,Watchable
 *      secondary,HiResDate thisTime)
 * @see Debrief.Tools.FilterOperations.ShowTimeVariablePlot3.CalculationHolder#isARelativeCalculation
 * @see WatchableList#getItemsBetween(HiResDate start,HiResDate end)
 * @see TimeSeriesCollection#addSeries(BasicTimeSeries series)
 */
public static AbstractSeriesDataset getDataSeries(final WatchableList primaryTrack,
        final CalculationHolder myOperation, final Vector<WatchableList> theTracks, final HiResDate start_time,
        final HiResDate end_time, final ColouredDataItem.OffsetProvider provider) {

    final toteCalculation theCalculation = myOperation._theCalc;

    AbstractSeriesDataset theSeriesCollection = null;

    // ok, now collate the data
    VersatileSeriesAdder theAdder = null;
    // sort out the adder for what we're doing
    if (HiResDate.inHiResProcessingMode()) {
        theSeriesCollection = new TimeSeriesCollection();
        theAdder = new VersatileSeriesAdder() {
            public void add(final Series thisSeries, final HiResDate theTime, final double data,
                    final Color thisColor, final boolean connectToPrevious,
                    final ColouredDataItem.OffsetProvider provider1) {
                // HI-RES NOT DONE - FixedMillisecond should be converted
                // some-how to
                // FixedMicroSecond
                final TimeSeriesDataItem newItem = new ColouredDataItem(
                        new FixedMillisecond((long) (theTime.getMicros() / 1000d)), data, thisColor,
                        connectToPrevious, provider1);

                // To change body of implemented methods use File | Settings
                // | File
                // Templates.
                final TimeSeries theSeries = (TimeSeries) thisSeries;
                theSeries.add(newItem);
            }

            public void addSeries(final AbstractSeriesDataset collection, final Series thisSeries,
                    final Color defaultColor) {
                final TimeSeriesCollection coll = (TimeSeriesCollection) collection;
                coll.addSeries((TimeSeries) thisSeries);

            }
        };

    } else {
        theSeriesCollection = new TimeSeriesCollection();

        // right, just working with normal dates
        theAdder = new VersatileSeriesAdder() {
            public void add(final Series thisSeries, final HiResDate theTime, final double data,
                    final Color thisColor, final boolean connectToPrevious,
                    final ColouredDataItem.OffsetProvider provider1) {
                // HI-RES NOT DONE - FixedMillisecond should be converted
                // some-how to
                // FixedMicroSecond
                final ColouredDataItem newItem = new ColouredDataItem(
                        new FixedMillisecond(theTime.getDate().getTime()), data, thisColor, connectToPrevious,
                        provider1);

                // To change body of implemented methods use File | Settings
                // | File
                // Templates.
                final TimeSeries theSeries = (TimeSeries) thisSeries;
                theSeries.add(newItem);
            }

            public void addSeries(final AbstractSeriesDataset collection, final Series thisSeries,
                    final Color defaultColor) {
                final TimeSeriesCollection coll = (TimeSeriesCollection) collection;
                coll.addSeries((TimeSeries) thisSeries);
            }

        };
    }

    // calculate the data variables for our tracks
    final Enumeration<WatchableList> iter = theTracks.elements();
    while (iter.hasMoreElements()) {
        final WatchableList thisSecondaryTrack = (WatchableList) iter.nextElement();

        // is this a relative calculation?
        if (myOperation.isARelativeCalculation()) {
            // yes, but we don't bother with the primary track, see if this
            // is it
            if (thisSecondaryTrack == primaryTrack) {
                // just double check that we have primary data
                final Collection<Editable> ss = thisSecondaryTrack.getItemsBetween(start_time, end_time);

                if (ss == null) {
                    Application.logError2(ToolParent.WARNING, "Insufficient points found in primary track."
                            + "\nPlease check coverage of time controller bars", null);
                    return null;
                }

                // drop out, and wait for the next cycle
                continue;
            }
        }

        // ////////////////////////////////////////////////////
        // step through the track
        //
        final Collection<Editable> ss = thisSecondaryTrack.getItemsBetween(start_time, end_time);

        // indicator for whether we join this data point to the previous one
        boolean connectToPrevious = false;

        // have we found any?. Hey, listen here. The "getItemsBetween"
        // method may return data items, but we may still not be able to do the calc 
        // (such as if we have "NaN" for depth). So we still do a sanity check 
        // at the end of this method to stop us adding empty data series to the collection.
        if (ss == null) {
            Application.logError2(ToolParent.WARNING, "Insufficient points found in primary track."
                    + "\nPlease check coverage of time controller bars", null);
            return null;
        } else {
            // remember the default color for this series
            Color seriesColor;

            // ok, now collate the data
            Series thisSeries = null;
            // sort out the adder for what we're doing
            if (HiResDate.inHiResProcessingMode()) {
                thisSeries = new XYSeries(thisSecondaryTrack.getName());
            } else {
                thisSeries = new TimeSeries(thisSecondaryTrack.getName());
            }

            seriesColor = thisSecondaryTrack.getColor();

            // split into separate processing here, depending on where we're
            // looking
            // at a relative calculation
            if (myOperation.isARelativeCalculation()) {
                // yes, it is a relative calculation.

                // Find out if it's a special case (where we don't have time
                // data)
                if (thisSecondaryTrack.getStartDTG() == null) {
                    // do we have any primary data to fall back on (to
                    // decide the times
                    // for
                    // data points)
                    if (primaryTrack.getStartDTG() == null) {

                        // ////////////////////////////////////////////////
                        // CASE 1 - neither track has time data, relative
                        // calc
                        // ////////////////////////////////////////////////

                        // so, we don't have primary or secondary data.
                        // produce data
                        // values at the start and end of the track
                        // produce data points at the primary track
                        // locations
                        final Iterator<Editable> it = ss.iterator();
                        final Watchable theSecondaryPoint = (Watchable) it.next();

                        // get an iterator for the primary track
                        final Collection<Editable> primaryPoints = primaryTrack.getItemsBetween(start_time,
                                end_time);

                        // do we have any primary data in this period
                        if (primaryPoints != null) {
                            final Iterator<Editable> throughPrimary = primaryPoints.iterator();
                            final Watchable thisPrimary = (Watchable) throughPrimary.next();

                            // ok, create the series with it's two points in
                            produceTwoPointDataSeries(theCalculation, thisPrimary, theSecondaryPoint,
                                    thisSeries, start_time, end_time, provider, theAdder);

                        }
                    } else {

                        // ////////////////////////////////////////////////
                        // CASE 2 - secondary track has time data, relative
                        // calc
                        // ////////////////////////////////////////////////

                        // so, we do have time data for the secondary track,
                        // but not on
                        // the primary track
                        // therefore we produce data points at the primary
                        // track locations
                        final Watchable[] theSecondaryPoints = thisSecondaryTrack.getNearestTo(start_time);
                        final Watchable theSecondaryPoint = theSecondaryPoints[0];

                        final Color thisColor = theSecondaryPoint.getColor();

                        // get an iterator for the primary track
                        final Collection<Editable> primaryPoints = primaryTrack.getItemsBetween(start_time,
                                end_time);

                        if (primaryPoints != null) {
                            final Iterator<Editable> throughPrimary = primaryPoints.iterator();
                            while (throughPrimary.hasNext()) {
                                final Watchable thisPrimary = (Watchable) throughPrimary.next();

                                final HiResDate currentTime = thisPrimary.getTime();

                                // and add the new data point (if we have
                                // to)
                                connectToPrevious = createDataPoint(theCalculation, thisPrimary,
                                        theSecondaryPoint, currentTime, connectToPrevious, thisColor,
                                        thisSeries, provider, theAdder);

                            } // stepping through the primary track

                        } // whether we have primary points

                    }
                } else
                // whether we have DTG data
                {

                    // ////////////////////////////////////////////////
                    // CASE 3 - both tracks have time data, relative calc
                    // ////////////////////////////////////////////////
                    // yes, we do have DTG data for this track - hooray!

                    // ok, step through the list
                    final Iterator<Editable> it = ss.iterator();

                    // remember the last point - used to check if we're
                    // passing through
                    // zero degs
                    double lastSecondaryValue = Double.NaN; // we we're
                                                            // using NaN but
                                                            // it
                                                            // was failing the equality
                                                            // test
                    HiResDate lastTime = null;

                    throughThisTrack: while (it.hasNext()) {
                        final Watchable thisSecondary = (Watchable) it.next();

                        final Color thisColor = thisSecondary.getColor();

                        // what's the current time?
                        final HiResDate currentTime = thisSecondary.getTime();

                        // is this fix visible?
                        if (thisSecondary.getVisible()) {
                            // the point on the primary track we work with
                            Watchable thisPrimary = null;

                            // find the fix on the primary track which is
                            // nearest in
                            // time to this one (if we need to)
                            Watchable[] nearList;

                            // temp switch on interpolation
                            Boolean oldInterp = null;
                            if (primaryTrack instanceof ISecondaryTrack) {
                                final ISecondaryTrack tw = (ISecondaryTrack) primaryTrack;
                                oldInterp = tw.getInterpolatePoints();
                                tw.setInterpolatePoints(true);
                            }

                            // find it's nearest point on the primary track
                            nearList = primaryTrack.getNearestTo(currentTime);

                            // and restore the interpolate points setting
                            if (oldInterp != null) {
                                final ISecondaryTrack tw = (ISecondaryTrack) primaryTrack;
                                tw.setInterpolatePoints(oldInterp.booleanValue());
                            }

                            // yes. right, we only perform a calc if we have
                            // primary data
                            // for this point
                            if (nearList.length == 0) {
                                // remember that the next point doesn't
                                // connect to it's
                                // previous one
                                // since we want to show the gap represented
                                // by this datum
                                connectToPrevious = false;

                                // drop out, and wait for the next cycle
                                continue throughThisTrack;
                            } else {
                                thisPrimary = nearList[0];
                            }

                            // ////////////////////////////////////////////////
                            // NOW PUT IN BIT TO WRAP THROUGH ZERO WHERE
                            // APPLICABLE
                            // ////////////////////////////////////////////////

                            // produce the new calculated value
                            final double thisVal = theCalculation.calculate(thisSecondary, thisPrimary,
                                    currentTime);

                            // SPECIAL HANDLING - do we need to check if
                            // this data passes
                            // through 360 degs?
                            if (theCalculation.isWrappableData()) {
                                // add extra points, if we need to
                                connectToPrevious = insertWrappingPoints(theCalculation, lastSecondaryValue,
                                        thisVal, lastTime, currentTime, thisColor, thisSeries,
                                        connectToPrevious, provider, theAdder, myOperation._clipMax);
                            }
                            // ////////////////////////////////////////////////
                            // THANK YOU, WE'RE PLEASED TO RETURN YOU TO
                            // YOUR NORMAL PROGRAM
                            // ////////////////////////////////////////////////

                            // and add the new data point (if we have to)
                            connectToPrevious = createDataPoint(theCalculation, thisPrimary, thisSecondary,
                                    currentTime, connectToPrevious, thisColor, thisSeries, provider, theAdder);

                            lastSecondaryValue = thisVal;
                            lastTime = currentTime;

                        } // whether this point is visible
                    } // stepping through this track
                } // whether we have DTG data

            } else {
                // so, this is an absolute calculation - we don't need to
                // worry about
                // the primry
                // track

                // do we have time data for this secondary track?
                if (thisSecondaryTrack.getStartDTG() == null) {

                    // ////////////////////////////////////////////////
                    // CASE 4 - no time data, non-relative calculation
                    // ////////////////////////////////////////////////

                    // it's ok. It we don't have time related data for this
                    // point we
                    // just create
                    // data points for it at the start & end of the track

                    // ok, create the series with it's two points in
                    // ok, step through the list
                    final Iterator<Editable> it = ss.iterator();
                    final Watchable thisSecondary = (Watchable) it.next();

                    // and
                    produceTwoPointDataSeries(theCalculation, null, thisSecondary, thisSeries, start_time,
                            end_time, provider, theAdder);

                } else {

                    // ////////////////////////////////////////////////
                    // CASE 5 - with time data, non-relative calculation
                    // ////////////////////////////////////////////////

                    // ok, step through the list
                    final Iterator<Editable> it = ss.iterator();

                    // remember the last point - used to check if we're
                    // passing through
                    // zero degs
                    double lastSecondaryValue = Double.NaN; // we we're
                                                            // using NaN but
                                                            // it
                                                            // was failing the equality
                                                            // test
                    HiResDate lastTime = null;

                    while (it.hasNext()) {
                        final Watchable thisSecondary = (Watchable) it.next();

                        // / get the colour
                        final Color thisColor = thisSecondary.getColor();

                        // what's the time of this data point?
                        final HiResDate currentTime = thisSecondary.getTime();

                        // produce the new calculated value
                        final double thisVal = theCalculation.calculate(thisSecondary, null, currentTime);

                        // SPECIAL HANDLING - do we need to check if this
                        // data passes
                        // through 360 degs?
                        if (theCalculation.isWrappableData()) {
                            // add extra points, if we need to
                            connectToPrevious = insertWrappingPoints(theCalculation, lastSecondaryValue,
                                    thisVal, lastTime, currentTime, thisColor, thisSeries, connectToPrevious,
                                    provider, theAdder, myOperation._clipMax);
                        }

                        // is this fix visible?
                        if (thisSecondary.getVisible()) {
                            // the point on the primary track we work with
                            final Watchable thisPrimary = null;

                            // and add the new data point (if we have to)
                            connectToPrevious = createDataPoint(theCalculation, thisPrimary, thisSecondary,
                                    currentTime, connectToPrevious, thisColor, thisSeries, provider, theAdder);
                            lastSecondaryValue = thisVal;
                            lastTime = new HiResDate(currentTime);

                        } // whether this point is visible
                    } // stepping through this secondary collection
                } // whether there was time-related data for this track
            } // whether this was a relative calculation

            // if the series if empty, set it to null, rather than create
            // one of
            // empty length
            if (thisSeries instanceof XYSeries) {
                final XYSeries ser = (XYSeries) thisSeries;
                if (ser.getItemCount() == 0)
                    thisSeries = null;
            } else if (thisSeries instanceof TimeSeries) {
                final TimeSeries ser = (TimeSeries) thisSeries;
                if (ser.getItemCount() == 0)
                    thisSeries = null;
            }

            // did we find anything?
            if (thisSeries != null) {
                theAdder.addSeries(theSeriesCollection, thisSeries, seriesColor);
            }

        } // if this collection actually had data

    } // looping through the tracks

    if (theSeriesCollection.getSeriesCount() == 0)
        theSeriesCollection = null;

    return theSeriesCollection;
}

From source file:com.bdb.weather.display.day.DayXYPlotPane.java

protected void displaySeries(TimeSeriesCollection left, TimeSeriesCollection right) {
    int n = 0;/* w  w w. j ava2  s .c om*/
    XYItemRenderer renderer = getPlot().getRenderer(0);
    left.removeAllSeries();
    for (SeriesEntry entry : entries) {
        if (entry.checkbox == null || entry.checkbox.isSelected()) {
            if (entry.datasetLeft) {
                left.addSeries(entry.timeSeries);
                renderer.setSeriesPaint(n++, entry.seriesInfo.getPaint());
            }
        }
    }

    n = 0;
    renderer = getPlot().getRenderer(1);
    right.removeAllSeries();
    for (SeriesEntry entry : entries) {
        if (entry.checkbox == null || entry.checkbox.isSelected()) {
            if (!entry.datasetLeft) {
                right.addSeries(entry.timeSeries);
                renderer.setSeriesPaint(n++, entry.seriesInfo.getPaint());
            }
        }
    }
}

From source file:ec.ui.view.RevisionSaSeriesView.java

private void addSeries(TimeSeriesCollection chartSeries, TsData data) {
    TimeSeries chartTs = new TimeSeries("");
    for (int i = 0; i < data.getDomain().getLength(); ++i) {
        if (DescriptiveStatistics.isFinite(data.get(i))) {
            Day day = new Day(data.getDomain().get(i).middle());
            chartTs.addOrUpdate(day, data.get(i));
        }//from  w ww. j  ava2 s  .  c  o m
    }
    chartSeries.addSeries(chartTs);
}