public void handleItemChanged(TimeStampedDataItem changedItem) {
    int index = myInput.getItems().indexOf(changedItem);
    if (index < 0) {
      return;
    }

    double currentXValue = myXComponent.getDoubleValue(changedItem);
    BackedXYDataItem chartItem = (BackedXYDataItem) mySeries.getDataItem(index);
    if (chartItem.getDomainItem() != changedItem) {
      int shouldBeAt = myInput.getItems().indexOf(chartItem.getDomainItem());
      throw new IllegalStateException(
          "domain position for element: "
              + changedItem
              + //
              " is "
              + index
              + //
              ", but chart series contains "
              + chartItem.getDomainItem()
              + //
              " which should be at position: "
              + shouldBeAt);
    }
    if (currentXValue == chartItem.getXValue()) {
      mySeries.updateByIndex(index, myYComponent.getDoubleValue(changedItem));
    } else {
      handleItemDeleted(index, changedItem);
      handleItemAdded(index, changedItem);
    }
  }
 public void handleItemAdded(int index, TimeStampedDataItem addedItem) {
   mySeries.insertAt(index, createChartItem(addedItem));
 }
 public void handleItemDeleted(int oldIndex, TimeStampedDataItem deletedItem) {
   mySeries.remove(oldIndex);
 }