unit == 'grams') { $data_array[] = round($label->quantity / 1000, 2); $labels[] = $label->name . ' (kg)'; } else { $data_array[] = $label->quantity; if ($label->unit == 'pieces') { $labels[] = $label->name . ' (Stück)'; } elseif ($label->unit == 'liter') { $labels[] = $label->name . ' (Liter)'; } else { $labels[] = $label->name . ' (' . ucfirst($label->unit) . ')'; } } } return [ 'chart' => [ 'type' => 'bar', 'height' => 300, ], 'series' => [ [ 'name' => 'BasicBarChart', 'data' => $data_array, ], ], 'xaxis' => [ 'categories' => $labels, 'labels' => [ 'style' => [ 'fontFamily' => 'inherit', ], ], ], 'yaxis' => [ 'labels' => [ 'style' => [ 'fontFamily' => 'inherit', ], ], ], 'colors' => ['#f59e0b'], 'plotOptions' => [ 'bar' => [ 'borderRadius' => 3, 'horizontal' => false, ], ], ]; } protected function extraJsOptions(): ?RawJs { return RawJs::make(<<<'JS' { xaxis: { labels: { formatter: function (val, timestamp, opts) { return val.replace('( ', '(') } } }, dataLabels: { enabled: true, formatter: function (val, opt) { return val+''+opt.w.globals.labels[opt.dataPointIndex].match(/\((.*?)\)/)[1] }, dropShadow: { enabled: true }, } } JS); } }