skip to main content
Charts > Programmer's documentation > Developing with the JViews Charts SDK > Using the Data Model > Synchronizing the Contents of Several Data Sets
 
Synchronizing the Contents of Several Data Sets
Your goal is to provide a display of the following measurements for a given day:
*The temperature at the beginning of the day.
*The temperature at the end of the day.
*The highest temperature during the day.
*The lowest temperature during the day.
1. Create a data set for each of these measures.
2. Store them in a data source. The update of these data sets occurs through a listener on the original temperature data set. This listener either appends new points or modifies the value of existing points in the corresponding data set.
The complete source code can be found in <installdir>/jviews-charts/samples/listener/index.html.
 
// Contains the (High, Low, Start, End) data sets.
protected IlvDataSource hiloDS;
 
DataSetListener tempListener = new DataSetListener() {
  public void dataSetContentsChanged(DataSetContentsEvent evt)
  {
    if (evt.getType() == DataSetContentsEvent.DATA_ADDED) {
      IlvDataSet ds = evt.getDataSet();
      double x = ds.getXData(evt.getFirstIdx());
      double y = ds.getYData(evt.getFirstIdx());
      int count = ds.getDataCount()-1;
      if (count < 0) count = 0;
      if ((count%24) == 0) {
  // If the point begins a new day, add it to all the hilo data
        // sets (High, Low, Start, End).
        for (int i=0; i<hiloDS.getDataSetCount(); ++i) {
          hiloDS.getDataSet(i).addData(x,y);
        }
      } else {
   // Else, update the high/low/end values accordingly.
   ...
      }
  }
 
   public void dataSetPropertyChanged(DataSetPropertyEvent evt) {}
};

Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.