-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PieChart method #19
Comments
You can try I see examples in OfficeIMO document.AddParagraph("This is a pie chart");
var pieChart = document.AddPieChart();
pieChart.AddCategories(categories);
pieChart.AddChartPie("Poland", new List<int> { 15, 20, 30 }); So either I made mistake, or just needs improvements. |
Tried both ways, and both result in the same error, I suspect it is indeed due to lack of handling for single values. Thank you for your response and for the module! |
Ok, i checked it and it seems the implementation differs a bit from my other projects. The trick is - it's one name, but with 4 categories, and the values match the category... List<string> categories = new List<string>() { "Food", "Housing", "Mix", "Data" };
var pieChart2 = document.AddPieChart();
pieChart2.AddCategories(categories);
pieChart2.AddChartPie("Poland", new List<int> { 10, 20, 30, 40 }); I need to decide what to do, as the implementation is like that in all chartts - need to think about it, but till then - using categories with one entry should work. |
This PR should resolve your issue: It also changes how things work when it comes to charts so you will need to change some code, and then you need to null out values as it's possible to do AddPie(5).AddPie(7).AddPie(9) but this means an object is returned on AddPie, AddLine and so on. |
Thank you very much! Got it working now following your advice, and I understand that once PsWriteOffice is updated, this will need changing. # Define categories and corresponding data
[string[]]$Categories = @("Compliant Resources", "Non-Compliant Resources")
$CompliantResources = $ComplianceSummary.TotalResources - $ComplianceSummary.NonCompliantResources
$NonCompliantResources = $ComplianceSummary.NonCompliantResources
# Add a Pie Chart to the document
$PieChart = $PieChartDocument.AddPieChart("Azure Policy Compliance Summary")
$PieChart.AddCategories($Categories)
# Populate the pie chart with data
$Values = [System.Collections.Generic.List[int]]::new()
$Values.Add($CompliantResources)
$Values.Add($NonCompliantResources)
$PieChart.AddChartPie("Compliance Breakdown", $Values)
$PieChart.AddLegend("Bottom")
$PieChart.RoundedCorners = $true |
Yes, the whole charts have been rebuilt. I need to further improve it, but upgrading PSWriteOffice to new version will break current charts. |
Hello Przemysław,
I have been struggling to use
.AddPieChart
and.AddChartPie
to add a pie chart to Word doc output..AddPieChart
seems to work OK in that my output doc lands up with a blank section that would be a pie, but whenever I try to use.AddChartPie
I get an overload error.Most basic example:
Error:
I've tried making sure I'm using the expected types as defined below, but every variation seems to fail and results in the overload error.
Can you offer any guidance or share an example?
The text was updated successfully, but these errors were encountered: