Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ApexCharts package for Laravel

License

NotificationsYou must be signed in to change notification settings

akaunting/laravel-apexcharts

Repository files navigation

DownloadsTestsStyleCILicense

This package allows you to generate modern and interactive charts using theApexCharts library directly fromLaravel without interacting with JavaScript, CSS, etc.

It covers all of the charttypes andoptions available within theApexCharts library.

Check out theAkaunting project to see it live.

Getting Started

1. Install

Run the following command:

composer require akaunting/laravel-apexcharts

2. Publish

Publish configuration

php artisan vendor:publish --tag=apexcharts

3. Configure

You can change the chart settings of your app fromconfig/apexcharts.php file

Usage

Blade

Create an instance of theChart class and set the data and options according to your needs.

useAkaunting\Apexcharts\Chart;// ...$chart = (newChart)->setType('donut')    ->setWidth('100%')    ->setHeight(300)    ->setLabels(['Sales','Deposit'])    ->setDataset('Income by Category','donut', [1907,1923]);

Then, include the JavaScript (on every page using charts).

<!-- layout.blade.php--><body><!-- ...-->@apexchartsScripts</body>

Finally, call thecontainer andscript method wherever you want to display the chart.

<!-- dashboard.blade.php-->{!!$chart->container()!!}{!!$chart->script()!!}

Vue

If you're using Vue and Inertia, install Apexcharts and their Vue 3 adapter:

npm install --save apexchartsnpm install --save vue3-apexcharts
// resources/js/app.jsimportVueApexChartsfrom'vue3-apexcharts';createInertiaApp({// ...setup({el, App, props, plugin}){returncreateApp({render:()=>h(App,props)}).use(VueApexCharts).mount(el);},});

Then, create a simplechart.vue component:

<!-- components/chart.vue--><template>    <apexchart:id="chart.id":key="chart.id":type="chart.type":width="chart.width":height="chart.height":series="chart.series":options="chart.options"    /></template><script setup>defineProps({    chart:Object,});</script>

Create an instance ofChart and calltoVue() before passing it to your page:

Route::get('dashboard',function () {$chart = (newChart)->setType('...');returninertia('dashboard', ['chart' =>$chart->toVue(),    ]);});

Finally, render the chart:

<!-- pages/dashboard.vue--><template>    <Chart:chart="chart" /></template><script setup>importChartfrom'./components/chart.vue';defineProps({    chart:Object,});</script>

Testing

composertest

Changelog

Please seeReleases for more information what has changed recently.

Contributing

Pull requests are more than welcome. You must follow the PSR coding standards.

Security

Please reviewour security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please seeLICENSE for more information.

About

ApexCharts package for Laravel

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Contributors4

  •  
  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp