private void addValue(Object chartSerie, Number x, String lastXValue, Number y, HashMap<String, String> formatValues, int chartsNo) {			
		if (chart.getType().isLine()) {					
		   ((XYSeries)chartSerie).add(x, y);
		} else if (isLineCombo) {			
			lineBarDataset.addValue(y, (String)chartSerie, lastXValue);
		} else if (!chart.getType().isPie()) {
						
			GFunction function = FunctionFactory.getFunction(chart.getYFunction());
			if (!AbstractGFunction.NOOP.equals(function.getName()) || (chartsNo > 1)) {
				barDataset.setValue(y, (String)chartSerie, lastXValue);
			} else {			
				int serie = 0;
				Integer i = xValueSerie.get(lastXValue);
				if (i != null) {
					serie = i+1;
					xValueSerie.put(lastXValue, serie);
					barDataset.setValue(y, (String)chartSerie, lastXValue + " (" + serie + ")");		
				} else {
					barDataset.setValue(y, (String)chartSerie, lastXValue);
					xValueSerie.put(lastXValue, 0);
				}	
			}
			
		} else if (chart.getType().isPie()) {
			if (AbstractGFunction.NOOP.equals(chart.getYFunction())) {
				int serie = 0;
				Integer i = xValueSerie.get(lastXValue);
				if (i != null) {
					serie = i+1;
					xValueSerie.put(lastXValue, serie);
					pieDataset.setValue(lastXValue + " (" + serie + ")", y);					
				} else {
					pieDataset.setValue(lastXValue, y);
					xValueSerie.put(lastXValue, 0);
				}				
			} else {
				pieDataset.setValue(lastXValue, y);
			}
		}
		formatValues.put(x.toString(), lastXValue);
	}
private void addValue ( Object chartSerie , Number x , String lastXValue , Number y , HashMap < String , String > formatValues , int chartsNo ) { if ( chart . getType ( ) . isLine ( ) ) { ( ( XYSeries ) chartSerie ) . add ( x , y ) ; } else if ( isLineCombo ) { lineBarDataset . addValue ( y , ( String ) chartSerie , lastXValue ) ; } else if ( ! chart . getType ( ) . isPie ( ) ) { GFunction function = FunctionFactory . getFunction ( chart . getYFunction ( ) ) ; if ( ! AbstractGFunction . NOOP . equals ( function . getName ( ) ) || ( chartsNo > 1 ) ) { barDataset . setValue ( y , ( String ) chartSerie , lastXValue ) ; } else { int serie = 0 ; Integer i = xValueSerie . get ( lastXValue ) ; if ( i != null ) { serie = i + 1 ; xValueSerie . put ( lastXValue , serie ) ; barDataset . setValue ( y , ( String ) chartSerie , lastXValue + " (" + serie + ")" ) ; } else { barDataset . setValue ( y , ( String ) chartSerie , lastXValue ) ; xValueSerie . put ( lastXValue , 0 ) ; } } } else if ( chart . getType ( ) . isPie ( ) ) { if ( AbstractGFunction . NOOP . equals ( chart . getYFunction ( ) ) ) { int serie = 0 ; Integer i = xValueSerie . get ( lastXValue ) ; if ( i != null ) { serie = i + 1 ; xValueSerie . put ( lastXValue , serie ) ; pieDataset . setValue ( lastXValue + " (" + serie + ")" , y ) ; } else { pieDataset . setValue ( lastXValue , y ) ; xValueSerie . put ( lastXValue , 0 ) ; } } else { pieDataset . setValue ( lastXValue , y ) ; } } formatValues . put ( x . toString ( ) , lastXValue ) ; }
take care if no function is set : every value is in a differnet category (we use an incremental integer : serie)