Create pie charts in ODT documents in LibreOffice
The dataset below is used in a chart that represents the quantity of cheese purchased by french households in 2019.
Group values by cheese types using the following dataset:
ODT
template in LibreOfficeClick the Home tab > Chart button. A column chart appears. Change the chart format by clicking the chart type button from the chart toolbar.
Insert the data dynamically using a loop
and the bindChart
formatter: Click Data Table from the chart toolbar. A popup appears to edit chart values.
The following is not different than Microsoft Word. It's not possible to insert tag {d.value}
inside table cells, except in the first column Categories
.
So you write the category name, then add bindChart
tags. The {bindChart}
formatter is used to bind a variable to a reference tag in the table cell, i.e., "the value X
in the chart must be replaced by the tag Y
."
jn the first cell, the following expression is written: {d.cheeses[i].type} {bindChart(3)=d.cheeses[i].purchasedTonnes}
the cheese type is printed with {d.cheeses[i].type}
, then bindChart
is used to bind the variable d.cheeses[i].purchasedTonnes
to the cell that has the value 3
this means: the purchasedTonnes
value is printed instead of 3
in the first cell of the second row, the expression {d.cheeses[i+1].type} {bindChart(4)=d.cheeses[i+1].purchasedTonnes}
is written
the bindChart
replaces the 4
value by the d.cheeses[i+1].purchasedTonnes
variable
Generate the PDF
report, and the pie chart is automatically filled.