Adding data labels to bar charts

日本語のページ

You can add data labels to individual bars in a bar chart to display individual values.

Example of adding data labels to a bar chart

1. Add a data label block

After the block that creates the bar chart, add the "Add data labels to a bar chart" block.

Add data labels to a bar chart

Then, set the first parameter according to the type of bar chart.

You can also add data labels to bar charts with multiple series and stacked bar charts.

In the loop, add a block for "Add data labels to bar chart" after the block that creates the bar chart.

2. Set the position of the data label

The "X position" and "Y position" parameters specify where on the bar the data label should be displayed.
The relationship between the values ​​specified for each parameter and the position where the label is displayed is as shown in the figure below (the label is displayed at the ● position).

The relationship between the values ​​specified for the X position/Y position parameters and the position where the label is displayed

3. Setting the alignment of the data label

The "X alignment" and "Y alignment" parameters specify how to alignment the text based on the position determined by "X position" and "Y position".
The relationship between the values ​​specified for each parameter and the reference point (position of the ●) and the label alignment is as shown in the figure below.

The relationship between the values ​​specified for the X alignment/Y alignment parameters and the reference point and label alignment

4. Other settings

By specifying the "X offset" and "Y offset" parameters, you can display the data label slightly shifted up, down, left, or right from the reference point.
The value is in pixels.
If you specify a positive value, the data label will shift to the right in the X direction and up in the Y direction.
If you specify a negative value, it will shift in the opposite direction.

You can also rotate the text by specifying the "orientation (degrees)" parameter.
0 degrees will make it horizontal, and a positive value will rotate it counterclockwise.

5. Examples

We will introduce examples of adding data labels to bar charts with only one series and bar charts with multiple series.

5-1. Bar chart with only one series

The following program is an example of displaying a bar chart like the one at the top of this page.

This program can be downloaded from here.
To run this program, download this file and open it in Excel.

Example of a program to add data labels to a bar chart

The X position is the center and the Y position is the top, so the center of the line at the top of the bar is the reference point for the label.
Also, because the X alignment is centered and the Y alignment is top-justified, the left and right positions of the labels are the same as the reference point, and the top and bottom positions are above the reference point.

5-2. Bar charts with multiple series

The following program is an example of adding data labels to a bar chart with multiple series.
This program can be downloaded from here.
When running this program, download this file and open it in Excel.

Program to add data labels to bar charts with multiple series

The result of running this program is as follows.
The X position/Y position and X placement/Y placement are all centered, so the data labels are displayed in the center of each bar.

Execution result of an example where data labels are added to a bar chart with multiple series