This plugin works upon filament and its core concepts. Some packages that need to be preinstalled are:
- laravel/laravel
- filament/filament
Consider taking a look at Laravel docs and Filament docs for more information.
- Clone the package into your project:
git clone https://github.com/tsetis/sunburst-chart.git
-
Move the sunburst-chart folder into the vendor/tsetis folder
-
Run the following command:
composer require tsetis/sunburst-chart="dev-main"
Run the following command to create a sunburst widget inside the App\Filament\Widgets folder with the {widget-name} in CamelCase:
php artisan make:sunburst-chart {widget-name}
After running the aforementioned command a class that extends SunburstChart class will be created. That class comes with a necessary method and 2 optional ones:
-
The getData method returns an
array
that contains the nesessary chart data. The minimum attributes that characterise each arc/node arename
andsize
(except for the root that does not need the size attribute). Except for the root, the rest of the nodes can optionally have achildren
attribute, as well, that correspondes to nested nodes (that is, extra chart rings/layers). Moreover, each node can also accept an optionalcolor
attribute.If the user wishes to customize the chart's colors, every node of the chart must have a color attribute that accepts a color name (e.g. pink, red). Considering that some colors may not be rendered, the user should consult the d3-color library that the project relies on. If not provided, each ring receives a random generated color.
An example of an array with data:
[ "name" => "root", "color" => "red", "children" => [ [ "name" => "a", "color" => "gray", "size" => 1 ], [ "name" => "b", "color" => "brown", "size" => 1, "children" => [ [ "name" => "ba", "color" => "purple", "size" => 1 ], [ "name" => "bb", "color" => "yellow", "size" => 1, "children" => [ [ "name" => "bba", "color" => "orange", "size" => 1 ], [ "name" => "bbb", "color" => "green", "size" => 1, ], [ "name" => "bbc", "color" => "blue", "size" => 1, ] ] ] ] ] ] ]
-
The getInfo() method accepts 3 sets of arguments, either the
string
name of the Chart, either an array of keys title and description withstring
values each or a (default)null
value.Scenarios:
- a default title and description are set with the given Chart name.
- the array with the given title and description values is set as is.
- a default title Sunburst Chart with no description is set.
-
The getCustomizationParameters() returns an array that contains key-value pairs of method_name and value. The methods provided are limited and correspond to the package of vasturiano/sunburst-chart. Respectively, the values each method receives are specific. When this method is used each method name (array index) is called with the given value (array value) as a parameter. If this method is not called, some methods and values are used by default for basic chart customization purposes.
Due to the complexity of each method, some may require more complex actions and structure than the one described above. Therefore, it is highly suggested to consult the package of vasturiano for more information.
The MIT License (MIT). Please see License File for more information.