ChartBoy

Make rich, meaningful charts through PHP via charts.css in a snap!

View the Project on GitHub wolfgangs-code/ChartBoy

ChartBoy DocumentationBoy

Installation

Composer

composer require wolfgang-degroot/chartboy

Linking to charts.css easily via ChartBoy

charts.css can be linked to via the function ChartBoy\linkStyle(location);, where ‘location’ is a string.

Clarification: If you are using any other method or have already linked to charts.css elsewhere in your head, this function is redundant.

Usage

Creating a new chart

$chart = new ChartBoy\ChartBoy($arrayOfData);

You may also optionally set the type if not bar, primary and data axis labels, as well as the caption while creating a new chart.

$chart = new ChartBoy\ChartBoy($arrayOfData, "column", "Foo", "Bar", "How Much 'Foo' per 'Bar'?");

Rendering your chart

Rendering is done through the renderChart method. While optional, you may use a string as an argument to give the chart an id in its HTML.

Using a div as a wrapper:

<div><?=$chart->renderChart("optional-id");?></div>

Modifying your chart

Methods

charts.css Settings

To change a setting, use the changeSetting(key, value = true) method, where ‘key’ is the setting and ‘value’ is the value, e.g. true, false, or an integer. A full list and data type compatability table can be found here. For variable rules, the ‘*’ is entered verbatim will be replaced with the value- If none is specified, defaults to 1.

Custom charts.css-based Settings


by Wolfgang de Groot, 2021
MIT License