Free Support Forum - aspose.com

怎么给 High Low Colse 图表赋值


#1

我们公司使用的是 aspose-slides-16.4.0.jar 企业版。

比如,给 Clustered Column赋值是使用 series.getDataPoints().addDataPointForBarSeries。
那么,High Low Close 如何赋值?


#2

@cpych,

我已经观察了你的要求,但却无法完全理解这一点。 您能否以样本演示和快照的形式分享您想要使用Aspose.Slides设置的内容。


#3

import com.aspose.slides.ChartType;
import com.aspose.slides.IChart;
import com.aspose.slides.IChartDataCell;
import com.aspose.slides.IChartDataPointCollection;
import com.aspose.slides.IChartDataWorkbook;
import com.aspose.slides.IChartSeries;
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;

public class TestHighLowClose {

public void testHighLowClose() {
	Presentation presentation = new Presentation();
	IChart chart = presentation.getSlides().get_Item(0).getShapes().addChart(ChartType.HighLowClose, 100, 100, 400, 400);

	chart.getChartData().getSeries().clear();
	chart.getChartData().getCategories().clear();
	IChartDataWorkbook fact = chart.getChartData().getChartDataWorkbook();
	fact.clear(0);
	fact.clear(1);
	fact.clear(2);
	fact.clear(3);
	fact.clear(4);

	{
		int defaultWorksheetIndex = 0;
		chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 1, 0, "First Qtr"));
		IChartSeries series = chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 1, "Series 1"), chart.getType());
		IChartDataPointCollection icdpc = series.getDataPoints();
		IChartDataCell cell = fact.getCell(defaultWorksheetIndex, 1, 1, 20);
		
		// Problem : addDataPointForBarSeries is not applicable to ChartType.HighLowClose
		icdpc.addDataPointForBarSeries(cell); // Exception : Parent series is not Bar series.
	}

	presentation.save("C:\\Users\\Administrator\\Desktop\\HighLowClose.pptx", SaveFormat.Pptx);
}

public static void main(String[] args) {
	new TestHighLowClose().testHighLowClose();
}

}


#4

@cpych,

我已经观察了您共享的示例代码,并且想要分享ID已经在iur iasue跟踪系统中添加了ID SLIDESJAVA-36564的问题,以便调查并解决此问题。此主题已与该问题相关联,因此一旦问题得到解决,您可能会收到通知。