Loosing chart formatting information after using setRange

Hi all,

I am trieng to fill data in a chart, it’s working fine, but agter using chart.getChartData().setRange(range) all the style and formatting information is changed… :frowning:

before:
grafik.png (12.0 KB)

after using setRange:
grafik.png (7.3 KB)

Can please anybody help?

Thanks in advance
Möbi

@moebi089,

I have observed your comments. Can you please share source files along with generated result and sample project to reproduce issue also please share environment details with us so that we may further investigate to help you out.

Thanks for observing and trieng to help :slight_smile:

this is the code I used:

String dataDir = “C:/slides/Examples/src/main/resources/com/aspose/slides/examples/Slides/Charts/UpdatingExistingChart/”;

String pptxFile = “Example.pptx”;

Presentation pres = new Presentation(dataDir + pptxFile);

ISlideCollection slds = pres.getSlides();

for (int i = 0; i < slds.size(); i++) {

ISlide sld = slds.get_Item(i);

for (int h = 0; h < sld.getShapes().size(); h++) {

	IShape shape = sld.getShapes().get_Item(h);

	if (shape instanceof IChart) {
		
		IChart chart = (IChart) shape;
		
		int defaultWorksheetIndex = 0;
		
		// Getting the chart data WorkSheet
		IChartDataWorkbook fact = chart.getChartData().getChartDataWorkbook();
		
		// Take first chart series
		IChartSeries series0 = chart.getChartData().getSeries().get_Item(0);
		IChartSeries series1 = chart.getChartData().getSeries().get_Item(1);
		IChartSeries series2 = chart.getChartData().getSeries().get_Item(2);
		IChartSeries series3 = chart.getChartData().getSeries().get_Item(3);
		
		IChartDataCell cell = fact.getCell(defaultWorksheetIndex, 0, 0);
		
		PopoChartData popo = null;
		Object o = hmPopoChartData.get (cell.getValue());
		if ( o != null && o instanceof PopoChartData ) {
			popo = (PopoChartData)o;	
		} else {
			continue;
		}


		String range = "Tabelle1!A1:E"+(popo.categorieCounter+1);
		chart.getChartData().setRange(range);

		Iterator iterCategories = popo.categories.listIterator(); 
		Iterator iterZustimmer=popo.zustimmerList.listIterator();
		Iterator iterNeutral=popo.neutralList.listIterator();
		Iterator iterAblehner=popo.ablehnerList.listIterator();
		
		for ( int r=0; r<7; r++ ) {
			if ( iterCategories.hasNext() ) {
				fact.getCell(defaultWorksheetIndex, r+1, 0).setValue(iterCategories.next());
			} else {
				fact.getCell(defaultWorksheetIndex, r+1, 0).setValue(null);
				series0.getDataPoints().get_Item(r).getValue().setData(null);
			}
			series1.getDataPoints().get_Item(r).getValue().setData(iterZustimmer.hasNext()?iterZustimmer.next():null);
			series2.getDataPoints().get_Item(r).getValue().setData(iterNeutral.hasNext()?iterNeutral.next():null);
			series3.getDataPoints().get_Item(r).getValue().setData(iterAblehner.hasNext()?iterAblehner.next():null);
		}

	}			

}			

}

pres.save(dataDir + “ExampleModified.pptx”, SaveFormat.Pptx);

}

UpdatingExistingChart.zip (111.3 KB)

and here are the pptx-Files

@moebi089,

I have worked with presentation file shared by you and have been able to observe the issue specified. An issue with ID SLIDESJAVA-37012 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

Hello :slight_smile:

did you find anything out yet?

@moebi089,

I regret to share that the concerned issue is still unresolved. We request for your patience till the time the issue gets resolved.

The issues you have found earlier (filed as SLIDESJAVA-37012) have been fixed in this update.