チャート シリーズのポイントの X 値と Y 値のタイプを見つける
Contents
[
Hide
]
考えられる使用シナリオ
系列のチャート ポイントの X 値と Y 値のタイプを知りたい場合があります。 Aspose.Cells は、この目的で使用できる ChartPoint.XValueType および ChartPoint.YValueType プロパティを提供します。これらのプロパティを効果的に使用するには、Chart.Calculate() メソッドを呼び出す必要があることに注意してください。
チャート シリーズのポイントの X 値と Y 値のタイプを見つける
次のサンプル コードは、サンプル Excel ファイル最初のワークシート内の最初のグラフにアクセスします。次に、Chart.Calculate() メソッドを呼び出し、最初のチャート ポイントの X 値と Y 値のタイプを見つけて、コンソールに出力します。参考として、以下に示すコンソール出力を参照してください。
サンプルコード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
//Load sample Excel file containing chart. | |
Workbook wb = new Workbook(sourceDir + "sampleFindTypeOfXandYValuesOfPointsInChartSeries.xlsx"); | |
//Access first worksheet. | |
Worksheet ws = wb.Worksheets[0]; | |
//Access first chart. | |
Chart ch = ws.Charts[0]; | |
//Calculate chart data. | |
ch.Calculate(); | |
//Access first chart point in the first series. | |
ChartPoint pnt = ch.NSeries[0].Points[0]; | |
//Print the types of X and Y values of chart point. | |
Console.WriteLine("X Value Type: " + pnt.XValueType); | |
Console.WriteLine("Y Value Type: " + pnt.YValueType); |
コンソール出力
X Value Type: IsString
Y Value Type: IsNumeric