├── .styleci.yml
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE.md
├── README.md
├── codecov.yml
├── composer.json
├── examples
├── ExampleBarChart.php
├── ExampleDoughnutChart.php
├── ExampleLineChart.php
└── ExamplePieChart.php
├── resources
└── views
│ ├── chart_refresh.blade.php
│ └── tile.blade.php
└── src
├── ChartTileServiceProvider.php
├── Charts
└── Chart.php
├── Components
├── ChartComponent.php
└── ChartRefreshComponent.php
├── Contracts
└── ChartFactory.php
└── Factories
└── DefaultChartFactory.php
/.styleci.yml:
--------------------------------------------------------------------------------
1 | preset: laravel
2 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | All notable changes to `fidum/laravel-dashboard-chart-tile` will be documented in this file
4 |
5 | ## 6.2.0 - 2025-02-24
6 |
7 | ### What's Changed
8 |
9 | * Run tests on PHP 8.4 by @dmason30 in https://github.com/fidum/laravel-dashboard-chart-tile/pull/30
10 | * Adds Laravel 12.x Support by @dmason30 in https://github.com/fidum/laravel-dashboard-chart-tile/pull/31
11 |
12 | **Full Changelog**: https://github.com/fidum/laravel-dashboard-chart-tile/compare/6.1.0...6.2.0
13 |
14 | ## 6.1.0 - 2024-03-13
15 |
16 | ### What's Changed
17 |
18 | * Support Laravel 11 by @dmason30 in https://github.com/fidum/laravel-dashboard-chart-tile/pull/29
19 |
20 | **Full Changelog**: https://github.com/fidum/laravel-dashboard-chart-tile/compare/6.0.0...6.1.0
21 |
22 | ## 6.0.0 - 2023-12-02
23 |
24 | ### What's Changed
25 |
26 | * Run tests on PHP 8.3 by @dmason30 in https://github.com/fidum/laravel-dashboard-chart-tile/pull/26
27 | * Upgrade to Laravel Dashboard 3.x by @dmason30 in https://github.com/fidum/laravel-dashboard-chart-tile/pull/27
28 |
29 | **Full Changelog**: https://github.com/fidum/laravel-dashboard-chart-tile/compare/5.0.1...6.0.0
30 |
31 | ## 5.0.1 - 2023-02-08
32 |
33 | ### What's Changed
34 |
35 | - Add Laravel 10 support by @dmason30 in https://github.com/fidum/laravel-dashboard-chart-tile/pull/25
36 |
37 | **Full Changelog**: https://github.com/fidum/laravel-dashboard-chart-tile/compare/5.0.0...5.0.1
38 |
39 | ## 5.0.0 - 2022-08-19
40 |
41 | ### What's Changed
42 |
43 | - Revert to ConsoleTvs/Charts v6 by @dmason30 in https://github.com/fidum/laravel-dashboard-chart-tile/pull/24
44 |
45 | > If you're wondering what happened to the ConsoleTVs/Charts v7 version please read this: https://github.com/ConsoleTVs/Charts/issues/1#issuecomment-1208550258
46 |
47 | **Full Changelog**: https://github.com/fidum/laravel-dashboard-chart-tile/compare/4.1.0...5.0.0
48 |
49 | ## 4.1.0 - 2022-02-10
50 |
51 | ## What's Changed
52 |
53 | - Run tests in PHP 8.1 by @dmason30 in https://github.com/fidum/laravel-dashboard-chart-tile/pull/21
54 | - Add Laravel 9 Support by @dmason30 in https://github.com/fidum/laravel-dashboard-chart-tile/pull/22
55 |
56 | **Full Changelog**: https://github.com/fidum/laravel-dashboard-chart-tile/compare/4.0.1...4.1.0
57 |
58 | ## 4.0.1 - 2020-12-12
59 |
60 | **Added**
61 |
62 | - Added PHP 8 Support
63 |
64 | ## 4.0.0 - 2020-09-10
65 |
66 | **Added**
67 |
68 | - Added Laravel 8 Support
69 | - Added `spatie/laravel-dashboard` 2.0.0 support
70 |
71 | **Changed**
72 |
73 | - Updated `consoletvs/charts` to 7.1
74 |
75 | **Breaking**
76 |
77 | - Dropped Laravel 7 support
78 | - Dropped `spatie/laravel-dashboard` 1.x support
79 |
80 | ## 3.1.1 - 2020-07-17
81 |
82 | **Changed**
83 |
84 | - Switch to chartisan 2.1.* UMD build ([#12](https://github.com/fidum/laravel-dashboard-chart-tile/pull/12))
85 |
86 | ## 3.1.0 - 2020-07-17
87 |
88 | **Fixed**
89 |
90 | - Fix scripts getting the latest versions that contain breaking changes ([#11](https://github.com/fidum/laravel-dashboard-chart-tile/pull/11))
91 |
92 | ## 3.0.3 - 2020-07-06
93 |
94 | **Added**
95 |
96 | - Add support to use any frontend chart library ([#9](https://github.com/fidum/laravel-dashboard-chart-tile/pull/9))
97 |
98 | ## 3.0.2 - 2020-07-05
99 |
100 | **Fixed**
101 |
102 | - Chart API url was incorrectly escaped in view
103 |
104 | ## 3.0.1 - 2020-07-05
105 |
106 | **Fixed**
107 |
108 | - Move psalm dependencies to require-dev
109 |
110 | ## 3.0.0 - 2020-07-05
111 |
112 | **Breaking**
113 |
114 | - Changed to v7 of ConsoleTVs/Charts package. ([#7](https://github.com/fidum/laravel-dashboard-chart-tile/pull/7))
115 | - Changed `chartSettings` tile property name to `chartFilters`
116 |
117 | The v7 release of the Charts package was a complete rewrite. Therefore it was not possible to support this version and
118 | keep it backwards compatible. This has resulted in another breaking change and another major version.
119 |
120 | The `ChartFactory` interface no longer exists. All charts must now extend `Fidum\ChartTile\Charts\Chart` abstract class.
121 |
122 | See README for updated documentation.
123 |
124 | ## 2.0.0 - 2020-05-15
125 |
126 | **Added**
127 |
128 | - Add `chartSettings` tile property ([#3](https://github.com/fidum/laravel-dashboard-chart-tile/pull/3))
129 |
130 | **Breaking**
131 |
132 | - `Fidum\ChartTile\Contracts\ChartFactory::make` signature has changed to have the `array $settings` argument.
133 |
134 | ## 1.1.0 - 2020-05-15
135 |
136 | **Added**
137 |
138 | - Add `refreshIntervalInSeconds` tile property ([#2](https://github.com/fidum/laravel-dashboard-chart-tile/pull/2))
139 |
140 | ## 1.0.0 - 2020-05-14
141 |
142 | - initial release
143 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | Contributions are **welcome** and will be fully **credited**.
4 |
5 | Please read and understand the contribution guide before creating an issue or pull request.
6 |
7 | ## Etiquette
8 |
9 | This project is open source, and as such, the maintainers give their free time to build and maintain the source code
10 | held within. They make the code freely available in the hope that it will be of use to other developers. It would be
11 | extremely unfair for them to suffer abuse or anger for their hard work.
12 |
13 | Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
14 | world that developers are civilized and selfless people.
15 |
16 | It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
17 | quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.
18 |
19 | ## Viability
20 |
21 | When requesting or submitting new features, first consider whether it might be useful to others. Open
22 | source projects are used by many developers, who may have entirely different needs to your own. Think about
23 | whether or not your feature is likely to be used by other users of the project.
24 |
25 | ## Procedure
26 |
27 | Before filing an issue:
28 |
29 | - Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
30 | - Check to make sure your feature suggestion isn't already present within the project.
31 | - Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
32 | - Check the pull requests tab to ensure that the feature isn't already in progress.
33 |
34 | Before submitting a pull request:
35 |
36 | - Check the codebase to ensure that your feature doesn't already exist.
37 | - Check the pull requests to ensure that another person hasn't already submitted the feature or fix.
38 |
39 | ## Requirements
40 |
41 | If the project maintainer has any additional requirements, you will find them listed here.
42 |
43 | - **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - We automatically manage this in our CI so you don't need to worry about this too much when submitting your changes.
44 |
45 | - **Add tests!** - Your patch won't be accepted if it doesn't have tests.
46 |
47 | - **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
48 |
49 | - **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option.
50 |
51 | - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
52 |
53 | - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
54 |
55 | **Happy coding**!
56 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) Fidum
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Laravel Dashboard Charting Tile
2 |
3 | [](https://packagist.org/packages/fidum/laravel-dashboard-chart-tile)
4 | [](https://github.com/fidum/laravel-dashboard-chart-tile/actions?query=workflow%3Arun-tests+branch%3Amaster)
5 | [](https://codecov.io/gh/fidum/laravel-dashboard-chart-tile)
6 | [](https://twitter.com/danmasonmp)
7 |
8 | Show off your charting skills with this easy to use tile. Supports line, bar, pie, doughnut and many more!
9 |
10 | 
11 |
12 | ## Installation
13 |
14 | You can install the package via composer:
15 |
16 | ```bash
17 | composer require fidum/laravel-dashboard-chart-tile
18 | ```
19 |
20 | ## Usage
21 | In the `dashboard` config file, you can optionally add this configuration in the `tiles` key.
22 |
23 | ```php
24 | // in config/dashboard.php
25 | return [
26 | // ...
27 | 'tiles' => [
28 | 'charts' => [
29 | 'refresh_interval_in_seconds' => 300, // Default: 300 seconds (5 minutes)
30 | ],
31 | ],
32 | ];
33 | ```
34 | This tile uses `chart.js` to render the charts with the help of `Laravel Charts` package see links to
35 | documentation for both below:
36 |
37 | - [Laravel Charts Documentation](https://charts.erik.cat/)
38 | - [Chart.js Documentation](https://www.chartjs.org/docs/latest/charts/)
39 |
40 |
41 | So that you can easily add your datasets and configure your charts exactly how you want them you need to create
42 | a chart class that implements the `Fidum\ChartTile\Contracts\ChartFactory` interface.
43 |
44 | See chart example below:
45 |
46 | ```php
47 | namespace App\Charts;
48 |
49 | use Carbon\Carbon;
50 | use Fidum\ChartTile\Charts\Chart;
51 | use Fidum\ChartTile\Contracts\ChartFactory;
52 |
53 | class ExampleBarChart implements ChartFactory
54 | {
55 | public static function make(array $settings): ChartFactory
56 | {
57 | return new static;
58 | }
59 |
60 | public function chart(): Chart
61 | {
62 | $date = Carbon::now()->subMonth()->startOfDay();
63 |
64 | $data = collect(range(0, 12))->map(function ($days) use ($date) {
65 | return [
66 | 'x' => $date->clone()->addDays($days)->toDateString(),
67 | 'y' => rand(100, 500),
68 | ];
69 | });
70 |
71 | $chart = (new Chart)
72 | ->labels($data->pluck('x')->toArray())
73 | ->options([
74 | 'responsive' => true,
75 | 'maintainAspectRatio' => false,
76 | // etc...
77 | ], true);
78 |
79 | $chart->dataset('Example Data', 'bar', $data->toArray())
80 | ->backgroundColor('#848584');
81 |
82 | return $chart;
83 | }
84 | }
85 | ```
86 |
87 | In your dashboard view you can use the below component as many times as needed. Pass your chart class
88 | reference to the component and that will be used to generate the chart.
89 |
90 | ```blade
91 |