beastbytes / mermaid-pie-chart
PHP for Mermaid.js pie charts
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/beastbytes/mermaid-pie-chart
Requires
- php: ^8.3
- beastbytes/mermaid: dev-master
Requires (Dev)
- pestphp/pest: ^4.0
- vimeo/psalm: ^6.0
This package is auto-updated.
Last update: 2025-12-29 16:20:09 UTC
README
PHP for Mermaid.js pie charts.
For license information see the LICENSE file.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist beastbytes/mermaid-pie-chart
or add
"beastbytes/mermaid-pie-chart": "{{versionConstraint}}"
to the require section of your composer.json.
Usage
- Create a PieChart instance using the
Mermaid::create()method - Configure the chart
- Render the chart
Example
/** @var array<string, float|int> $values */ echo Mermaid::create(PieChart::class) ->withValues($values) ->render() ;
API
PieChart
PieChart represents a pie chart.
addValues()
Returns a new instance of PieChart with the given values added to any existing values.
Note: New values with the same name as existing values will overwrite the existing values.
Parameters
| Name | Type | Description |
|---|---|---|
| values | array<string, float|int> | Array of name => value pairs |
| Return Type: PieChart |
render()
Returns a string that is the Mermaid Pie Chart wrapped in a HTML <pre class="mermaid"> tag.
Parameters
| Name | Type | Description |
|---|---|---|
| attributes | array<string, string> | Array of attribute => value pairs |
Note: The mermaid class is always added. |
Return Type: string
showData()
Returns a new instance of PieChart with showData set. The rendered Pie Chart will show values after the legend text.
Return Type: PieChart
withComment()
Returns a new instance of PieChart with a comment.
Parameters
| Name | Type | Description |
|---|---|---|
| comment | string | The comment |
| Return Type: PieChart |
withTitle()
Returns a new instance of PieChart with a title.
Parameters
| Name | Type | Description |
|---|---|---|
| title | string | The title |
| Return Type: PieChart |
withValues()
Returns a new instance of PieChart with the given values.
Parameters
| Name | Type | Description |
|---|---|---|
| values | array<string, float|int> | Array of name => value pairs |
| Return Type: PieChart |