@@ -35,12 +35,14 @@ You can change the chart settings of your app from `config/apexcharts.php` file
35
35
36
36
## Usage
37
37
38
- First of all, create an instance of the ` Chart ` class and set the data and options according to your needs.
38
+ ### Blade
39
+
40
+ Create an instance of the ` Chart ` class and set the data and options according to your needs.
39
41
40
42
``` php
41
43
use Akaunting\Apexcharts\Chart;
42
44
43
- ...
45
+ // ...
44
46
45
47
$chart = (new Chart)->setType('donut')
46
48
->setWidth('100%')
@@ -52,11 +54,10 @@ $chart = (new Chart)->setType('donut')
52
54
Then, include the JavaScript (on every page using charts).
53
55
54
56
``` html
55
- ...
57
+ <!-- layout.blade.php -->
56
58
57
- </head >
58
59
<body >
59
- ...
60
+ <!-- ... -->
60
61
61
62
@apexchartsScripts
62
63
</body >
@@ -65,11 +66,67 @@ Then, include the JavaScript (on every page using charts).
65
66
Finally, call the ` container ` and ` script ` method wherever you want to display the chart.
66
67
67
68
``` php
69
+ <!-- dashboard.blade.php -->
70
+
68
71
{!! $chart->container() !!}
69
72
70
73
{!! $chart->script() !!}
71
74
```
72
75
76
+ ### Vue
77
+
78
+ If you're using Vue and Inertia, create a simple ` chart.vue ` component:
79
+
80
+ ``` vue
81
+ <!-- chart.vue -->
82
+
83
+ <template>
84
+ <apexchart
85
+ :type="chart.type"
86
+ :width="chart.width"
87
+ :height="chart.height"
88
+ :series="chart.series"
89
+ :options="chart.options"
90
+ />
91
+ </template>
92
+
93
+ <script setup>
94
+ defineProps({
95
+ chart: Object,
96
+ });
97
+ </script>
98
+ ```
99
+
100
+ Then, create an instance of ` Chart ` and call ` toVue() ` when passing it to your page:
101
+
102
+ ``` php
103
+ Route::get('dashboard', function () {
104
+ $chart = (new Chart)->setType('...');
105
+
106
+ return inertia('dashboard', [
107
+ 'chart' => $chart->toVue(),
108
+ ]);
109
+ });
110
+ ```
111
+
112
+ Finally, render the chart:
113
+
114
+ ``` vue
115
+ <!-- dashboard.vue -->
116
+
117
+ <template>
118
+ <Chart :chart="chart" />
119
+ </template>
120
+
121
+ <script setup>
122
+ import Chart from './components/chart.vue';
123
+
124
+ defineProps({
125
+ chart: Object,
126
+ });
127
+ </script>
128
+ ```
129
+
73
130
## Testing
74
131
75
132
``` bash
0 commit comments