Program: 65924
Project: 65924
Buggy source:
private Chart getConvertedChart(Chart currentChart,String sNewSubType,Orientation newOrientation,String sNewDimension){
  Chart helperModel=currentChart.copyInstance();
  helperModel.eAdapters().addAll(currentChart.eAdapters());
  ChartCacheManager.getInstance().cacheSeries(ChartUIUtil.getAllOrthogonalSeriesDefinitions(helperModel));
  IChartType oldType=ChartUIUtil.getChartType(currentChart.getType());
  if ((currentChart instanceof ChartWithAxes)) {
    Axis xAxis=((ChartWithAxes)currentChart).getAxes().get(0);
    if (currentChart.getType().equals(TYPE_LITERAL)) {
      if (!currentChart.getSubType().equals(sNewSubType)) {
        currentChart.setSubType(sNewSubType);
        for (        Axis yAxis : xAxis.getAssociatedAxes()) {
          yAxis.unsetPercent();
          for (          SeriesDefinition ysd : yAxis.getSeriesDefinitions()) {
            Series series=ysd.getDesignTimeSeries();
            series.unsetStacked();
            if (series instanceof StockSeries) {
              ((StockSeries)series).setShowAsBarStick(BAR_STICK_SUBTYPE_LITERAL.equals(currentChart.getSubType()));
            }
          }
        }
      }
    }
 else {
      if (!currentChart.getType().equals(TYPE_LITERAL)) {
        currentChart.setSampleData(getConvertedSampleData(currentChart.getSampleData(),false));
      }
      currentChart.setType(TYPE_LITERAL);
      Text title=currentChart.getTitle().getLabel().getCaption();
      if (title.getValue() != null && (title.getValue().trim().length() == 0 || title.getValue().trim().equals(oldType.getDefaultTitle().trim()))) {
        title.setValue(getDefaultTitle());
      }
      currentChart.setSubType(sNewSubType);
      int seriesIndex=0;
      for (      Axis yAxis : xAxis.getAssociatedAxes()) {
        if (!ChartPreviewPainter.isLivePreviewActive()) {
          yAxis.setType(AxisType.LINEAR_LITERAL);
        }
        yAxis.unsetPercent();
        for (        SeriesDefinition ysd : yAxis.getSeriesDefinitions()) {
          Series series=ysd.getDesignTimeSeries();
          series=getConvertedSeries(series,seriesIndex);
          series.unsetStacked();
          ysd.getSeries().clear();
          ysd.getSeries().add(series);
          seriesIndex++;
        }
      }
    }
  }
 else {
    currentChart=ChartWithAxesImpl.createDefault();
    copyChartProperties(helperModel,currentChart);
    currentChart.setType(TYPE_LITERAL);
    currentChart.setSubType(sNewSubType);
    ChartElementUtil.setEObjectAttribute(currentChart,"String_Node_Str",newOrientation,newOrientation == null);
    ChartElementUtil.setEObjectAttribute(currentChart,"String_Node_Str",getDimensionFor(sNewDimension),sNewDimension == null);
    Axis xAxis=((ChartWithAxes)currentChart).getAxes().get(0);
    Axis yAxis=xAxis.getAssociatedAxes().get(0);
    currentChart.setSampleData(getConvertedSampleData(currentChart.getSampleData(),true));
{
      xAxis.getSeriesDefinitions().clear();
      xAxis.getSeriesDefinitions().add(((ChartWithoutAxes)helperModel).getSeriesDefinitions().get(0));
      yAxis.getSeriesDefinitions().clear();
      yAxis.getSeriesDefinitions().addAll(xAxis.getSeriesDefinitions().get(0).getSeriesDefinitions());
      SeriesDefinition bsd=xAxis.getSeriesDefinitions().get(0);
      Series series=bsd.getDesignTimeSeries();
      bsd.getSeries().clear();
      bsd.getSeries().add(series);
      int j=0;
      for (      SeriesDefinition vsd : yAxis.getSeriesDefinitions()) {
        series=vsd.getDesignTimeSeries();
        series=getConvertedSeries(series,j++);
        series.getLabel().unsetVisible();
        series.unsetStacked();
        vsd.getSeries().clear();
        vsd.getSeries().add(series);
      }
    }
    Text title=currentChart.getTitle().getLabel().getCaption();
    if (title.getValue() != null && (title.getValue().trim().length() == 0 || title.getValue().trim().equals(oldType.getDefaultTitle().trim()))) {
      title.setValue(getDefaultTitle());
    }
  }
  ChartElementUtil.setEObjectAttribute(currentChart,"String_Node_Str",newOrientation,newOrientation == null);
  ChartElementUtil.setEObjectAttribute(currentChart,"String_Node_Str",getDimensionFor(sNewDimension),sNewDimension == null);
  ChartUIUtil.restoreLabelPositionFromCache(currentChart);
  SeriesGrouping sg=ChartUtil.getBaseSeriesDefinitions(currentChart).get(0).getGrouping();
  if (sg.getGroupType().getValue() == DataType.DATE_TIME) {
    ChartUIUtil.updateDefaultAggregations(currentChart);
  }
  return currentChart;
}

