Program: 73685
Project: 73685
Buggy source:
/** 
 * Add aggregate bindings of value series for grouping case.
 * @param query
 * @param seriesDefinitions
 * @param innerGroupDef
 * @param valueExprMap
 * @param baseSD
 * @throws DataException
 * @throws DataException
 */
protected void addValueSeriesAggregateBindingForGrouping(BaseQueryDefinition query,EList seriesDefinitions,GroupDefinition innerGroupDef,Map valueExprMap,SeriesDefinition baseSD) throws ChartException {
  for (Iterator iter=seriesDefinitions.iterator(); iter.hasNext(); ) {
    SeriesDefinition orthSD=(SeriesDefinition)iter.next();
    Series series=orthSD.getDesignTimeSeries();
    List qlist=ChartEngine.instance().getDataSetProcessor(series.getClass()).getDataDefinitionsForGrouping(series);
    for (Iterator iter_datadef=series.getDataDefinition().iterator(); iter_datadef.hasNext(); ) {
      Query qry=(Query)iter_datadef.next();
      if (!qlist.contains(qry)) {
        continue;
      }
      String expr=qry.getDefinition();
      if (expr != null && !"String_Node_Str".equals(expr)) {
        String aggName=ChartUtil.getAggregateFuncExpr(orthSD,baseSD);
        if (aggName != null && !"String_Node_Str".equals(aggName)) {
          String name=generateUniqueBindingName(expr);
          Binding colBinding=new Binding(name);
          colBinding.setDataType(org.eclipse.birt.core.data.DataType.ANY_TYPE);
          colBinding.setExpression(new ScriptExpression(expr));
          if (innerGroupDef != null) {
            try {
              colBinding.addAggregateOn(innerGroupDef.getName());
            }
 catch (            DataException e) {
              throw new ChartException(ChartReportItemPlugin.ID,ChartException.DATA_BINDING,e);
            }
          }
          colBinding.setAggrFunction(ChartReportItemUtil.convertToDtEAggFunction(aggName));
          IAggregateFunction aFunc=PluginSettings.instance().getAggregateFunction(aggName);
          if (aFunc.getParametersCount() > 0) {
            Object[] parameters=getAggFunParameters(orthSD,baseSD);
            for (int i=0; i < parameters.length && i < aFunc.getParametersCount(); i++) {
              String param=(String)parameters[i];
              colBinding.addArgument(new ScriptExpression(param));
            }
          }
          String newExpr=getExpressionForEvaluator(name);
          qry.setDefinition(newExpr);
          try {
            query.addBinding(colBinding);
          }
 catch (          DataException e) {
            throw new ChartException(ChartReportItemPlugin.ID,ChartException.DATA_BINDING,e);
          }
          valueExprMap.put(expr,newExpr);
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Add aggregate bindings of value series for grouping case.
 * @param query
 * @param seriesDefinitions
 * @param innerGroupDef
 * @param valueExprMap
 * @param baseSD
 * @throws DataException
 * @throws DataException
 */
protected void addValueSeriesAggregateBindingForGrouping(BaseQueryDefinition query,EList seriesDefinitions,GroupDefinition innerGroupDef,Map valueExprMap,SeriesDefinition baseSD) throws ChartException {
  for (Iterator iter=seriesDefinitions.iterator(); iter.hasNext(); ) {
    SeriesDefinition orthSD=(SeriesDefinition)iter.next();
    Series series=orthSD.getDesignTimeSeries();
    List qlist=ChartEngine.instance().getDataSetProcessor(series.getClass()).getDataDefinitionsForGrouping(series);
    for (Iterator iter_datadef=series.getDataDefinition().iterator(); iter_datadef.hasNext(); ) {
      Query qry=(Query)iter_datadef.next();
      if (!qlist.contains(qry)) {
        continue;
      }
      String expr=qry.getDefinition();
      if (expr != null && !"String_Node_Str".equals(expr)) {
        String aggName=ChartUtil.getAggregateFuncExpr(orthSD,baseSD);
        if (aggName != null && !"String_Node_Str".equals(aggName)) {
          String name=generateUniqueBindingName(expr);
          Binding colBinding=new Binding(name);
          colBinding.setDataType(org.eclipse.birt.core.data.DataType.ANY_TYPE);
          colBinding.setExpression(new ScriptExpression(expr));
          if (innerGroupDef != null) {
            try {
              colBinding.addAggregateOn(innerGroupDef.getName());
            }
 catch (            DataException e) {
              throw new ChartException(ChartReportItemPlugin.ID,ChartException.DATA_BINDING,e);
            }
          }
          colBinding.setAggrFunction(ChartReportItemUtil.convertToDtEAggFunction(aggName));
          IAggregateFunction aFunc=PluginSettings.instance().getAggregateFunction(aggName);
          if (aFunc.getParametersCount() > 0) {
            Object[] parameters=getAggFunParameters(orthSD,baseSD);
            for (int i=0; i < parameters.length && i < aFunc.getParametersCount(); i++) {
              String param=(String)parameters[i];
              colBinding.addArgument(new ScriptExpression(param));
            }
          }
          String newExpr=getExpressionForEvaluator(name);
          updateQueryDefinitionForSortOnAggregateExpression(qry,name,newExpr);
          try {
            query.addBinding(colBinding);
          }
 catch (          DataException e) {
            throw new ChartException(ChartReportItemPlugin.ID,ChartException.DATA_BINDING,e);
          }
          valueExprMap.put(expr,new String[]{name,newExpr});
        }
      }
    }
  }
}