Chart Series Coloring in Word Processing Document

Chart Series Coloring in Word Processing Document

Creating a Column Chart

Practising the following steps, you can insert a Column Chart in MS Word 2013:

  1. Click in the document where you want to insert the chart, click the “Insert” tab, and then click “Chart” in the illustrations group to open the “Insert Chart” dialog box
  2. Select “Column” in the sidebar, you will see a gallery of charts
  3. Select the “100% Stacked Column” and press “OK” to insert the chart and Worksheet template to your document
  4. Edit the Worksheet with your data to update the chart. See Chart Data (Excel).
  5. Save your Document

Reporting Requirement

As a report developer, you are required to share contract price by manager dynamically with the following key requirements:

  • The report must show the  name of the manager
  • The report must show the total contract price for each manager 
  • Series color to be used in chart series 
  • The Report must be generated in the Word Processing Document

Adding Syntax to be evaluated by GroupDocs.Assembly Engine

Chart Title

<Total Contract Prices by Managers<<foreach [m in
managers]>><<x [m.Manager]>>

Chart Data (Excel)

 Total Contract Price«y [m.Total_Contract_Price]»«seriesColor [color]»
Category 14.3
Category 22.5
Category 33.5
Category 44.5

Download Template

Please download the sample Dynamic Chart Series Color document we created in this article:

Generating The Report

For a chart with dynamic data, you can set colors of chart series dynamically based upon expressions. To use the feature, do the following steps:

  • Declare a chart with dynamic data in the usual way

  • For chart series to be colored dynamically, define corresponding color expressions in names of these series using seriesColor tags having the following syntax:

    <<seriesColor [color_expression]>>
    

A color expression must return a value of one of the following types:

  • A string containing the name of a known color, that is, the case-insensitive name of a member of the KnownColor enumeration such as “red”
  • An integer value defining RGB (red, green, blue) components of the color such as 0xFFFF00 (yellow)
  • A value of the Color type

Following code snippet generates the report:

© Aspose Pty Ltd 2001-2022. All Rights Reserved.