Trova se i punti dati sono nel secondo grafico a torta o a barre su un grafico a torta di torta o a barre. Trova come usare Aspose.Cells for .NET per trovare se i punti dati sono nel secondo grafico a torta o barre su un grafico a torta di torta o a barre. La nostra guida dimostrerà come identificare e accedere al secondo grafico a torta o a barre su un grafico composito, consentendoti di analizzare e manipolare i dati in modo efficace.
Possibili Scenari di Utilizzo
Puoi scoprire se i punti dati di una serie sono nel secondo grafico a torta o nel grafico a barre usando Aspose.Cells. Si prega di utilizzare la proprietà ChartPoint.IsInSecondaryPlot per determinarlo.
Si prega di scaricare il file excel di esempio utilizzato nel seguente codice di esempio e vedere il suo output sulla console. Se si apre il file excel di esempio, si noterà che tutti i punti dati inferiori a 10 sono all’interno del grafico a barre di Grafico a Barre di Torta come mostrato anche dall’output sulla console.
Verifica se i punti dati sono nel secondo grafico a torta o a barre su un grafico di torta o barre di un grafico a torta
Il seguente codice di esempio mostra come trovare se i punti dati sono nel secondo grafico a torta o a barre su un grafico Torta di torte o Barra di torte.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
//Load source excel file containing Bar of Pie chart | |
Workbook wb = new Workbook(dataDir + "PieBars.xlsx"); | |
// Access first worksheet | |
Worksheet ws = wb.Worksheets[0]; | |
// Access first chart which is Bar of Pie chart and calculate it | |
Chart ch = ws.Charts[0]; | |
ch.Calculate(); | |
// Access the chart series | |
Series srs = ch.NSeries[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.Points.Count; i++) | |
{ | |
//Access chart point | |
ChartPoint cp = srs.Points[i]; | |
//Skip null values | |
if (cp.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.WriteLine("Value: " + cp.YValue); | |
Console.WriteLine("IsInSecondaryPlot: " + cp.IsInSecondaryPlot); | |
Console.WriteLine(); | |
} |
Output della console
Si prega di vedere l’output della console generato dopo l’esecuzione del codice di esempio sopra con il file excel di esempio. Se IsInSecondaryPlot è false, il punto dati è all’interno della torta oppure se è true, allora il punto dati è all’interno della barra.
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