查找数据点是否位于饼图饼图或饼图条形图的第二个饼图或条形图中

可能的使用场景

您可以找到系列的数据点是否在第二个饼图中馅饼的馅饼图表或在栏中馅饼吧使用 Aspose.Cells 的图表。请使用ChartPoint.IsInSecondaryPlot属性来确定它。

请下载示例 excel 文件在以下示例代码中使用并查看其控制台输出。如果你打开示例 excel 文件,你会发现,所有小于10的数据点都在馅饼吧图表也由控制台输出显示。

查找数据点是否位于饼图饼图或饼图条形图的第二个饼图或条形图中

以下示例代码显示如何查找数据点是否在第二个饼图或条形图中馅饼的馅饼要么馅饼吧图表。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// The path to the documents directory.
String dataDir = Utils.getSharedDataDir(FindDataPoints.class) + "articles/";
// Load source excel file containing Bar of Pie chart
Workbook wb = new Workbook(dataDir + "PieBars.xlsx");
// Access first worksheet
Worksheet ws = wb.getWorksheets().get(0);
// Access first chart which is Bar of Pie chart and calculate it
Chart ch = ws.getCharts().get(0);
ch.calculate();
// Access the chart series
Series srs = ch.getNSeries().get(0);
// Print the data points of the chart series and check
// its IsInSecondaryPlot property to determine if data point is inside
// the bar or pie
for (int i = 0; i < srs.getPoints().getCount(); i++) {
// Access chart point
ChartPoint cp = srs.getPoints().get(i);
// Skip null values
if (cp.getYValue() == null)
continue;
// Print the chart point value and see if it is inside bar or pie
// If the IsInSecondaryPlot is true, then the data point is inside
// bar
// otherwise it is inside the pie
System.out.println("Value: " + cp.getYValue());
System.out.println("IsInSecondaryPlot: " + cp.isInSecondaryPlot());
System.out.println();

控制台输出

请查看执行上述示例代码后生成的以下控制台输出示例 excel 文件.如果位于次要情节错误的 数据点在 Pie 内部或者如果它在真的,则数据点位于条形图内部。

 Value: 15

IsInSecondaryPlot: false

Value: 9

IsInSecondaryPlot: true

Value: 2

IsInSecondaryPlot: true

Value: 40

IsInSecondaryPlot: false

Value: 5

IsInSecondaryPlot: true

Value: 4

IsInSecondaryPlot: true

Value: 25

IsInSecondaryPlot: false