パイオブパイチャートまたはバーオブパイチャートでデータポイントが第2パイまたは棒にあるかどうかを見つける
可能な使用シナリオ
Aspose.Cellsを使用して、Pie of Pieチャートの第2パイまたはBar of Pieチャートの棒にシリーズのデータポイントがあるかどうかを見つけることができます。ChartPoint.IsInSecondaryPlotプロパティを使用してください。
以下のサンプルコードを使用して、sample excel fileをダウンロードし、そのコンソール出力を確認してください。sample excel fileを開くと、コンソール出力によっても示されているように、10未満のすべてのデータポイントがBar of Pieチャートの内側にあります。
パイオブパイチャートまたはバーオブパイチャートでデータポイントが第2パイまたは棒にあるかどうかを見つける
以下のサンプルコードは、Pie of PieまたはBar of Pieチャートでデータポイントが第2パイまたは棒にあるかどうかを見つける方法を示しています。
// 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(); |
コンソール出力
以下は、上記のサンプルコードの実行後に生成されたコンソール出力です。IsInSecondaryPlotがfalseの場合、データポイントはパイの内側にあり、trueの場合はデータポイントが棒の内側にあります。
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