Updates a chart in a Word or Powerpoint document with the specified data.
Compatibility
The macro can be used in the highlighted input document types only. A greyed-out icon indicates not supported.
Usage
To update a specific chart, set it's unique ID (any text you like) in Word / Powerpoint in the Alt Text field and use the Id parameter to reference it. Supported chart types are: Area charts (Area, Stacked Area, 100% Stacked Area, 3-D Area, 3-D Stacked Area, 3-D 100% Stacked Area), Bar charts (Clustered Bar, Stacked Bar, 100% Stacked Bar, 3-D Clustered Bar, 3-D Stacked Bar, 3-D 100% Stacked Bar), Column charts (Clustered Column, Stacked Column, 100% Stacked Column, 3-D Clustered Column, 3-D Stacked Column, 3-D 100% Stacked Column, 3-D Column), Combo charts (various combinations of the other supported types MAY work, use with caution), Funnel charts (Funnel), Line charts (Line, Stacked Line, 100% Stacked Line, Line with Markers, Stacked Line with Markers, 100% Stacked Line with Markers, 3-D Line), Pie charts (Pie, 3-D Pie, Doughnut), Radar charts (Radar, Radar with Markers, Filled Radar).
Updates
Microsoft funnel charts are now supported in Word and PowerPoint. Set 'type' to Funnel and give the 'values' as category and value pairs, in the same way as for a pie chart. The chart keeps its own series name, and Edit Data shows the same figures afterwards. The other chart macros do not yet support funnel charts.
History (3)
The spreadsheet behind an updated chart is now written correctly, so you can still right-click the chart and choose Edit Data after a report has run. Previously the category names were written to invalid cells, which stopped the spreadsheet opening at all. The chart itself looked correct either way.
Doughnut and 3D pie charts now gain a data label for each extra data point, matching how pie charts already behaved. This applies only to charts that already carry an individual data label; charts without one are unchanged.
Now correctly populates the embedded XLSX data. Added more supported chart types.
Mandatory (1)
| Parameter | Type | Purpose | Options | Default |
| List<String> | The list of values, in the form: Series Name^Series Name^...;X-axis Label 1;Data^Data^...;X-axis Label 2;Data^Data^...For empty (non-rendered but occupying the right series space) values, simply omit the value but use the delimiter, e.g. X-axis Label 1;Data^^^Data... where the 2nd and 3rd data points are empty. For pie / doughnut / funnel charts, the format is: Category Name^Category Value;Category Name^Category Value;Category Name^Category Value... Pie, doughnut and funnel charts cannot use empty values (use 0 if you want to show the category in the legend, but with no value). NOTE: for all chart types except pie / doughnut / funnel charts, the series names must match the series names of those in the original data, i.e. you cannot change them using this macro (you can use the [Graph.RenameData:] macro to achieve that). For pie, doughnut and funnel charts, this macro works differently and simply overwrites the existing data. | N/A | N/A |
Behaviour (8)
| Parameter | Type | Presence | Purpose | Options | Default |
| List<ExecutionResult> | Optional | If specified, asserts the expected execution result of the macro. Accepts a single value or a semicolon-separated list of acceptable values (e.g. 'Success;Warning'). The macro executes normally; if the actual result matches any of the desired values, the result is converted to Success. If the actual result does not match, the result is converted to MacroError with a descriptive message. This is primarily used for testing and diagnostic purposes. Valid values are: 'Unknown', 'Success', 'MacroError', 'WorkerStopped', 'Running', 'Warning', 'NeverRun', 'Cancelled', 'Pending', 'Paused', 'SystemError', 'Deferred' and 'Stopped'. |
|
N/A | |
| Boolean | Optional | Should NCalc expression evaluation throw error on Overflow |
|
true | |
| String | Optional | If specified, asserts the expected output type of the macro result. The macro executes normally; if the actual type does not match, a macro error is generated. Requires 'storeAs', 'storeAsHidden', or 'storeFormattedValueAs' to be set for typed validation. Valid types include CLR names (e.g. Int32, Int64, Single, Double, Boolean, String, JArray, JObject) and C# keyword aliases (e.g. int, long, float, double, bool, string, uint, ulong, short, ushort, byte, sbyte, decimal, char, object). The special value 'Number' matches any numeric type. | N/A | N/A | |
| String | Optional | If specified, asserts the expected output value of the macro result. The macro executes normally; if the actual value does not match, a macro error is generated. When 'storeAs' or 'storeAsHidden' is set, the stored variable value is compared. Otherwise, the document output text is compared. | N/A | N/A | |
| String | Optional | The condition that must be true in order for the macro to be executed/evaluated. Must either evaluate to true or false, for example: "3+5=8" or "contains('abcd', 'z')". | N/A | true | |
| MacroMode | Optional | The mode in which variables are stored. In legacy mode (default for Schedules), the variable created is a string and formatted. In normal mode (default for Report Studio), the output variable is stored as a strongly-typed object, e.g. an Int32 or a JArray etc., rather than a formatted string. |
|
Legacy | |
| ObfuscationType | Optional | Obfuscation type. Use obfuscation to write reports where sensitive data is hidden. When used, ReportMagic guarantees that the same input string will map to the same output string for the whole of the report (but the next time the report runs, it will most likely map to a different value). If you use obfuscation, the property in your macro will not show up and instead, you will see a fake item of the obfuscation type chosen. |
|
None | |
| String | Optional | If specified, adds a warning message for this macro. This is processed as an NCalc, and the warning message will ALWAYS be present and will be the value of the evaluated NCalc expression. | N/A | N/A |
Output (3)
| Parameter | Type | Presence | Purpose | Options | Default |
| Char | Optional | The delimiter to use between each column in the input values. | N/A | ^ | |
| String | Optional | The text to display should the macro fail to execute. Note that a poorly-specified macro (e.g. omitting mandatory parameters) will still result in an error message. | N/A | N/A | |
| String | Optional | The name of a variable to create should the macro fail to execute. The variable will be a text variable, and will contain either the failure text (only if the failureText parameter is set), otherwise it will contain the exception / failure message. | N/A | N/A |
General (4)
| Parameter | Type | Presence | Purpose | Options | Default |
| List<String> | Mandatory | The list of values, in the form: Series Name^Series Name^...;X-axis Label 1;Data^Data^...;X-axis Label 2;Data^Data^...For empty (non-rendered but occupying the right series space) values, simply omit the value but use the delimiter, e.g. X-axis Label 1;Data^^^Data... where the 2nd and 3rd data points are empty. For pie / doughnut / funnel charts, the format is: Category Name^Category Value;Category Name^Category Value;Category Name^Category Value... Pie, doughnut and funnel charts cannot use empty values (use 0 if you want to show the category in the legend, but with no value). NOTE: for all chart types except pie / doughnut / funnel charts, the series names must match the series names of those in the original data, i.e. you cannot change them using this macro (you can use the [Graph.RenameData:] macro to achieve that). For pie, doughnut and funnel charts, this macro works differently and simply overwrites the existing data. | N/A | N/A | |
| String | Optional | Add a comment to make your document template more readable. The comment is discarded in the output document. | N/A | N/A | |
| String | Optional | The chart ID, which you can set in it's Alt Text (right-click a chart, then select 'Edit Alt Text'). If you set id=foobar in your macro, the alt text needs to be exactly "foobar" (no quotes). When not set: in Word the previous chart will be used, and in PowerPoint it will find the first 'previous' chart encountered. | N/A | N/A | |
| GraphUpdateType | Optional | The input chart type. Defaults to Bar, but if you use other types, you should set this accordingly. A funnel chart must be given as Funnel, because its values use the category and value format. |
|
Bar |
Examples (4)
Example 1
Update the previous bar chart (as no 'id' parameter is set'):
[Graph.Update: values=Routers^Switches^FWs^LBs;Jan^23^2.4^2^2;Feb^23^2.4^2^2]Example 2
Update the bar chart whose ID is 'Chart1'. The chart can be anywhere in the document:
[Graph.Update: id=Chart1, values=Routers^Switches^FWs^LBs;Jan^23^2.4^2^2;Feb^23^2.4^2^2]Example 3
Update the previous pie chart:
[Graph.Update: values=Routers^10;Switches^20;FWs^30, type=Pie]Example 4
Update the funnel chart whose ID is 'Pipeline'. The values are category and value pairs, largest first:
[Graph.Update: id=Pipeline, values=Prospects^500;Qualified^200;Quoted^80;Won^25, type=Funnel]