Fixed version (ground truth):
private Chart getConvertedChart(Chart currentChart,String sNewSubType,Orientation newOrientation,String sNewDimension){
  Chart helperModel=currentChart.copyInstance();
  helperModel.eAdapters().addAll(currentChart.eAdapters());
  ChartCacheManager.getInstance().cacheSeries(ChartUIUtil.getAllOrthogonalSeriesDefinitions(helperModel));
  IChartType oldType=ChartUIUtil.getChartType(currentChart.getType());
  if ((currentChart instanceof ChartWithAxes)) {
    Axis xAxis=((ChartWithAxes)currentChart).getAxes().get(0);
    if (currentChart.getType().equals(TYPE_LITERAL)) {
      if (!currentChart.getSubType().equals(sNewSubType)) {
        currentChart.setSubType(sNewSubType);
        for (        Axis yAxis : xAxis.getAssociatedAxes()) {
          yAxis.unsetPercent();
          for (          SeriesDefinition ysd : yAxis.getSeriesDefinitions()) {
            Series series=ysd.getDesignTimeSeries();
            series.unsetStacked();
            if (series instanceof StockSeries) {
              ((StockSeries)series).setShowAsBarStick(BAR_STICK_SUBTYPE_LITERAL.equals(currentChart.getSubType()));
            }
          }
        }
      }
    }
 else {
      if (!currentChart.getType().equals(TYPE_LITERAL)) {
        currentChart.setSampleData(getConvertedSampleData(currentChart.getSampleData(),false));
      }
      currentChart.setType(TYPE_LITERAL);
      Text title=currentChart.getTitle().getLabel().getCaption();
      if (title.getValue() != null && (title.getValue().trim().length() == 0 || title.getValue().trim().equals(oldType.getDefaultTitle().trim()))) {
        title.setValue(getDefaultTitle());
      }
      currentChart.setSubType(sNewSubType);
      int seriesIndex=0;
      for (      Axis yAxis : xAxis.getAssociatedAxes()) {
        if (!ChartPreviewPainter.isLivePreviewActive()) {
          yAxis.setType(AxisType.LINEAR_LITERAL);
        }
        yAxis.unsetPercent();
        for (        SeriesDefinition ysd : yAxis.getSeriesDefinitions()) {
          Series series=ysd.getDesignTimeSeries();
          series=getConvertedSeries(series,seriesIndex);
          series.unsetStacked();
          ysd.getSeries().clear();
          ysd.getSeries().add(series);
          seriesIndex++;
        }
      }
    }
  }
 else {
    currentChart=ChartWithAxesImpl.createDefault();
    copyChartProperties(helperModel,currentChart);
    currentChart.setType(TYPE_LITERAL);
    currentChart.setSubType(sNewSubType);
    ChartElementUtil.setEObjectAttribute(currentChart,"String_Node_Str",newOrientation,newOrientation == null);
    ChartElementUtil.setEObjectAttribute(currentChart,"String_Node_Str",getDimensionFor(sNewDimension),sNewDimension == null);
    try {
      ChartElementUtil.setDefaultValue(((ChartWithAxes)currentChart).getAxes().get(0),"String_Node_Str",true);
    }
 catch (    ChartException e) {
    }
    Axis xAxis=((ChartWithAxes)currentChart).getAxes().get(0);
    Axis yAxis=xAxis.getAssociatedAxes().get(0);
    currentChart.setSampleData(getConvertedSampleData(currentChart.getSampleData(),true));
{
      xAxis.getSeriesDefinitions().clear();
      xAxis.getSeriesDefinitions().add(((ChartWithoutAxes)helperModel).getSeriesDefinitions().get(0));
      yAxis.getSeriesDefinitions().clear();
      yAxis.getSeriesDefinitions().addAll(xAxis.getSeriesDefinitions().get(0).getSeriesDefinitions());
      SeriesDefinition bsd=xAxis.getSeriesDefinitions().get(0);
      Series series=bsd.getDesignTimeSeries();
      bsd.getSeries().clear();
      bsd.getSeries().add(series);
      int j=0;
      for (      SeriesDefinition vsd : yAxis.getSeriesDefinitions()) {
        series=vsd.getDesignTimeSeries();
        series=getConvertedSeries(series,j++);
        series.getLabel().unsetVisible();
        series.unsetStacked();
        vsd.getSeries().clear();
        vsd.getSeries().add(series);
      }
    }
    Text title=currentChart.getTitle().getLabel().getCaption();
    if (title.getValue() != null && (title.getValue().trim().length() == 0 || title.getValue().trim().equals(oldType.getDefaultTitle().trim()))) {
      title.setValue(getDefaultTitle());
    }
  }
  ChartElementUtil.setEObjectAttribute(currentChart,"String_Node_Str",newOrientation,newOrientation == null);
  ChartElementUtil.setEObjectAttribute(currentChart,"String_Node_Str",getDimensionFor(sNewDimension),sNewDimension == null);
  ChartUIUtil.restoreLabelPositionFromCache(currentChart);
  SeriesGrouping sg=ChartUtil.getBaseSeriesDefinitions(currentChart).get(0).getGrouping();
  if (sg.getGroupType().getValue() == DataType.DATE_TIME) {
    ChartUIUtil.updateDefaultAggregations(currentChart);
  }
  return currentChart;
}