Create dynamic charts in Microsoft Word

Learn how to create line charts in DOCX/PDF documents in Microsoft Word

The dataset below is used in a chart that represents the weather temperature during a short period.

Step 1: Prepare JSON data

Group temperatures history by dates (minimum, maximum, average) using the following dataset:

{
  "temps": [
    {
      "date": "01/07/2022",
      "min": 13,
      "max": 28,
      "avg": 20.5
    },
    {
      "date": "02/07/2022",
      "min": 13,
      "max": 29,
      "avg": 21
    },
    {
      "date": "03/07/2022",
      "min": 14,
      "max": 31,
      "avg": 22.5
    },
    {
      "date": "04/07/2022",
      "min": 16,
      "max": 32,
      "avg": 24
    }
  ]
}

Step 2: Create a new DOCX template in Microsoft Word

Click the Insert tab > Chart menu > Line > 2D Line to insert a line chart.

As soon as the chart is created, Microsoft Word opens an Excel spreadsheet to edit charts values.

Step 3: Edit chart values

Delete default values, and insert temperature values by looping through the temps list.

After each loop expression that contains [i] in the first row, use the expression [i+1] in the next line.

Dynamic charts do not support only one [i+1] for multiple [i] expressions.

Step 4: Generate the report

Generate the PDF report, and the line chart is automatically filled.

Last updated