Custom Page - Bar Graph Colors

ChrisG

Member

Your current DaDaBIK version​

You are using DaDaBIK version 13.4-Levanto enterprise, installed on 03-19-2026 (installation code: 688552cc613a1c6b6), the latest version of DaDaBIK is 13.4-Levanto released on 03-18-2026

You are running the latest release of DaDaBIK

In case you want to upgrade to a more powerful edition (from Pro to Enterprise/Platinum, from Enterprise to Platinum) please contact us.

System info​

PHP Version: 8.4.19

mysql version: 10.11.15-MariaDB

Web server: Apache/2.4.63 (Rocky Linux) OpenSSL/3.5.1

Client: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36


I have several Custom Dashboards that use bar graphs. I have noticed that all bar graphs are blue in my instance. Is there a way to easily make them alternate colors or to choose what colors to use?

This is an example of one of the graphs. Each Custom Page has several graphs.
Screenshot 2026-03-26 094547.png
 

eugenio

Administrator
Staff member
Hi Chris,
DaDaBIK uses chart.js to generate charts. I should definitely add some configuration parameters for colors and other settings, this is in my todo list already; currently the only easy way for you is to change the code in the file
/include/forms/generate_report_output.php

Search for this line

JavaScript:
data.datasets[0].backgroundColor = ['#365e96'];

this is the color for bar charts, you can change it with any other color or a combination of colors, e.g.

JavaScript:
data.datasets[0].backgroundColor = ['#365e96','#f00'];

alternates blue and red.

When you upgrade DaDaBIK, this file will be replaced, though.

Best,
 

ChrisG

Member
Well, that did not work for me. Nothing changed. All still blue.

/include/forms/generate_report_output.php

I changed from:
data.datasets[0].backgroundColor = ['#365e96'];

I changed to:
<?php if ( $report_type === 'bar'){ ?>
data.datasets[0].backgroundColor = '#365e96','#993333','#336666','#5A4E8C','#3C7A89';
<?php } ?>
 

ChrisG

Member
Yes, sorry. After adding brackets, it works perfectly.

<?php if ( $report_type === 'bar'){ ?>
data.datasets[0].backgroundColor = ['#365e96','#993333','#336666','#5A4E8C','#3C7A89'];
<?php } ?>
 

eugenio

Administrator
Staff member
The new configuration parameter $barchart_bin_colors (available in v13.5, released yesterday) allows to set a color (or a palette of colors) to use for the bins of bar charts.
 
Top