Node.jsとC++を使って、Data Pointsが円の第二の円または棒の中にあるかどうかを調べる方法

可能な使用シナリオ

シリーズのデータポイントがPie of Pieチャートの第二の円にあるか、またはBar of Pieチャートの棒にあるかを、Aspose.Cells for Node.js via C++を使って確認できます。 ChartPoint.isInSecondaryPlot() プロパティを使用して判定してください。

以下のサンプルコードとサンプルExcelファイルをダウンロードし、そのコンソール出力を確認してください。Excelファイルを開くと、すべての値が10未満のデータポイントがBar of Pieチャートの棒内にあることがわかります。

パイオブパイチャートまたはバーオブパイチャートでデータポイントが第2パイまたは棒にあるかどうかを見つける

次のサンプルコードは、Pie of PieまたはBar of Pieチャートの第二の円または棒内にデータポイントがあるかどうかを確認する方法を示しています。

const path = require("path");
const AsposeCells = require("aspose.cells.node");

// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
// Load source excel file containing Bar of Pie chart
const workbook = new AsposeCells.Workbook(path.join(dataDir, "PieBars.xlsx"));

// Access first worksheet
const worksheet = workbook.getWorksheets().get(0);

// Access first chart which is Bar of Pie chart and calculate it
const chart = worksheet.getCharts().get(0);
chart.calculate();

// Access the chart series
const series = chart.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 (let i = 0; i < series.getPoints().getCount(); i++) {
// Access chart point
const chartPoint = series.getPoints().get(i);

// Skip null values
if (chartPoint.get_YValue() === 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. 
*/
console.log("Value: " + chartPoint.get_YValue());
console.log("IsInSecondaryPlot: " + chartPoint.isInSecondaryPlot());
console.log();
}

コンソール出力

上記のサンプルコードとサンプルExcelファイルの実行後に生成されるコンソール出力を確認してください。 ChartPoint.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