├── .github
└── workflows
│ └── main.yml
├── .gitignore
├── .idea
├── .gitignore
├── codeStyles
│ └── codeStyleConfig.xml
├── composerJson.xml
├── larapex-charts.iml
├── misc.xml
├── modules.xml
├── php-test-framework.xml
├── php.xml
└── vcs.xml
├── .phpunit.cache
└── test-results
├── .vscode
└── settings.json
├── LICENSE.md
├── README.md
├── build
└── report.junit.xml
├── composer.json
├── config
└── larapex-charts.php
├── phpunit.xml.dist
├── phpunit.xml.dist.bak
├── src
├── AreaChart.php
├── BarChart.php
├── Console
│ └── ChartMakeCommand.php
├── Contracts
│ ├── MustAddComplexData.php
│ └── MustAddSimpleData.php
├── DonutChart.php
├── Facades
│ └── LarapexChart.php
├── HeatMapChart.php
├── HorizontalBar.php
├── LarapexChart.php
├── LarapexChartsServiceProvider.php
├── LineChart.php
├── PieChart.php
├── PolarAreaChart.php
├── RadarChart.php
├── RadialChart.php
├── Traits
│ ├── ComplexChartDataAggregator.php
│ ├── HasOptions.php
│ ├── SimpleChartDataAggregator.php
│ └── WithModelStub.php
└── stubs
│ └── charts
│ ├── Default
│ ├── AreaChart.stub
│ ├── BarChart.stub
│ ├── DonutChart.stub
│ ├── HeatMapChart.stub
│ ├── HorizontalBarChart.stub
│ ├── LineChart.stub
│ ├── PieChart.stub
│ ├── PolarAreaChart.stub
│ ├── RadarChart.stub
│ └── RadialBarChart.stub
│ ├── Json
│ ├── AreaChart.stub
│ ├── BarChart.stub
│ ├── DonutChart.stub
│ ├── HeatMapChart.stub
│ ├── HorizontalBarChart.stub
│ ├── LineChart.stub
│ ├── PieChart.stub
│ ├── PolarAreaChart.stub
│ ├── RadarChart.stub
│ └── RadialBarChart.stub
│ └── Vue
│ ├── AreaChart.stub
│ ├── BarChart.stub
│ ├── DonutChart.stub
│ ├── HeatMapChart.stub
│ ├── HorizontalBarChart.stub
│ ├── LineChart.stub
│ ├── PieChart.stub
│ ├── PolarAreaChart.stub
│ ├── RadarChart.stub
│ └── RadialBarChart.stub
├── stubs
├── public
│ └── apexcharts.js
├── resources
│ └── views
│ │ └── chart
│ │ ├── container.blade.php
│ │ └── script.blade.php
└── stubs
│ └── charts
│ ├── Default
│ ├── AreaChart.stub
│ ├── BarChart.stub
│ ├── DonutChart.stub
│ ├── HeatMapChart.stub
│ ├── HorizontalBarChart.stub
│ ├── LineChart.stub
│ ├── PieChart.stub
│ ├── PolarAreaChart.stub
│ ├── RadarChart.stub
│ └── RadialBarChart.stub
│ ├── Json
│ ├── AreaChart.stub
│ ├── BarChart.stub
│ ├── DonutChart.stub
│ ├── HeatMapChart.stub
│ ├── HorizontalBarChart.stub
│ ├── LineChart.stub
│ ├── PieChart.stub
│ ├── PolarAreaChart.stub
│ ├── RadarChart.stub
│ └── RadialBarChart.stub
│ └── Vue
│ ├── AreaChart.stub
│ ├── BarChart.stub
│ ├── DonutChart.stub
│ ├── HeatMapChart.stub
│ ├── HorizontalBarChart.stub
│ ├── LineChart.stub
│ ├── PieChart.stub
│ ├── PolarAreaChart.stub
│ ├── RadarChart.stub
│ └── RadialBarChart.stub
└── tests
├── Feature
└── ChartsTest.php
├── TestCase.php
└── Unit
└── ChartsTest.php
/.github/workflows/main.yml:
--------------------------------------------------------------------------------
1 | name: run-tests
2 |
3 | on:
4 | push:
5 | branches: [master]
6 | pull_request:
7 | branches: [master]
8 |
9 | jobs:
10 | test:
11 | runs-on: ${{ matrix.os }}
12 | strategy:
13 | fail-fast: true
14 | matrix:
15 | os: [ubuntu-latest, windows-latest]
16 | php: [7.4, 8.0]
17 | laravel: [8.*]
18 | stability: [prefer-stable]
19 | include:
20 | - laravel: 8.*
21 | testbench: ^6.6
22 |
23 | name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
24 |
25 | steps:
26 | - name: Checkout code
27 | uses: actions/checkout@v2
28 |
29 | - name: Setup PHP
30 | uses: shivammathur/setup-php@v2
31 | with:
32 | php-version: ${{ matrix.php }}
33 | extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
34 | coverage: none
35 |
36 | - name: Setup problem matchers
37 | run: |
38 | echo "::add-matcher::${{ runner.tool_cache }}/php.json"
39 | echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
40 | - name: Install dependencies
41 | run: |
42 | composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
43 | composer update --${{ matrix.stability }} --prefer-dist --no-interaction
44 | - name: Execute tests
45 | run: vendor/bin/phpunit
46 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | vendor
2 | composer.lock
3 | .phpunit.result.cache
4 | coverage
5 | .idea
6 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /workspace.xml
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/composerJson.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/larapex-charts.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/php-test-framework.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/php.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.phpunit.cache/test-results:
--------------------------------------------------------------------------------
1 | {"version":1,"defects":[],"times":{"ArielMejiaDev\\LarapexCharts\\Tests\\Feature\\ChartsTest::it_tests_larapex_charts_can_render_bar_charts":0,"ArielMejiaDev\\LarapexCharts\\Tests\\Feature\\ChartsTest::it_tests_larapex_charts_can_render_pie_chart":0,"ArielMejiaDev\\LarapexCharts\\Tests\\Feature\\ChartsTest::it_tests_larapex_charts_can_render_heatmap_chart":0,"ArielMejiaDev\\LarapexCharts\\Tests\\Feature\\ChartsTest::it_tests_larapex_charts_can_create_an_area_chart":0,"ArielMejiaDev\\LarapexCharts\\Tests\\Feature\\ChartsTest::it_tests_larapex_charts_can_render_horizontal_bar_chart":0.001,"ArielMejiaDev\\LarapexCharts\\Tests\\Feature\\ChartsTest::it_tests_larapex_charts_can_render_stacked_bar_chart":0,"ArielMejiaDev\\LarapexCharts\\Tests\\Feature\\ChartsTest::larapex_can_render_line_charts":0,"ArielMejiaDev\\LarapexCharts\\Tests\\Feature\\ChartsTest::it_tests_larapex_charts_can_render_polar_chart":0,"ArielMejiaDev\\LarapexCharts\\Tests\\Feature\\ChartsTest::it_tests_larapex_charts_can_render_pie_charts_by_default":0,"ArielMejiaDev\\LarapexCharts\\Tests\\Feature\\ChartsTest::it_tests_larapex_charts_can_render_donut_chart":0,"ArielMejiaDev\\LarapexCharts\\Tests\\Feature\\ChartsTest::it_tests_larapex_can_render_radial_bar_charts":0,"ArielMejiaDev\\LarapexCharts\\Tests\\Feature\\ChartsTest::it_tests_larapex_charts_can_render_radar_chart":0,"ArielMejiaDev\\LarapexCharts\\Tests\\Unit\\ChartsTest::it_tests_larapex_charts_can_load_script_correctly":0.019,"ArielMejiaDev\\LarapexCharts\\Tests\\Unit\\ChartsTest::it_tests_larapex_charts_can_change_default_config_colors":0.001,"ArielMejiaDev\\LarapexCharts\\Tests\\Unit\\ChartsTest::it_tests_larapex_chart_cdn_returns_a_correct_url":0,"ArielMejiaDev\\LarapexCharts\\Tests\\Unit\\ChartsTest::it_tests_larapex_charts_install_add_chart_stubs":0.04}}
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "nuxt.isNuxtApp": false
3 | }
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) [2020] [Ariel Mejia]
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 all
13 | 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 THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Larapex Charts
2 |
3 |
4 |
5 | [](https://madewithlaravel.com/p/larapex-charts/shield-link)
6 |
7 | [](https://packagist.org/packages/arielmejiadev/larapex-charts)
8 |
9 | [](https://packagist.org/packages/arielmejiadev/larapex-charts)
10 |
11 | 
12 |
13 | [](https://packagist.org/packages/arielmejiadev/larapex-charts)
14 |
15 |
16 |
17 | A Laravel wrapper for apex charts library Check the documentation on: [Larapex Chart Docs](https://larapex-charts.netlify.app/).
18 |
19 | ## Installation
20 |
21 | Use composer.
22 |
23 | ```bash
24 | composer require arielmejiadev/larapex-charts
25 | ```
26 |
27 | ## Usage
28 |
29 | ### Basic example
30 |
31 | In your controller add:
32 |
33 | ```php
34 | $chart = (new LarapexChart)->setTitle('Posts')
35 | ->setDataset([150, 120])
36 | ->setLabels(['Published', 'No Published']);
37 |
38 | ```
39 |
40 | Remember to import the Facade to your controller with
41 |
42 | ```php
43 | use ArielMejiaDev\LarapexCharts\Facades\LarapexChart;
44 | ```
45 |
46 | Or importing the LarapexChart class:
47 |
48 | ```php
49 | use ArielMejiaDev\LarapexCharts\LarapexChart;
50 | ```
51 |
52 | Then in your view (Blade file) add:
53 |
54 | ```php
55 |
56 |
57 |
58 |
59 |
61 |
62 | Chart Sample
63 |
64 |
65 |
66 | {!! $chart->container() !!}
67 |
68 |
69 |
70 | {{ $chart->script() }}
71 |
72 |
73 | ```
74 |
75 | ### More complex example
76 |
77 | ```php
78 | $chart = (new LarapexChart)->setType('area')
79 | ->setTitle('Total Users Monthly')
80 | ->setSubtitle('From January to March')
81 | ->setXAxis([
82 | 'Jan', 'Feb', 'Mar'
83 | ])
84 | ->setDataset([
85 | [
86 | 'name' => 'Active Users',
87 | 'data' => [250, 700, 1200]
88 | ]
89 | ]);
90 | ```
91 |
92 | You can create a variety of charts including: Line, Area, Bar, Horizontal Bar, Heatmap, pie, donut and Radialbar.
93 |
94 | ## More examples
95 |
96 | Check the documentation on: [Larapex Chart Docs](https://larapex-charts.netlify.app/)
97 |
98 | ## Contributing
99 |
100 | The author Ariel Mejia Dev.
101 |
102 | ## License
103 | [MIT](./LICENSE.md)
104 |
105 | ## Support the project
106 |
107 | Hey 👋 thanks for considering making a donation, with these donations I can continue working to contribute to opensource projects.
108 |
109 |
110 |
111 |
112 |
113 | ## Roadmap for future versions
114 |
115 | - [ ] Add blade directive `@apexchartscdn`
116 | - [ ] Add blade directive `@script($chart)`
117 | - [ ] Add a chain options setter for charts
118 | - [ ] Update Github Actions to run tests
119 | - [ ] Update the package in general for more efficient & modern practices (spatie skeleton package)
120 | - [ ] Add ReactJS + Inertia Support
121 | - [ ] Add More complex charts
122 | - [ ] Add More complex boilerplate code using Laravel/Prompts
123 | - [ ] Add more complex boilerplate code examples using Laravel Trends Package
124 |
--------------------------------------------------------------------------------
/build/report.junit.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "arielmejiadev/larapex-charts",
3 | "description": "Package to provide easy api to build apex charts on Laravel",
4 | "keywords": [
5 | "arielmejiadev",
6 | "larapex",
7 | "charts",
8 | "apexcharts"
9 | ],
10 | "homepage": "https://larapex-charts.netlify.app/",
11 | "license": "MIT",
12 | "type": "library",
13 | "authors": [
14 | {
15 | "name": "ArielMejiaDev",
16 | "email": "arielmejiadev@gmail.com"
17 | }
18 | ],
19 | "require": {
20 | "php": "^8.0|^8.2",
21 | "illuminate/support": "^9.0|^10.0|^11.0",
22 | "ext-json": "*"
23 | },
24 | "require-dev": {
25 | "orchestra/testbench": "^7.0|^8.0",
26 | "phpunit/phpunit": "^9.0|^10.0",
27 | "nunomaduro/collision": "^7.5"
28 | },
29 | "autoload": {
30 | "psr-4": {
31 | "ArielMejiaDev\\LarapexCharts\\": "src"
32 | }
33 | },
34 | "autoload-dev": {
35 | "psr-4": {
36 | "ArielMejiaDev\\LarapexCharts\\Tests\\": "tests"
37 | }
38 | },
39 | "scripts": {
40 | "test": "vendor/bin/phpunit",
41 | "test-coverage": "vendor/bin/phpunit --coverage-html coverage"
42 | },
43 | "extra": {
44 | "laravel": {
45 | "providers": [
46 | "ArielMejiaDev\\LarapexCharts\\LarapexChartsServiceProvider"
47 | ],
48 | "aliases": {
49 | "LarapexChart": "ArielMejiaDev\\LarapexCharts\\Facades\\LarapexChart"
50 | }
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/config/larapex-charts.php:
--------------------------------------------------------------------------------
1 | 'Helvetica, Arial, sans-serif',
15 |
16 | 'font_color' => '#373d3f',
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Default Colors for datasets
21 | |--------------------------------------------------------------------------
22 | |
23 | | Here you may specify which hexadecimal colors below you wish
24 | | to use as your default colors palette in that order.
25 | |
26 | */
27 |
28 | 'colors' => [
29 | '#008FFB', '#00E396', '#feb019', '#ff455f', '#775dd0', '#80effe',
30 | '#0077B5', '#ff6384', '#c9cbcf', '#0057ff', '#00a9f4', '#2ccdc9', '#5e72e4'
31 | ]
32 | ];
33 |
--------------------------------------------------------------------------------
/phpunit.xml.dist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | tests
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | ./src
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/phpunit.xml.dist.bak:
--------------------------------------------------------------------------------
1 |
2 |
18 |
19 |
20 | tests
21 |
22 |
23 |
24 |
25 | ./src
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/src/AreaChart.php:
--------------------------------------------------------------------------------
1 | type = 'area';
16 | }
17 |
18 | public function addArea(string $name, array $data) :AreaChart
19 | {
20 | return $this->addData($name, $data);
21 | }
22 | }
--------------------------------------------------------------------------------
/src/BarChart.php:
--------------------------------------------------------------------------------
1 | type = 'bar';
16 | }
17 |
18 | public function addBar(string $name, array $data) :BarChart
19 | {
20 | return $this->addData($name, $data);
21 | }
22 | }
--------------------------------------------------------------------------------
/src/Console/ChartMakeCommand.php:
--------------------------------------------------------------------------------
1 | 'PieChart',
16 | 'Donut Chart' => 'DonutChart',
17 | 'Radial Bar Chart' => 'RadialBarChart',
18 | 'Polar Area Chart' => 'PolarAreaChart',
19 | 'Line Chart' => 'LineChart',
20 | 'Area Chart' => 'AreaChart',
21 | 'Bar Chart' => 'BarChart',
22 | 'Horizontal Bar Chart' => 'HorizontalBarChart',
23 | 'Heatmap Chart' => 'HeatMapChart',
24 | 'Radar Chart' => 'RadarChart',
25 | ];
26 |
27 | protected $selectedChart;
28 |
29 | protected function askChartType()
30 | {
31 | $option = $this->choice(
32 | 'Select a chart type',
33 | array_keys($this->chartTypes),
34 | );
35 | $this->selectedChart = $this->chartTypes[$option];
36 | }
37 |
38 | public function handle(): ?bool
39 | {
40 | $this->askChartType();
41 | return parent::handle();
42 | }
43 |
44 | /**
45 | * The console command name.
46 | *
47 | * @var string
48 | */
49 | protected $name = 'make:chart';
50 |
51 | /**
52 | * The console command description.
53 | *
54 | * @var string
55 | */
56 | protected $description = 'Creates a chart class';
57 |
58 | /**
59 | * The type of class being generated.
60 | *
61 | * @var string
62 | */
63 | protected $type = 'Chart class';
64 |
65 | /**
66 | * Get the stub file for the generator.
67 | *
68 | * @return string
69 | */
70 | protected function getStub(): string
71 | {
72 | $directory = 'Default';
73 |
74 | if ($this->option('vue')) {
75 | $directory = 'Vue';
76 | }
77 |
78 | if ($this->option('json')) {
79 | $directory = 'Json';
80 | }
81 |
82 | $stub = "{$directory}/{$this->selectedChart}.stub";
83 |
84 | return $this->resolveStubPath($stub);
85 | }
86 |
87 | /**
88 | * Replace the class name for the given stub.
89 | *
90 | * @param string $stub
91 | * @param string $name
92 | * @return string
93 | */
94 | protected function replaceClass($stub, $name): string
95 | {
96 | $stub = parent::replaceClass($stub, $name);
97 |
98 | $className = class_basename(str_replace('\\', '/', $name));
99 |
100 | return str_replace('{{ name }}', $className, $stub);
101 | }
102 |
103 | /**
104 | * Get the default namespace for the class.
105 | *
106 | * @param string $rootNamespace
107 | * @return string
108 | */
109 | protected function getDefaultNamespace($rootNamespace): string
110 | {
111 | return $rootNamespace . '\Charts';
112 | }
113 |
114 | /**
115 | * Get the console command arguments.
116 | *
117 | * @return array
118 | */
119 | protected function getArguments(): array
120 | {
121 | return [
122 | ['name', InputArgument::REQUIRED, 'The name of the chart class.'],
123 | ];
124 | }
125 |
126 | /**
127 | * Get the console command options.
128 | *
129 | * @return array
130 | */
131 | protected function getOptions(): array
132 | {
133 | return [
134 | ['vue', 'vue', InputOption::VALUE_NONE, 'Creates a chart class for a vue component.'],
135 | ['json', 'json', InputOption::VALUE_NONE, 'Creates a chart class for a json API response.'],
136 | ];
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/src/Contracts/MustAddComplexData.php:
--------------------------------------------------------------------------------
1 | type = 'donut';
17 | }
18 |
19 | public function addPieces(array $data) :DonutChart
20 | {
21 | $this->addData($data);
22 | return $this;
23 | }
24 | }
--------------------------------------------------------------------------------
/src/Facades/LarapexChart.php:
--------------------------------------------------------------------------------
1 | type = 'heatmap';
18 | }
19 |
20 | public function addHeat(string $name, array $data) :HeatMapChart
21 | {
22 | return $this->addData($name, $data);
23 | }
24 | }
--------------------------------------------------------------------------------
/src/HorizontalBar.php:
--------------------------------------------------------------------------------
1 | type = 'bar';
18 | $this->horizontal = json_encode(['horizontal' => true]);
19 | }
20 |
21 | public function addBar(string $name, array $data) :HorizontalBar
22 | {
23 | return $this->addData($name, $data);
24 | }
25 | }
--------------------------------------------------------------------------------
/src/LarapexChart.php:
--------------------------------------------------------------------------------
1 | id = substr(str_shuffle(str_repeat($x = $this->chartLetters, ceil(25 / strlen($x)))), 1, 25);
55 | $this->horizontal = json_encode(['horizontal' => false]);
56 | $this->colors = json_encode(config('larapex-charts.colors'));
57 | $this->setXAxis([]);
58 | $this->grid = json_encode(['show' => false]);
59 | $this->markers = json_encode(['show' => false]);
60 | $this->toolbar = json_encode(['show' => false]);
61 | $this->zoom = json_encode(['enabled' => true]);
62 | $this->dataLabels = json_encode(['enabled' => false]);
63 | $this->sparkline = json_encode(['enabled' => false]);
64 | $this->fontFamily = config('larapex-charts.font_family');
65 | $this->foreColor = config('larapex-charts.font_color');
66 | return $this;
67 | }
68 |
69 | public function pieChart() :PieChart
70 | {
71 | return new PieChart();
72 | }
73 |
74 | public function donutChart() :DonutChart
75 | {
76 | return new DonutChart();
77 | }
78 |
79 | public function radialChart() :RadialChart
80 | {
81 | return new RadialChart();
82 | }
83 |
84 | public function polarAreaChart() :PolarAreaChart
85 | {
86 | return new PolarAreaChart();
87 | }
88 |
89 | public function lineChart() :LineChart
90 | {
91 | return new LineChart();
92 | }
93 |
94 | public function areaChart() :AreaChart
95 | {
96 | return new AreaChart();
97 | }
98 |
99 | public function barChart() :BarChart
100 | {
101 | return new BarChart();
102 | }
103 |
104 | public function horizontalBarChart() :HorizontalBar
105 | {
106 | return new HorizontalBar();
107 | }
108 |
109 | public function heatMapChart() :HeatMapChart
110 | {
111 | return new HeatMapChart();
112 | }
113 |
114 | public function radarChart() :RadarChart
115 | {
116 | return new RadarChart();
117 | }
118 |
119 | /*
120 | |--------------------------------------------------------------------------
121 | | Setters
122 | |--------------------------------------------------------------------------
123 | */
124 |
125 | /**
126 | *
127 | * @deprecated deprecated since version 2.0
128 | * @param null $type
129 | * @return $this
130 | */
131 | public function setType($type = null) :LarapexChart
132 | {
133 | $this->type = $type;
134 | return $this;
135 | }
136 |
137 | public function setFontFamily($fontFamily) :LarapexChart
138 | {
139 | $this->fontFamily = $fontFamily;
140 | return $this;
141 | }
142 |
143 | public function setFontColor($fontColor) :LarapexChart
144 | {
145 | $this->foreColor = $fontColor;
146 | return $this;
147 | }
148 |
149 | public function setDataset(array $dataset): LarapexChart
150 | {
151 | $this->dataset = json_encode($dataset);
152 | return $this;
153 | }
154 |
155 | public function setHeight(int $height) :LarapexChart
156 | {
157 | $this->height = $height;
158 | return $this;
159 | }
160 |
161 | public function setWidth(int $width) :LarapexChart
162 | {
163 | $this->width = $width;
164 | return $this;
165 | }
166 |
167 | public function setColors(array $colors) :LarapexChart
168 | {
169 | $this->colors = json_encode($colors);
170 | return $this;
171 | }
172 |
173 | public function setHorizontal(bool $horizontal) :LarapexChart
174 | {
175 | $this->horizontal = json_encode(['horizontal' => $horizontal]);
176 | return $this;
177 | }
178 |
179 | public function setTitle(string $title) :LarapexChart
180 | {
181 | $this->title = $title;
182 | return $this;
183 | }
184 |
185 | public function setSubtitle(string $subtitle, string $position = 'left') :LarapexChart
186 | {
187 | $this->subtitle = $subtitle;
188 | $this->subtitlePosition = $position;
189 | return $this;
190 | }
191 |
192 | public function setLabels(array $labels) :LarapexChart
193 | {
194 | $this->labels = $labels;
195 | return $this;
196 | }
197 |
198 | public function setXAxis(array $categories) :LarapexChart
199 | {
200 | $this->xAxis = json_encode($categories);
201 | return $this;
202 | }
203 |
204 | public function setGrid($color = '#e5e5e5', $opacity = 0.1) :LarapexChart
205 | {
206 | $this->grid = json_encode([
207 | 'show' => true,
208 | 'row' => [
209 | 'colors' => [$color, 'transparent'],
210 | 'opacity' => $opacity,
211 | ],
212 | ]);
213 |
214 | return $this;
215 | }
216 |
217 | public function setMarkers($colors = [], $width = 4, $hoverSize = 7) :LarapexChart
218 | {
219 | if(empty($colors)) {
220 | $colors = config('larapex-charts.colors');
221 | }
222 |
223 | $this->markers = json_encode([
224 | 'size' => $width,
225 | 'colors' => $colors,
226 | 'strokeColors' => "#fff",
227 | 'strokeWidth' => $width / 2,
228 | 'hover' => [
229 | 'size' => $hoverSize,
230 | ]
231 | ]);
232 |
233 | return $this;
234 | }
235 |
236 | public function setStroke(int $width, array $colors = [], string $curve = 'straight') :LarapexChart
237 | {
238 | if(empty($colors)) {
239 | $colors = config('larapex-charts.colors');
240 | }
241 |
242 | $this->stroke = json_encode([
243 | 'show' => true,
244 | 'width' => $width,
245 | 'colors' => $colors,
246 | 'curve' => $curve,
247 | ]);
248 | return $this;
249 | }
250 |
251 | public function setToolbar(bool $show, bool $zoom = true) :LarapexChart
252 | {
253 | $this->toolbar = json_encode(['show' => $show]);
254 | $this->zoom = json_encode(['enabled' => $zoom ? $zoom : false]);
255 | return $this;
256 | }
257 |
258 | public function setDataLabels(bool $enabled = true) :LarapexChart
259 | {
260 | $this->dataLabels = json_encode(['enabled' => $enabled]);
261 | return $this;
262 | }
263 |
264 | public function setTheme(string $theme) :LarapexChart
265 | {
266 | $this->theme = $theme;
267 | return $this;
268 | }
269 |
270 | public function setSparkline(bool $enabled = true): LarapexChart
271 | {
272 | $this->sparkline = json_encode(['enabled' => $enabled]);
273 | return $this;
274 | }
275 |
276 | public function setStacked(bool $stacked = true): LarapexChart
277 | {
278 | $this->stacked = $stacked;
279 | return $this;
280 | }
281 |
282 | public function setShowLegend(bool $showLegend = true): self
283 | {
284 | $this->showLegend = $showLegend;
285 | return $this;
286 | }
287 |
288 | /*
289 | |--------------------------------------------------------------------------
290 | | Getters
291 | |--------------------------------------------------------------------------
292 | */
293 |
294 | public function transformLabels(array $array): bool|string
295 | {
296 | $stringArray = array_filter($array, function($string){
297 | return "{$string}";
298 | });
299 | return json_encode(['"' . implode('","', $stringArray) . '"']);
300 | }
301 |
302 | public function container(): mixed
303 | {
304 | return View::make('larapex-charts::chart.container', ['id' => $this->id()]);
305 | }
306 |
307 | public function script(): mixed
308 | {
309 | return View::make('larapex-charts::chart.script', ['chart' => $this]);
310 | }
311 |
312 | public static function cdn() :string
313 | {
314 | return 'https://cdn.jsdelivr.net/npm/apexcharts';
315 | }
316 |
317 | public function id(): string
318 | {
319 | return $this->id;
320 | }
321 |
322 | public function title(): string
323 | {
324 | return $this->title;
325 | }
326 |
327 | public function subtitle(): string
328 | {
329 | return $this->subtitle;
330 | }
331 |
332 | public function subtitlePosition(): string
333 | {
334 | return $this->subtitlePosition;
335 | }
336 |
337 | public function type(): string
338 | {
339 | return $this->type;
340 | }
341 |
342 | public function fontFamily(): string
343 | {
344 | return $this->fontFamily;
345 | }
346 |
347 | public function foreColor(): string
348 | {
349 | return $this->foreColor;
350 | }
351 |
352 | public function labels(): array
353 | {
354 | return $this->labels;
355 | }
356 |
357 | public function dataset(): string
358 | {
359 | return $this->dataset;
360 | }
361 |
362 | public function height() :int
363 | {
364 | return $this->height;
365 | }
366 |
367 | public function width() :string
368 | {
369 | return $this->width;
370 | }
371 |
372 | public function colors(): bool|string
373 | {
374 | return $this->colors;
375 | }
376 |
377 | public function horizontal(): bool|string
378 | {
379 | return $this->horizontal;
380 | }
381 |
382 | public function xAxis(): string
383 | {
384 | return $this->xAxis;
385 | }
386 |
387 | public function grid(): bool|string
388 | {
389 | return $this->grid;
390 | }
391 |
392 | public function markers(): bool|string
393 | {
394 | return $this->markers;
395 | }
396 |
397 | public function stroke(): string
398 | {
399 | return $this->stroke;
400 | }
401 |
402 | public function toolbar(): bool|string
403 | {
404 | return $this->toolbar;
405 | }
406 |
407 | public function zoom(): bool|string
408 | {
409 | return $this->zoom;
410 | }
411 |
412 | public function dataLabels(): bool|string
413 | {
414 | return $this->dataLabels;
415 | }
416 |
417 | public function sparkline(): bool|string
418 | {
419 | return $this->sparkline;
420 | }
421 |
422 | public function stacked(): bool
423 | {
424 | return $this->stacked;
425 | }
426 |
427 | public function showLegend(): string
428 | {
429 | return $this->showLegend ? 'true' : 'false';
430 | }
431 |
432 | /*
433 | |--------------------------------------------------------------------------
434 | | JSON Options Builder
435 | |--------------------------------------------------------------------------
436 | */
437 |
438 | public function toJson(): \Illuminate\Http\JsonResponse
439 | {
440 | $options = [
441 | 'chart' => [
442 | 'type' => $this->type(),
443 | 'height' => $this->height(),
444 | 'width' => $this->width(),
445 | 'toolbar' => json_decode($this->toolbar()),
446 | 'zoom' => json_decode($this->zoom()),
447 | 'fontFamily' => json_decode($this->fontFamily()),
448 | 'foreColor' => $this->foreColor(),
449 | 'sparkline' => $this->sparkline(),
450 | 'stacked' => $this->stacked(),
451 | ],
452 | 'plotOptions' => [
453 | 'bar' => json_decode($this->horizontal()),
454 | ],
455 | 'colors' => json_decode($this->colors()),
456 | 'series' => json_decode($this->dataset()),
457 | 'dataLabels' => json_decode($this->dataLabels()),
458 | 'theme' => [
459 | 'mode' => $this->theme
460 | ],
461 | 'title' => [
462 | 'text' => $this->title()
463 | ],
464 | 'subtitle' => [
465 | 'text' => $this->subtitle() ? $this->subtitle() : '',
466 | 'align' => $this->subtitlePosition() ? $this->subtitlePosition() : '',
467 | ],
468 | 'xaxis' => [
469 | 'categories' => json_decode($this->xAxis()),
470 | ],
471 | 'grid' => json_decode($this->grid()),
472 | 'markers' => json_decode($this->markers()),
473 | 'legend' => [
474 | 'show' => $this->showLegend()
475 | ],
476 | ];
477 |
478 | if($this->labels()) {
479 | $options['labels'] = $this->labels();
480 | }
481 |
482 | if($this->stroke()) {
483 | $options['stroke'] = json_decode($this->stroke());
484 | }
485 |
486 | return response()->json([
487 | 'id' => $this->id(),
488 | 'options' => $options,
489 | ]);
490 | }
491 |
492 | /*
493 | |--------------------------------------------------------------------------
494 | | Vue Options Builder
495 | |--------------------------------------------------------------------------
496 | */
497 |
498 | public function toVue() :array
499 | {
500 | $options = [
501 | 'chart' => [
502 | 'height' => $this->height(),
503 | 'toolbar' => json_decode($this->toolbar()),
504 | 'zoom' => json_decode($this->zoom()),
505 | 'fontFamily' => json_decode($this->fontFamily()),
506 | 'foreColor' => $this->foreColor(),
507 | 'sparkline' => json_decode($this->sparkline()),
508 | 'stacked' => $this->stacked(),
509 | ],
510 | 'plotOptions' => [
511 | 'bar' => json_decode($this->horizontal()),
512 | ],
513 | 'colors' => json_decode($this->colors()),
514 | 'dataLabels' => json_decode($this->dataLabels()),
515 | 'theme' => [
516 | 'mode' => $this->theme
517 | ],
518 | 'title' => [
519 | 'text' => $this->title()
520 | ],
521 | 'subtitle' => [
522 | 'text' => $this->subtitle() ? $this->subtitle() : '',
523 | 'align' => $this->subtitlePosition() ? $this->subtitlePosition() : '',
524 | ],
525 | 'xaxis' => [
526 | 'categories' => json_decode($this->xAxis()),
527 | ],
528 | 'grid' => json_decode($this->grid()),
529 | 'markers' => json_decode($this->markers()),
530 | 'legend' => [
531 | 'show' => $this->showLegend()
532 | ]
533 | ];
534 |
535 | if($this->labels()) {
536 | $options['labels'] = $this->labels();
537 | }
538 |
539 | if($this->stroke()) {
540 | $options['stroke'] = json_decode($this->stroke());
541 | }
542 |
543 | return [
544 | 'height' => $this->height(),
545 | 'width' => $this->width(),
546 | 'type' => $this->type(),
547 | 'options' => $options,
548 | 'series' => json_decode($this->dataset()),
549 | ];
550 | }
551 | }
552 |
--------------------------------------------------------------------------------
/src/LarapexChartsServiceProvider.php:
--------------------------------------------------------------------------------
1 | app->bind('larapex-chart', function(){
21 | return new LarapexChart;
22 | });
23 |
24 | $this->mergeConfigFrom($this->packageBasePath('config/larapex-charts.php'), 'larapex-charts');
25 |
26 | $this->commands([
27 | \ArielMejiaDev\LarapexCharts\Console\ChartMakeCommand::class,
28 | ]);
29 | }
30 |
31 | /**
32 | * When this method is apply we have all laravel providers and methods available
33 | *
34 | * @return void
35 | */
36 | public function boot()
37 | {
38 | $this->loadViewsFrom($this->packageBasePath('stubs/resources/views'), 'larapex-charts');
39 |
40 | $this->publishes([
41 | $this->packageBasePath('stubs/public') => public_path('vendor/larapex-charts')
42 | ], 'larapex-charts-apexcharts-script');
43 |
44 | $this->publishes([
45 | $this->packageBasePath('stubs/resources/views') => resource_path('views/vendor/larapex-charts')
46 | ], 'larapex-charts-views');
47 |
48 | $this->publishes([
49 | $this->packageBasePath('config/larapex-charts.php') => base_path('config/larapex-charts.php')
50 | ], 'larapex-charts-config');
51 |
52 | $this->publishes([
53 | $this->packageBasePath('stubs/Console/Commands') => app_path('Console/Commands')
54 | ], 'larapex-charts-commands');
55 |
56 | $this->publishes([
57 | $this->packageBasePath('stubs/stubs') => base_path('stubs')
58 | ], 'larapex-charts-stubs');
59 |
60 | }
61 |
62 | public function packageBasePath(string $path = ''): string
63 | {
64 | return __DIR__ . '/../' . $path;
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/src/LineChart.php:
--------------------------------------------------------------------------------
1 | type = 'line';
17 | }
18 |
19 | public function addLine(string $name, array $data) :LineChart
20 | {
21 | return $this->addData($name, $data);
22 | }
23 | }
--------------------------------------------------------------------------------
/src/PieChart.php:
--------------------------------------------------------------------------------
1 | type = 'pie';
17 | }
18 |
19 | public function addPieces(array $data) :PieChart
20 | {
21 | $this->addData($data);
22 | return $this;
23 | }
24 | }
--------------------------------------------------------------------------------
/src/PolarAreaChart.php:
--------------------------------------------------------------------------------
1 | type = 'polarArea';
17 | }
18 |
19 | public function addPolarAreas(array $data) :PolarAreaChart
20 | {
21 | $this->addData($data);
22 | return $this;
23 | }
24 | }
--------------------------------------------------------------------------------
/src/RadarChart.php:
--------------------------------------------------------------------------------
1 | type = 'radar';
16 | }
17 |
18 | public function addSerie(string $name, array $data) :RadarChart
19 | {
20 | return $this->addData($name, $data);
21 | }
22 | }
--------------------------------------------------------------------------------
/src/RadialChart.php:
--------------------------------------------------------------------------------
1 | type = 'radialBar';
17 | }
18 |
19 | public function addRings(array $data) :RadialChart
20 | {
21 | $this->addData($data);
22 | return $this;
23 | }
24 | }
--------------------------------------------------------------------------------
/src/Traits/ComplexChartDataAggregator.php:
--------------------------------------------------------------------------------
1 | dataset);
10 |
11 | $dataset[] = [
12 | 'name' => $name,
13 | 'data' => $data
14 | ];
15 |
16 | $this->dataset = json_encode($dataset);
17 |
18 | return $this;
19 | }
20 | }
--------------------------------------------------------------------------------
/src/Traits/HasOptions.php:
--------------------------------------------------------------------------------
1 | options ? array_merge_recursive($this->getDefaultOption() ,$this->options) : $this->getDefaultOption();
11 | }
12 |
13 | /**
14 | * Set the value of options
15 | *
16 | * @return self
17 | */
18 | public function setOptions($options)
19 | {
20 | $this->options = $options;
21 |
22 | return $this;
23 | }
24 |
25 | private function getDefaultOption(){
26 | return [
27 | 'chart' => [
28 | 'type' => $this->type(),
29 | 'height' => $this->height(),
30 | 'width' => $this->width(),
31 | 'toolbar' => json_decode($this->toolbar()),
32 | 'zoom' => json_decode($this->zoom()),
33 | 'fontFamily' => json_decode($this->fontFamily()),
34 | 'foreColor' => $this->foreColor(),
35 | ],
36 | 'plotOptions' => [
37 | 'bar' => json_decode($this->horizontal()),
38 | ],
39 | 'colors' => json_decode($this->colors()),
40 | 'series' => json_decode($this->dataset()),
41 | 'dataLabels' => json_decode($this->dataLabels()),
42 | 'title' => [
43 | 'text' => $this->title()
44 | ],
45 | 'subtitle' => [
46 | 'text' => $this->subtitle() ? $this->subtitle() : '',
47 | 'align' => $this->subtitlePosition() ? $this->subtitlePosition() : '',
48 | ],
49 | 'xaxis' => [
50 | 'categories' => json_decode($this->xAxis()),
51 | ],
52 | 'grid' => json_decode($this->grid()),
53 | 'markers' => json_decode($this->markers()),
54 | ];
55 | }
56 | }
--------------------------------------------------------------------------------
/src/Traits/SimpleChartDataAggregator.php:
--------------------------------------------------------------------------------
1 | dataset = json_encode($data);
14 |
15 | return $this;
16 | }
17 | }
--------------------------------------------------------------------------------
/src/Traits/WithModelStub.php:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \ArielMejiaDev\LarapexCharts\AreaChart
17 | {
18 | return $this->chart->areaChart()
19 | ->setTitle('Sales during 2021.')
20 | ->setSubtitle('Physical sales vs Digital sales.')
21 | ->addData('Physical sales', [40, 93, 35, 42, 18, 82])
22 | ->addData('Digital sales', [70, 29, 77, 28, 55, 45])
23 | ->setXAxis(['January', 'February', 'March', 'April', 'May', 'June']);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/stubs/charts/Default/BarChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \ArielMejiaDev\LarapexCharts\BarChart
17 | {
18 | return $this->chart->barChart()
19 | ->setTitle('San Francisco vs Boston.')
20 | ->setSubtitle('Wins during season 2021.')
21 | ->addData('San Francisco', [6, 9, 3, 4, 10, 8])
22 | ->addData('Boston', [7, 3, 8, 2, 6, 4])
23 | ->setXAxis(['January', 'February', 'March', 'April', 'May', 'June']);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/stubs/charts/Default/DonutChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \ArielMejiaDev\LarapexCharts\DonutChart
17 | {
18 | return $this->chart->donutChart()
19 | ->setTitle('Top 3 scorers of the team.')
20 | ->setSubtitle('Season 2021.')
21 | ->addData([20, 24, 30])
22 | ->setLabels(['Player 7', 'Player 10', 'Player 9']);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/stubs/charts/Default/HeatMapChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \ArielMejiaDev\LarapexCharts\HeatMapChart
17 | {
18 | return $this->chart->heatMapChart()
19 | ->setTitle('Basic radar chart')
20 | ->addData('Sales', [80, 50, 30, 40, 100, 20])
21 | ->addHeat('Income', [70, 10, 80, 20, 60, 40])
22 | ->setMarkers(['#FFA41B', '#4F46E5'], 7, 10)
23 | ->setXAxis(['January', 'February', 'March', 'April', 'May', 'June']);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/stubs/charts/Default/HorizontalBarChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \ArielMejiaDev\LarapexCharts\HorizontalBar
17 | {
18 | return $this->chart->horizontalBarChart()
19 | ->setTitle('Los Angeles vs Miami.')
20 | ->setSubtitle('Wins during season 2021.')
21 | ->setColors(['#FFC107', '#D32F2F'])
22 | ->addData('San Francisco', [6, 9, 3, 4, 10, 8])
23 | ->addData('Boston', [7, 3, 8, 2, 6, 4])
24 | ->setXAxis(['January', 'February', 'March', 'April', 'May', 'June']);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/stubs/charts/Default/LineChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \ArielMejiaDev\LarapexCharts\LineChart
17 | {
18 | return $this->chart->lineChart()
19 | ->setTitle('Sales during 2021.')
20 | ->setSubtitle('Physical sales vs Digital sales.')
21 | ->addData('Physical sales', [40, 93, 35, 42, 18, 82])
22 | ->addData('Digital sales', [70, 29, 77, 28, 55, 45])
23 | ->setXAxis(['January', 'February', 'March', 'April', 'May', 'June']);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/stubs/charts/Default/PieChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \ArielMejiaDev\LarapexCharts\PieChart
17 | {
18 | return $this->chart->pieChart()
19 | ->setTitle('Top 3 scorers of the team.')
20 | ->setSubtitle('Season 2021.')
21 | ->addData([40, 50, 30])
22 | ->setLabels(['Player 7', 'Player 10', 'Player 9']);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/stubs/charts/Default/PolarAreaChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \ArielMejiaDev\LarapexCharts\PolarAreaChart
17 | {
18 | return $this->chart
19 | ->polarAreaChart()
20 | ->setTitle('Top 3 scorers of the team.')
21 | ->setSubtitle('Season 2021.')
22 | ->addData([20, 24, 30])
23 | ->setLabels(['Player 7', 'Player 10', 'Player 9']);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/stubs/charts/Default/RadarChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \ArielMejiaDev\LarapexCharts\RadarChart
17 | {
18 | return $this->chart->radarChart()
19 | ->setTitle('Individual Player Stats.')
20 | ->setSubtitle('Season 2021.')
21 | ->addData('Stats', [70, 93, 78, 97, 50, 90])
22 | ->setXAxis(['Pass', 'Dribble', 'Shot', 'Stamina', 'Long shots', 'Tactical'])
23 | ->setMarkers(['#303F9F'], 7, 10);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/stubs/charts/Default/RadialBarChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \ArielMejiaDev\LarapexCharts\RadialChart
17 | {
18 | return $this->chart->radialChart()
19 | ->setTitle('Passing effectiveness.')
20 | ->setSubtitle('Barcelona city vs Madrid sports.')
21 | ->addData([75, 60])
22 | ->setLabels(['Barcelona city', 'Madrid sports'])
23 | ->setColors(['#D32F2F', '#03A9F4']);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/stubs/charts/Json/AreaChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \Illuminate\Http\JsonResponse
17 | {
18 | return $this->chart->areaChart()
19 | ->setTitle('Sales during 2021.')
20 | ->setSubtitle('Physical sales vs Digital sales.')
21 | ->addData('Physical sales', [40, 93, 35, 42, 18, 82])
22 | ->addData('Digital sales', [70, 29, 77, 28, 55, 45])
23 | ->setXAxis(['January', 'February', 'March', 'April', 'May', 'June'])
24 | ->toJson();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/stubs/charts/Json/BarChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \Illuminate\Http\JsonResponse
17 | {
18 | return $this->chart->barChart()
19 | ->setTitle('San Francisco vs Boston.')
20 | ->setSubtitle('Wins during season 2021.')
21 | ->addData('San Francisco', [6, 9, 3, 4, 10, 8])
22 | ->addData('Boston', [7, 3, 8, 2, 6, 4])
23 | ->setXAxis(['January', 'February', 'March', 'April', 'May', 'June'])
24 | ->toJson();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/stubs/charts/Json/DonutChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \Illuminate\Http\JsonResponse
17 | {
18 | return $this->chart->donutChart()
19 | ->setTitle('Top 3 scorers of the team.')
20 | ->setSubtitle('Season 2021.')
21 | ->addData([20, 24, 30])
22 | ->setLabels(['Player 7', 'Player 10', 'Player 9'])
23 | ->toJson();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/stubs/charts/Json/HeatMapChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \Illuminate\Http\JsonResponse
17 | {
18 | return $this->chart->heatMapChart()
19 | ->setTitle('Basic radar chart')
20 | ->addData('Sales', [80, 50, 30, 40, 100, 20])
21 | ->addHeat('Income', [70, 10, 80, 20, 60, 40])
22 | ->setMarkers(['#FFA41B', '#4F46E5'], 7, 10)
23 | ->setXAxis(['January', 'February', 'March', 'April', 'May', 'June'])
24 | ->toJson();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/stubs/charts/Json/HorizontalBarChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \Illuminate\Http\JsonResponse
17 | {
18 | return $this->chart->horizontalBarChart()
19 | ->setTitle('Los Angeles vs Miami.')
20 | ->setSubtitle('Wins during season 2021.')
21 | ->setColors(['#FFC107', '#D32F2F'])
22 | ->addData('San Francisco', [6, 9, 3, 4, 10, 8])
23 | ->addData('Boston', [7, 3, 8, 2, 6, 4])
24 | ->setXAxis(['January', 'February', 'March', 'April', 'May', 'June'])
25 | ->toJson();
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/stubs/charts/Json/LineChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \Illuminate\Http\JsonResponse
17 | {
18 | return $this->chart->lineChart()
19 | ->setTitle('Sales during 2021.')
20 | ->setSubtitle('Physical sales vs Digital sales.')
21 | ->addData('Physical sales', [40, 93, 35, 42, 18, 82])
22 | ->addData('Digital sales', [70, 29, 77, 28, 55, 45])
23 | ->setXAxis(['January', 'February', 'March', 'April', 'May', 'June'])
24 | ->toJson();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/stubs/charts/Json/PieChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \Illuminate\Http\JsonResponse
17 | {
18 | return $this->chart->pieChart()
19 | ->setTitle('Top 3 scorers of the team.')
20 | ->setSubtitle('Season 2021.')
21 | ->addData([40, 50, 30])
22 | ->setLabels(['Player 7', 'Player 10', 'Player 9'])
23 | ->toJson();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/stubs/charts/Json/PolarAreaChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \Illuminate\Http\JsonResponse
17 | {
18 | return $this->chart
19 | ->polarAreaChart()
20 | ->setTitle('Top 3 scorers of the team.')
21 | ->setSubtitle('Season 2021.')
22 | ->addData([20, 24, 30])
23 | ->setLabels(['Player 7', 'Player 10', 'Player 9'])
24 | ->toJson();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/stubs/charts/Json/RadarChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \Illuminate\Http\JsonResponse
17 | {
18 | return $this->chart->radarChart()
19 | ->setTitle('Individual Player Stats.')
20 | ->setSubtitle('Season 2021.')
21 | ->addData('Stats', [70, 93, 78, 97, 50, 90])
22 | ->setXAxis(['Pass', 'Dribble', 'Shot', 'Stamina', 'Long shots', 'Tactical'])
23 | ->setMarkers(['#303F9F'], 7, 10)
24 | ->toJson();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/stubs/charts/Json/RadialBarChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \Illuminate\Http\JsonResponse
17 | {
18 | return $this->chart->radialChart()
19 | ->setTitle('Passing effectiveness.')
20 | ->setSubtitle('Barcelona city vs Madrid sports.')
21 | ->addData([75, 60])
22 | ->setLabels(['Barcelona city', 'Madrid sports'])
23 | ->setColors(['#D32F2F', '#03A9F4'])
24 | ->toJson();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/stubs/charts/Vue/AreaChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): array
17 | {
18 | return $this->chart->areaChart()
19 | ->setTitle('Sales during 2021.')
20 | ->setSubtitle('Physical sales vs Digital sales.')
21 | ->addData('Physical sales', [40, 93, 35, 42, 18, 82])
22 | ->addData('Digital sales', [70, 29, 77, 28, 55, 45])
23 | ->setXAxis(['January', 'February', 'March', 'April', 'May', 'June'])
24 | ->toVue();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/stubs/charts/Vue/BarChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): array
17 | {
18 | return $this->chart->barChart()
19 | ->setTitle('San Francisco vs Boston.')
20 | ->setSubtitle('Wins during season 2021.')
21 | ->addData('San Francisco', [6, 9, 3, 4, 10, 8])
22 | ->addData('Boston', [7, 3, 8, 2, 6, 4])
23 | ->setXAxis(['January', 'February', 'March', 'April', 'May', 'June'])
24 | ->toVue();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/stubs/charts/Vue/DonutChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): array
17 | {
18 | return $this->chart->donutChart()
19 | ->setTitle('Top 3 scorers of the team.')
20 | ->setSubtitle('Season 2021.')
21 | ->addData([20, 24, 30])
22 | ->setLabels(['Player 7', 'Player 10', 'Player 9'])
23 | ->toVue();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/stubs/charts/Vue/HeatMapChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): array
17 | {
18 | return $this->chart->heatMapChart()
19 | ->setTitle('Basic radar chart')
20 | ->addData('Sales', [80, 50, 30, 40, 100, 20])
21 | ->addHeat('Income', [70, 10, 80, 20, 60, 40])
22 | ->setMarkers(['#FFA41B', '#4F46E5'], 7, 10)
23 | ->setXAxis(['January', 'February', 'March', 'April', 'May', 'June'])
24 | ->toVue();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/stubs/charts/Vue/HorizontalBarChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): array
17 | {
18 | return $this->chart->horizontalBarChart()
19 | ->setTitle('Los Angeles vs Miami.')
20 | ->setSubtitle('Wins during season 2021.')
21 | ->setColors(['#FFC107', '#D32F2F'])
22 | ->addData('San Francisco', [6, 9, 3, 4, 10, 8])
23 | ->addData('Boston', [7, 3, 8, 2, 6, 4])
24 | ->setXAxis(['January', 'February', 'March', 'April', 'May', 'June'])
25 | ->toVue();
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/stubs/charts/Vue/LineChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): array
17 | {
18 | return $this->chart->lineChart()
19 | ->setTitle('Sales during 2021.')
20 | ->setSubtitle('Physical sales vs Digital sales.')
21 | ->addData('Physical sales', [40, 93, 35, 42, 18, 82])
22 | ->addData('Digital sales', [70, 29, 77, 28, 55, 45])
23 | ->setXAxis(['January', 'February', 'March', 'April', 'May', 'June'])
24 | ->toVue();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/stubs/charts/Vue/PieChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): array
17 | {
18 | return $this->chart->pieChart()
19 | ->setTitle('Top 3 scorers of the team.')
20 | ->setSubtitle('Season 2021.')
21 | ->addData([40, 50, 30])
22 | ->setLabels(['Player 7', 'Player 10', 'Player 9'])
23 | ->toVue();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/stubs/charts/Vue/PolarAreaChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): array
17 | {
18 | return $this->chart
19 | ->polarAreaChart()
20 | ->setTitle('Top 3 scorers of the team.')
21 | ->setSubtitle('Season 2021.')
22 | ->addData([20, 24, 30])
23 | ->setLabels(['Player 7', 'Player 10', 'Player 9'])
24 | ->toVue();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/stubs/charts/Vue/RadarChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): array
17 | {
18 | return $this->chart->radarChart()
19 | ->setTitle('Individual Player Stats.')
20 | ->setSubtitle('Season 2021.')
21 | ->addData('Stats', [70, 93, 78, 97, 50, 90])
22 | ->setXAxis(['Pass', 'Dribble', 'Shot', 'Stamina', 'Long shots', 'Tactical'])
23 | ->setMarkers(['#303F9F'], 7, 10)
24 | ->toVue();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/stubs/charts/Vue/RadialBarChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): array
17 | {
18 | return $this->chart->radialChart()
19 | ->setTitle('Passing effectiveness.')
20 | ->setSubtitle('Barcelona city vs Madrid sports.')
21 | ->addData([75, 60])
22 | ->setLabels(['Barcelona city', 'Madrid sports'])
23 | ->setColors(['#D32F2F', '#03A9F4'])
24 | ->toVue();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/stubs/resources/views/chart/container.blade.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/stubs/resources/views/chart/script.blade.php:
--------------------------------------------------------------------------------
1 |
50 |
--------------------------------------------------------------------------------
/stubs/stubs/charts/Default/AreaChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \ArielMejiaDev\LarapexCharts\AreaChart
17 | {
18 | return $this->chart->areaChart()
19 | ->setTitle('Sales during 2021.')
20 | ->setSubtitle('Physical sales vs Digital sales.')
21 | ->addData('Physical sales', [40, 93, 35, 42, 18, 82])
22 | ->addData('Digital sales', [70, 29, 77, 28, 55, 45])
23 | ->setXAxis(['January', 'February', 'March', 'April', 'May', 'June']);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/stubs/stubs/charts/Default/BarChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \ArielMejiaDev\LarapexCharts\BarChart
17 | {
18 | return $this->chart->barChart()
19 | ->setTitle('San Francisco vs Boston.')
20 | ->setSubtitle('Wins during season 2021.')
21 | ->addData('San Francisco', [6, 9, 3, 4, 10, 8])
22 | ->addData('Boston', [7, 3, 8, 2, 6, 4])
23 | ->setXAxis(['January', 'February', 'March', 'April', 'May', 'June']);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/stubs/stubs/charts/Default/DonutChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \ArielMejiaDev\LarapexCharts\DonutChart
17 | {
18 | return $this->chart->donutChart()
19 | ->setTitle('Top 3 scorers of the team.')
20 | ->setSubtitle('Season 2021.')
21 | ->addData([20, 24, 30])
22 | ->setLabels(['Player 7', 'Player 10', 'Player 9']);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/stubs/stubs/charts/Default/HeatMapChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \ArielMejiaDev\LarapexCharts\HeatMapChart
17 | {
18 | return $this->chart->heatMapChart()
19 | ->setTitle('Basic radar chart')
20 | ->addData('Sales', [80, 50, 30, 40, 100, 20])
21 | ->addHeat('Income', [70, 10, 80, 20, 60, 40])
22 | ->setMarkers(['#FFA41B', '#4F46E5'], 7, 10)
23 | ->setXAxis(['January', 'February', 'March', 'April', 'May', 'June']);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/stubs/stubs/charts/Default/HorizontalBarChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \ArielMejiaDev\LarapexCharts\HorizontalBar
17 | {
18 | return $this->chart->horizontalBarChart()
19 | ->setTitle('Los Angeles vs Miami.')
20 | ->setSubtitle('Wins during season 2021.')
21 | ->setColors(['#FFC107', '#D32F2F'])
22 | ->addData('San Francisco', [6, 9, 3, 4, 10, 8])
23 | ->addData('Boston', [7, 3, 8, 2, 6, 4])
24 | ->setXAxis(['January', 'February', 'March', 'April', 'May', 'June']);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/stubs/stubs/charts/Default/LineChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \ArielMejiaDev\LarapexCharts\LineChart
17 | {
18 | return $this->chart->lineChart()
19 | ->setTitle('Sales during 2021.')
20 | ->setSubtitle('Physical sales vs Digital sales.')
21 | ->addData('Physical sales', [40, 93, 35, 42, 18, 82])
22 | ->addData('Digital sales', [70, 29, 77, 28, 55, 45])
23 | ->setXAxis(['January', 'February', 'March', 'April', 'May', 'June']);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/stubs/stubs/charts/Default/PieChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \ArielMejiaDev\LarapexCharts\PieChart
17 | {
18 | return $this->chart->pieChart()
19 | ->setTitle('Top 3 scorers of the team.')
20 | ->setSubtitle('Season 2021.')
21 | ->addData([40, 50, 30])
22 | ->setLabels(['Player 7', 'Player 10', 'Player 9']);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/stubs/stubs/charts/Default/PolarAreaChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \ArielMejiaDev\LarapexCharts\PolarAreaChart
17 | {
18 | return $this->chart
19 | ->polarAreaChart()
20 | ->setTitle('Top 3 scorers of the team.')
21 | ->setSubtitle('Season 2021.')
22 | ->addData([20, 24, 30])
23 | ->setLabels(['Player 7', 'Player 10', 'Player 9']);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/stubs/stubs/charts/Default/RadarChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \ArielMejiaDev\LarapexCharts\RadarChart
17 | {
18 | return $this->chart->radarChart()
19 | ->setTitle('Individual Player Stats.')
20 | ->setSubtitle('Season 2021.')
21 | ->addData('Stats', [70, 93, 78, 97, 50, 90])
22 | ->setXAxis(['Pass', 'Dribble', 'Shot', 'Stamina', 'Long shots', 'Tactical'])
23 | ->setMarkers(['#303F9F'], 7, 10);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/stubs/stubs/charts/Default/RadialBarChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \ArielMejiaDev\LarapexCharts\RadialChart
17 | {
18 | return $this->chart->radialChart()
19 | ->setTitle('Passing effectiveness.')
20 | ->setSubtitle('Barcelona city vs Madrid sports.')
21 | ->addData([75, 60])
22 | ->setLabels(['Barcelona city', 'Madrid sports'])
23 | ->setColors(['#D32F2F', '#03A9F4']);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/stubs/stubs/charts/Json/AreaChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \Illuminate\Http\JsonResponse
17 | {
18 | return $this->chart->areaChart()
19 | ->setTitle('Sales during 2021.')
20 | ->setSubtitle('Physical sales vs Digital sales.')
21 | ->addData('Physical sales', [40, 93, 35, 42, 18, 82])
22 | ->addData('Digital sales', [70, 29, 77, 28, 55, 45])
23 | ->setXAxis(['January', 'February', 'March', 'April', 'May', 'June'])
24 | ->toJson();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/stubs/stubs/charts/Json/BarChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \Illuminate\Http\JsonResponse
17 | {
18 | return $this->chart->barChart()
19 | ->setTitle('San Francisco vs Boston.')
20 | ->setSubtitle('Wins during season 2021.')
21 | ->addData('San Francisco', [6, 9, 3, 4, 10, 8])
22 | ->addData('Boston', [7, 3, 8, 2, 6, 4])
23 | ->setXAxis(['January', 'February', 'March', 'April', 'May', 'June'])
24 | ->toJson();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/stubs/stubs/charts/Json/DonutChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \Illuminate\Http\JsonResponse
17 | {
18 | return $this->chart->donutChart()
19 | ->setTitle('Top 3 scorers of the team.')
20 | ->setSubtitle('Season 2021.')
21 | ->addData([20, 24, 30])
22 | ->setLabels(['Player 7', 'Player 10', 'Player 9'])
23 | ->toJson();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/stubs/stubs/charts/Json/HeatMapChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \Illuminate\Http\JsonResponse
17 | {
18 | return $this->chart->heatMapChart()
19 | ->setTitle('Basic radar chart')
20 | ->addData('Sales', [80, 50, 30, 40, 100, 20])
21 | ->addHeat('Income', [70, 10, 80, 20, 60, 40])
22 | ->setMarkers(['#FFA41B', '#4F46E5'], 7, 10)
23 | ->setXAxis(['January', 'February', 'March', 'April', 'May', 'June'])
24 | ->toJson();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/stubs/stubs/charts/Json/HorizontalBarChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \Illuminate\Http\JsonResponse
17 | {
18 | return $this->chart->horizontalBarChart()
19 | ->setTitle('Los Angeles vs Miami.')
20 | ->setSubtitle('Wins during season 2021.')
21 | ->setColors(['#FFC107', '#D32F2F'])
22 | ->addData('San Francisco', [6, 9, 3, 4, 10, 8])
23 | ->addData('Boston', [7, 3, 8, 2, 6, 4])
24 | ->setXAxis(['January', 'February', 'March', 'April', 'May', 'June'])
25 | ->toJson();
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/stubs/stubs/charts/Json/LineChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \Illuminate\Http\JsonResponse
17 | {
18 | return $this->chart->lineChart()
19 | ->setTitle('Sales during 2021.')
20 | ->setSubtitle('Physical sales vs Digital sales.')
21 | ->addData('Physical sales', [40, 93, 35, 42, 18, 82])
22 | ->addData('Digital sales', [70, 29, 77, 28, 55, 45])
23 | ->setXAxis(['January', 'February', 'March', 'April', 'May', 'June'])
24 | ->toJson();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/stubs/stubs/charts/Json/PieChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \Illuminate\Http\JsonResponse
17 | {
18 | return $this->chart->pieChart()
19 | ->setTitle('Top 3 scorers of the team.')
20 | ->setSubtitle('Season 2021.')
21 | ->addData([40, 50, 30])
22 | ->setLabels(['Player 7', 'Player 10', 'Player 9'])
23 | ->toJson();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/stubs/stubs/charts/Json/PolarAreaChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \Illuminate\Http\JsonResponse
17 | {
18 | return $this->chart
19 | ->polarAreaChart()
20 | ->setTitle('Top 3 scorers of the team.')
21 | ->setSubtitle('Season 2021.')
22 | ->addData([20, 24, 30])
23 | ->setLabels(['Player 7', 'Player 10', 'Player 9'])
24 | ->toJson();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/stubs/stubs/charts/Json/RadarChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \Illuminate\Http\JsonResponse
17 | {
18 | return $this->chart->radarChart()
19 | ->setTitle('Individual Player Stats.')
20 | ->setSubtitle('Season 2021.')
21 | ->addData('Stats', [70, 93, 78, 97, 50, 90])
22 | ->setXAxis(['Pass', 'Dribble', 'Shot', 'Stamina', 'Long shots', 'Tactical'])
23 | ->setMarkers(['#303F9F'], 7, 10)
24 | ->toJson();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/stubs/stubs/charts/Json/RadialBarChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): \Illuminate\Http\JsonResponse
17 | {
18 | return $this->chart->radialChart()
19 | ->setTitle('Passing effectiveness.')
20 | ->setSubtitle('Barcelona city vs Madrid sports.')
21 | ->addData([75, 60])
22 | ->setLabels(['Barcelona city', 'Madrid sports'])
23 | ->setColors(['#D32F2F', '#03A9F4'])
24 | ->toJson();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/stubs/stubs/charts/Vue/AreaChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): array
17 | {
18 | return $this->chart->areaChart()
19 | ->setTitle('Sales during 2021.')
20 | ->setSubtitle('Physical sales vs Digital sales.')
21 | ->addData('Physical sales', [40, 93, 35, 42, 18, 82])
22 | ->addData('Digital sales', [70, 29, 77, 28, 55, 45])
23 | ->setXAxis(['January', 'February', 'March', 'April', 'May', 'June'])
24 | ->toVue();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/stubs/stubs/charts/Vue/BarChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): array
17 | {
18 | return $this->chart->barChart()
19 | ->setTitle('San Francisco vs Boston.')
20 | ->setSubtitle('Wins during season 2021.')
21 | ->addData('San Francisco', [6, 9, 3, 4, 10, 8])
22 | ->addData('Boston', [7, 3, 8, 2, 6, 4])
23 | ->setXAxis(['January', 'February', 'March', 'April', 'May', 'June'])
24 | ->toVue();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/stubs/stubs/charts/Vue/DonutChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): array
17 | {
18 | return $this->chart->donutChart()
19 | ->setTitle('Top 3 scorers of the team.')
20 | ->setSubtitle('Season 2021.')
21 | ->addData([20, 24, 30])
22 | ->setLabels(['Player 7', 'Player 10', 'Player 9'])
23 | ->toVue();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/stubs/stubs/charts/Vue/HeatMapChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): array
17 | {
18 | return $this->chart->heatMapChart()
19 | ->setTitle('Basic radar chart')
20 | ->addData('Sales', [80, 50, 30, 40, 100, 20])
21 | ->addHeat('Income', [70, 10, 80, 20, 60, 40])
22 | ->setMarkers(['#FFA41B', '#4F46E5'], 7, 10)
23 | ->setXAxis(['January', 'February', 'March', 'April', 'May', 'June'])
24 | ->toVue();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/stubs/stubs/charts/Vue/HorizontalBarChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): array
17 | {
18 | return $this->chart->horizontalBarChart()
19 | ->setTitle('Los Angeles vs Miami.')
20 | ->setSubtitle('Wins during season 2021.')
21 | ->setColors(['#FFC107', '#D32F2F'])
22 | ->addData('San Francisco', [6, 9, 3, 4, 10, 8])
23 | ->addData('Boston', [7, 3, 8, 2, 6, 4])
24 | ->setXAxis(['January', 'February', 'March', 'April', 'May', 'June'])
25 | ->toVue();
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/stubs/stubs/charts/Vue/LineChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): array
17 | {
18 | return $this->chart->lineChart()
19 | ->setTitle('Sales during 2021.')
20 | ->setSubtitle('Physical sales vs Digital sales.')
21 | ->addData('Physical sales', [40, 93, 35, 42, 18, 82])
22 | ->addData('Digital sales', [70, 29, 77, 28, 55, 45])
23 | ->setXAxis(['January', 'February', 'March', 'April', 'May', 'June'])
24 | ->toVue();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/stubs/stubs/charts/Vue/PieChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): array
17 | {
18 | return $this->chart->pieChart()
19 | ->setTitle('Top 3 scorers of the team.')
20 | ->setSubtitle('Season 2021.')
21 | ->addData([40, 50, 30])
22 | ->setLabels(['Player 7', 'Player 10', 'Player 9'])
23 | ->toVue();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/stubs/stubs/charts/Vue/PolarAreaChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): array
17 | {
18 | return $this->chart
19 | ->polarAreaChart()
20 | ->setTitle('Top 3 scorers of the team.')
21 | ->setSubtitle('Season 2021.')
22 | ->addData([20, 24, 30])
23 | ->setLabels(['Player 7', 'Player 10', 'Player 9'])
24 | ->toVue();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/stubs/stubs/charts/Vue/RadarChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): array
17 | {
18 | return $this->chart->radarChart()
19 | ->setTitle('Individual Player Stats.')
20 | ->setSubtitle('Season 2021.')
21 | ->addData('Stats', [70, 93, 78, 97, 50, 90])
22 | ->setXAxis(['Pass', 'Dribble', 'Shot', 'Stamina', 'Long shots', 'Tactical'])
23 | ->setMarkers(['#303F9F'], 7, 10)
24 | ->toVue();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/stubs/stubs/charts/Vue/RadialBarChart.stub:
--------------------------------------------------------------------------------
1 | chart = $chart;
14 | }
15 |
16 | public function build(): array
17 | {
18 | return $this->chart->radialChart()
19 | ->setTitle('Passing effectiveness.')
20 | ->setSubtitle('Barcelona city vs Madrid sports.')
21 | ->addData([75, 60])
22 | ->setLabels(['Barcelona city', 'Madrid sports'])
23 | ->setColors(['#D32F2F', '#03A9F4'])
24 | ->toVue();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/tests/Feature/ChartsTest.php:
--------------------------------------------------------------------------------
1 | setTitle('Users Test Chart');
15 | $this->assertEquals('donut', $chart->type());
16 | $anotherChart = (new LarapexChart)->areaChart();
17 | $this->assertEquals('area', $anotherChart->type());
18 | }
19 |
20 | /** @test */
21 | public function it_tests_larapex_charts_can_render_pie_chart(): void
22 | {
23 | $chart = (new LarapexChart)->pieChart()
24 | ->setTitle('Posts')
25 | ->setSubtitle('From January To March')
26 | ->setLabels(['Product One', 'Product Two', 'Product Three'])
27 | ->setXAxis(['Jan', 'Feb', 'Mar'])
28 | ->setDataset([150, 120]);
29 |
30 | $this->assertEquals($chart, $chart->script()['chart']);
31 | $this->assertEquals('pie', $chart->type());
32 | }
33 |
34 | /** @test */
35 | public function it_tests_larapex_charts_can_render_donut_chart(): void
36 | {
37 | $chart = (new LarapexChart)->donutChart()
38 | ->setTitle('Posts')
39 | ->setXAxis(['Jan', 'Feb', 'Mar'])
40 | ->setDataset([150, 120]);
41 |
42 | $this->assertEquals($chart, $chart->script()['chart']);
43 | $this->assertEquals('donut', $chart->type());
44 | }
45 |
46 | /** @test */
47 | public function it_tests_larapex_can_render_radial_bar_charts(): void
48 | {
49 | $chart = (new LarapexChart)->radialChart()
50 | ->setTitle('Products with more profit')
51 | ->setXAxis(['Jan', 'Feb', 'Mar'])
52 | ->setDataset([60, 40, 79]);
53 |
54 | $this->assertEquals($chart, $chart->script()['chart']);
55 | $this->assertEquals('radialBar', $chart->type());
56 | }
57 |
58 | /** @test */
59 | public function it_tests_larapex_charts_can_render_polar_chart(): void
60 | {
61 | $chart = (new LarapexChart)->polarAreaChart()
62 | ->setTitle('Products with more profit')
63 | ->setXAxis(['Jan', 'Feb', 'Mar'])
64 | ->setDataset([60, 40, 79]);
65 |
66 | $this->assertEquals($chart, $chart->script()['chart']);
67 | $this->assertEquals('polarArea', $chart->type());
68 | }
69 |
70 | /** @test */
71 | public function larapex_can_render_line_charts(): void
72 | {
73 | $chart = (new LarapexChart)->lineChart()
74 | ->setTitle('Total Users Monthly')
75 | ->setSubtitle('From January to March')
76 | ->setXAxis([
77 | 'Jan', 'Feb', 'Mar'
78 | ])
79 | ->setDataset([
80 | [
81 | 'name' => 'Active Users',
82 | 'data' => [250, 700, 1200]
83 | ]
84 | ])
85 | ->setHeight(250)
86 | ->setGrid(true)
87 | ->setStroke(1);
88 |
89 | $this->assertEquals($chart->id(), $chart->container()['id']);
90 | $this->assertEquals($chart, $chart->script()['chart']);
91 | $this->assertEquals('line', $chart->type());
92 | }
93 |
94 | /** @test */
95 | public function it_tests_larapex_charts_can_create_an_area_chart(): void
96 | {
97 | $chart = (new LarapexChart)->areaChart()
98 | ->setTitle('Total Users Monthly')
99 | ->setSubtitle('From January to March')
100 | ->setXAxis([
101 | 'Jan', 'Feb', 'Mar'
102 | ])
103 | ->setDataset([
104 | [
105 | 'name' => 'Active Users',
106 | 'data' => [250, 700, 1200]
107 | ],
108 | [
109 | 'name' => 'New Users',
110 | 'data' => [1000, 1124, 2000]
111 | ]
112 | ]);
113 |
114 | $this->assertEquals($chart->id(), $chart->container()['id']);
115 | $this->assertEquals($chart, $chart->script()['chart']);
116 | $this->assertEquals('area', $chart->type());
117 | }
118 |
119 | /** @test */
120 | public function it_tests_larapex_charts_can_render_bar_charts(): void
121 | {
122 | $chart = (new LarapexChart)->barChart()
123 | ->setTitle('Net Profit')
124 | ->setXAxis(['Jan', 'Feb', 'Mar'])
125 | ->setDataset([
126 | [
127 | 'name' => 'Company A',
128 | 'data' => [500, 1000, 1900]
129 | ],
130 | [
131 | 'name' => 'Company B',
132 | 'data' => [300, 900, 1400]
133 | ],
134 | [
135 | 'name' => 'Company C',
136 | 'data' => [430, 245, 500]
137 | ],
138 | [
139 | 'name' => 'Company D',
140 | 'data' => [200, 245, 700]
141 | ],
142 | [
143 | 'name' => 'Company E',
144 | 'data' => [120, 45, 610]
145 | ],
146 | [
147 | 'name' => 'Company F',
148 | 'data' => [420, 280, 400]
149 | ]
150 | ]);
151 |
152 | $this->assertEquals($chart->id(), $chart->container()['id']);
153 | $this->assertEquals($chart, $chart->script()['chart']);
154 | $this->assertEquals('bar', $chart->type());
155 | }
156 |
157 | /** @test */
158 | public function it_tests_larapex_charts_can_render_stacked_bar_chart(): void
159 | {
160 | $chart = (new LarapexChart)->barChart()
161 | ->setTitle('Net Profit')
162 | ->setStacked(true)
163 | ->setXAxis(['Jan', 'Feb', 'Mar'])
164 | ->setDataset([
165 | [
166 | 'name' => 'Company A',
167 | 'data' => [500, 1000, 1900]
168 | ],
169 | [
170 | 'name' => 'Company B',
171 | 'data' => [300, 800, 1400]
172 | ],
173 | [
174 | 'name' => 'Company C',
175 | 'data' => [304, 231, 500]
176 | ]
177 | ]);
178 |
179 | $this->assertEquals($chart->id(), $chart->container()['id']);
180 | $this->assertEquals($chart, $chart->script()['chart']);
181 | $this->assertEquals('bar', $chart->type());
182 | $this->assertTrue($chart->stacked());
183 | }
184 |
185 | /** @test */
186 | public function it_tests_larapex_charts_can_render_horizontal_bar_chart(): void
187 | {
188 | $chart = (new LarapexChart)->barChart()
189 | ->setTitle('Net Profit')
190 | ->setHorizontal(true)
191 | ->setXAxis(['Jan', 'Feb', 'Mar'])
192 | ->setDataset([
193 | [
194 | 'name' => 'Company A',
195 | 'data' => [500, 1000, 1900]
196 | ],
197 | [
198 | 'name' => 'Company B',
199 | 'data' => [300, 900, 1400]
200 | ],
201 | [
202 | 'name' => 'Company C',
203 | 'data' => [430, 245, 500]
204 | ]
205 | ]);
206 |
207 | $this->assertEquals($chart->id(), $chart->container()['id']);
208 | $this->assertEquals($chart, $chart->script()['chart']);
209 | $this->assertEquals('bar', $chart->type());
210 | $chartHorizontalOrientation = json_decode($chart->horizontal(), 1)['horizontal'];
211 | $this->assertTrue($chartHorizontalOrientation);
212 | }
213 |
214 | /** @test */
215 | public function it_tests_larapex_charts_can_render_heatmap_chart(): void
216 | {
217 | $chart = (new LarapexChart)->heatMapChart()
218 | ->setTitle('Total Users')
219 | ->setXAxis([
220 | 'Jan', 'Feb', 'Mar'
221 | ])
222 | ->setDataset([
223 | [
224 | 'name' => 'Users of Basic Plan',
225 | 'data' => [250, 700, 1200]
226 | ],
227 | [
228 | 'name' => 'Users of Premium Plan',
229 | 'data' => [1000, 1124, 2000]
230 | ]
231 | ]);
232 |
233 | $this->assertEquals($chart->id(), $chart->container()['id']);
234 | $this->assertEquals($chart, $chart->script()['chart']);
235 | $this->assertEquals('heatmap', $chart->type());
236 | }
237 |
238 | /** @test */
239 | public function it_tests_larapex_charts_can_render_radar_chart(): void
240 | {
241 | $chart = (new LarapexChart)->radarChart()
242 | ->setTitle('Total Users')
243 | ->setXAxis([
244 | 'Jan', 'Feb', 'Mar'
245 | ])
246 | ->setDataset([
247 | [
248 | 'name' => 'Users of Basic Plan',
249 | 'data' => [250, 700, 1200]
250 | ],
251 | [
252 | 'name' => 'Users of Premium Plan',
253 | 'data' => [1000, 1124, 2000]
254 | ]
255 | ]);
256 |
257 | $this->assertEquals($chart->id(), $chart->container()['id']);
258 | $this->assertEquals($chart, $chart->script()['chart']);
259 | $this->assertEquals('radar', $chart->type());
260 | }
261 | }
262 |
--------------------------------------------------------------------------------
/tests/TestCase.php:
--------------------------------------------------------------------------------
1 | set('database.default', 'testing');
17 | $app['config']->set('database.connection.testing', [
18 | 'driver' => 'sqlite',
19 | 'database' => ':memory:'
20 | ]);
21 | }
22 |
23 | // set providers to test the class
24 | protected function getPackageProviders($app): array
25 | {
26 | return [
27 | LarapexChartsServiceProvider::class,
28 | ];
29 | }
30 |
31 | // With this method I can use the facade instead of all class namespace
32 | protected function getPackageAliases($app): array
33 | {
34 | return [
35 | 'LarapexChart' => \ArielMejiaDev\LarapexCharts\Facades\LarapexChart::class
36 | ];
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/tests/Unit/ChartsTest.php:
--------------------------------------------------------------------------------
1 | each(function ($chart) {
28 | $this->assertFileExists(
29 | base_path("stubs/charts/Default/{$chart}.stub")
30 | );
31 |
32 | $this->assertFileExists(
33 | base_path("stubs/charts/Vue/{$chart}.stub")
34 | );
35 |
36 | $this->assertFileExists(
37 | base_path("stubs/charts/Json/{$chart}.stub")
38 | );
39 | });
40 | }
41 |
42 | /** @test */
43 | public function it_tests_larapex_charts_can_load_script_correctly(): void
44 | {
45 | $chart = (new LarapexChart)
46 | ->setTitle('Posts')
47 | ->setXAxis(['Jan', 'Feb', 'Mar'])
48 | ->setDataset([150, 120])
49 | ->setLabels([__('Published'), __('No Published')]);
50 |
51 | $this->assertEquals($chart->dataset(), $chart->script()['chart']->dataset());
52 | }
53 |
54 | /** @test */
55 | public function it_tests_larapex_charts_can_change_default_config_colors(): void
56 | {
57 | $chart = (new LarapexChart)->setTitle('Posts')->setXAxis(['Jan', 'Feb', 'Mar'])->setDataset([150, 120]);
58 | $oldColors = $chart->colors();
59 | $chart->setColors(['#fe9700', '#607c8a']);
60 | $this->assertNotEquals($oldColors, $chart->colors());
61 | }
62 |
63 | /** @test */
64 | public function it_tests_larapex_chart_cdn_returns_a_correct_url(): void
65 | {
66 | $this->assertEquals('https://cdn.jsdelivr.net/npm/apexcharts' , (new LarapexChart)->cdn());
67 | }
68 | }
69 |
--------------------------------------------------------------------------------