barchart()

The function barchart() inserts a bar chart into a report.

ReportElement barchart(array data, [array settings])

Usage

Use barchart() within a box() to specify the size of the chart.

$data = [
  'Apples' => 800,
  'Pears' => 1200,
  'Clementines' => 1100,
  'Dates' => 1800,
  'Strawberries' => 900,
  'Figs' => 1400
];
 
add(
    box([
        'height' => 60,
        'width' => 120
        ],
        barchart(
            $data,
            [
                'ref.value' => 1000,
                'ref.color' => '#00CC00',
                'ref.label' => 'Reference value',
                'color.bars' => '#6666FF',
                'color.values' => '#FFFFFF',
            ]
        )
    )
);

Output of the bar chart in the PDF