Charts

Home Forums WordprocessingML Charts

This topic contains 4 replies, has 2 voices, and was last updated by  riaan_badenhorst@hotmail.com 8 years, 6 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #3450

    Hi Eric

    Hope you’re doing well. I’ve got another question. I want to add charts into my docs based the xml input file that I’m using to populate the docx.

    I’ve seen the update embedded charts and chart update modules for the Powertools but the example are using static data. Is it possible to modify the examples to read the update values from the input xml? The chart data is not static so i need to get X/Y axis values from the XML.

    If so, should i then create a chart with the correct rows/columns and paste it, then try to find it via the paragraph, chart part, etc.

    And then somehow dynamically update the chart.

    It all sounds really complicated. I really just want to be able to drop a chart in, tag it as one would with <table select> and then document assembler populates the embedded sheet instead of a real one in the docx.

    Is this possible?

    #3457

    Eric White
    Keymaster

    Hi,

    Unfortunately, as you know, that is not a feature of DocumentAssembler. It is a great idea, though.

    I recommend the following approach –

    • Include a ‘template’ chart in your template document. You will need to identify this ‘template’ chart in some fashion. One approach that I have used successfully in the past is to insert a paragraph before the chart that contains a specific GUID.
    • Then produce the new document using DocumentAssembler.
    • Write some code that goes into the generated document, and finds the paragraph with the specific GUID.
    • Get your data for the chart in the form that ChartUpdater wants
    • Your code can then find the chart immediately following, and use ChartUpdater to update the data.

    I have added this idea to my list of requested enhancements for DocumentAssembler. But I do not have a schedule for this. Probably not soon, given my current committments.

    Cheers, Eric

    #3464

    Hi Eric

    Thanks for the reply. Since i wrote yesterday I started to modify the ChartUpdater. I can now read my xml and grab the data that I want and put it in the various string arrays (SeriesNames,CategoryNames, Values) required for a chart. The update of the example charts supplied with PowerTools works well.

    I’m now trying to incorporate it into the document i create with document assembler. So what I’ve done is place your sample chart in my template. As far as I can see if just looks for Chart1 tag (need to test that still).

    i’m bit confused about the files being copied from “../../” to the Temp folder, and then the updated chart file is created there (from the copy). Why copy to temp and then create another file as well?

    I’m also facing an issue where the my data doesn’t always have the same amount of values in each series.

    So far so good.

    #3465

    Eric White
    Keymaster

    The answer to your question about why files are copied from “../../” to the Temp folder, and then the updated chart file is created there from the copy is very simple. I do that with almost all my examples, so that when I am manually validating the correct functionality, both the ‘before’ and ‘after’ files are in one location, for my own ease of opening them and seeing if the code worked properly.

    I’m happy you are able to modify the ChartUpdater to get the results you want. In one way, this is the main intention behind the code – to show the basic plumbing of how to do it, and then you can modify as appropriate for your scenario.

    #3466

    Thanks for the explanation!

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.