OfficeDev / Open-Xml-PowerTools

MIT License
692 stars 26 forks source link

ChartUpdater does not work with Waterfall Charts. #265

Closed ahmet269 closed 5 years ago

ahmet269 commented 5 years ago

I am trying to update data in waterfall chart in word but chartupdater is unable to do this. ChartUpdater does not exist as ChartPart on the MainDocumentPart of word document but it exists as an ExtendedPart. Have you any ideas how to make this work in chart updater?

DanielBailey1001001 commented 5 years ago

This may be a similar fix to #247, find this line of code and add your waterfall chart to the list: else if (chartType == C.doughnutChart || chartType == C.ofPieChart || chartType == C.pie3DChart || chartType == C.pieChart)

Here is the link to the similar pull request that adds a radar chart: https://github.com/OfficeDev/Open-Xml-PowerTools/pull/247/commits/f94542646a325332f7e5455da4426fc3ba4b7386

ahmet269 commented 5 years ago

Daniel thanks for the comment. This won’t work because the actual tags are different as well. Things like C.ser or C.f Xnames don’t work with waterfall charts because waterfall chart xml comes through with tag names cx:ser for example rather than c:ser.

I started to add code to handle these to chartupdater.cs so I am expanding it.

Just adding the chart type won’t work. Already tried that then I start to compare the xml and that’s when I realised it it different.

ahmet269 commented 5 years ago

I managed to fix this issue by changing the current chart updater class and introducing the handler for waterfall chart. Xml structure is completely different as the waterfall chart is not a chart part of the document but it is a extended part. plus the namespace ends in chartex and chart so it needed quite bit of changing to handle both current charts and extended parts as well. plus found some more issue in the chart updater class where if you had multiple series, it was only using the properties of the firts series, this means that any properties you apply to different series were getting lost. i managed to fix this as well.

tomjebo commented 5 years ago

Closing all issues as this repo is being archived and will no longer be maintained by Microsoft. The project is licensed for continued use and development by forking to your own repo.