{"id":18499754,"url":"https://github.com/s1syphos/kirby3-charts","last_synced_at":"2025-05-14T06:30:34.670Z","repository":{"id":62507949,"uuid":"502130255","full_name":"S1SYPHOS/kirby3-charts","owner":"S1SYPHOS","description":"SVG charts for Kirby v3","archived":false,"fork":false,"pushed_at":"2022-06-10T17:40:14.000Z","size":2156,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-17T01:26:00.788Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/S1SYPHOS.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-10T17:39:45.000Z","updated_at":"2022-06-10T17:40:35.000Z","dependencies_parsed_at":"2022-11-02T13:00:24.800Z","dependency_job_id":null,"html_url":"https://github.com/S1SYPHOS/kirby3-charts","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/S1SYPHOS%2Fkirby3-charts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/S1SYPHOS%2Fkirby3-charts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/S1SYPHOS%2Fkirby3-charts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/S1SYPHOS%2Fkirby3-charts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/S1SYPHOS","download_url":"https://codeload.github.com/S1SYPHOS/kirby3-charts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254084611,"owners_count":22011908,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T13:47:12.730Z","updated_at":"2025-05-14T06:30:34.635Z","avatar_url":"https://github.com/S1SYPHOS.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kirby3-charts\n[![Build](https://ci.codeberg.org/api/badges/Fundevogel/kirby3-charts/status.svg)](https://codeberg.org/Fundevogel/kirby3-charts/issues)\n\nA Kirby v3 plugin for creating SVG charts - batteries included.\n\n\n## What\n\n`kirby3-charts` is a Kirby v3 wrapper for [`SVGGraph`](https://github.com/goat1000/SVGGraph), as such there are (almost) no limits to what kind of chart may be created.\n\n\n## How\n\nInstall this package with [Composer](https://getcomposer.org):\n\n```text\ncomposer require fundevogel/kirby3-charts\n```\n\n\n### Usage\n\nIn order to generate a chart, we need some data first. The page method `toChart()` accepts an array of data points as first argument - basically two or more arrays, each of which consists of `color` (string) and `share` (float):\n\n```php\n$data = [\n    ['title' =\u003e 'HTML', 'color' =\u003e '#4F5D95', 'share' =\u003e 0.6],\n    ['title' =\u003e 'CSS', 'color' =\u003e '#2b7489', 'share' =\u003e 0.4],\n];\n\n$page-\u003etoChart($data);\n```\n\nThere's also a field method `toChart()` suitable for structure fields. The included example blueprint `fields/chart` is a good starting point \u0026 looks basically like this:\n\n```yaml\ntype: structure\nfields:\n  title:\n    label: Title\n    type: text\n\n  share:\n    label: share\n    type: number\n    step: .01\n\n  color:\n    label: Color\n    type: text\n```\n\nBoth methods take another two arrays for further customization:\n\n```php\n# SVG settings\n$settings = [\n    'width' =\u003e 100,\n    'height' =\u003e 100,\n    'type' =\u003e 'DonutGraph',\n    'inline' =\u003e false,\n];\n\n# Options depend on the type of chart (in this example 'DonutGraph'),\n# see https://www.goat1000.com/svggraph.php\n$options = [\n    'inner_radius' =\u003e 2,\n    'stroke_width' =\u003e 0.5,\n    'show_labels' =\u003e true,\n\n    # .. etc\n];\n\n# Page method\n$page-\u003etoChart($data, $settings, $options);\n\n# Field method\n$page-\u003echartData()-\u003etoChart($settings, $options);\n```\n\n**Note**: Both methods return a file object of the newly created SVG chart (unless `inline` is activated) for further use.\n\n\n### Configuration\n\nYou may also change certain fallback options from your `config.php` globally (`'fundevogel.charts.optionName'`):\n\n| Option        | Type   | Default      | Description                        |\n| ------------- | ------ | ------------ | ---------------------------------- |\n| `'type'`      | string | `DonutGraph` | Default chart type to be created   |\n| `'template'`  | string | `chart`      | Default file template              |\n| `'width'`     | int    | `100`        | SVG canvas width                   |\n| `'height'`    | int    | `100`        | SVG canvas height                  |\n| `'precision'` | int    | `2`          | Rounding precision (`-1` = off)    |\n| `'inline'`    | bool   | `false`      | Return SVG string insead of `File` |\n\n\n### Example\n\n```php\n# Create SVG chart as page file\n$chart = $page-\u003etoChart($data, ['type' =\u003e 'DonutGraph'], [\n    'donut_slice_gap' =\u003e 1.5,\n    'inner_radius' =\u003e 0.7,\n    'start_angle'  =\u003e -90,\n    'stroke_width' =\u003e 0,\n]);\n```\n\nAdding more items to the example `$data` from before and using above code, the generated chart looks like this:\n\n![Chart](example.svg)\n\n\n## Credits\n\nThis library is powered by `SVGGraph`, an extensive library for creating SVG charts, written by [goat1000](https://www.goat1000.com).\n\n\n## License\n\n`kirby3-charts` is licensed under the [MIT License](LICENSE), but **using Kirby in production** requires you to [buy a license](https://getkirby.com/buy).\n\n\n**Happy coding!**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs1syphos%2Fkirby3-charts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fs1syphos%2Fkirby3-charts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs1syphos%2Fkirby3-charts/lists"}