定制 vnuswilliams/larapex-charts 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

vnuswilliams/larapex-charts

Composer 安装命令:

composer require vnuswilliams/larapex-charts

包简介

Package to provide easy api to build apex charts on Laravel

README 文档

README

MadeWithLaravel.com shield

Latest Stable Version

Total Downloads

GitHub Actions

License

A Laravel wrapper for apex charts library Check the documentation on: Larapex Chart Docs.

This repository is inspired by ArielMejiaDev/larapex-charts and gives full credit to the original project.

Installation

Install the Laravel package with Composer:

composer require vnuswilliams/larapex-charts

You can also install ApexCharts in your frontend bundle (optional):

npm install apexcharts --save

Then import it in your app.js (or any other frontend entry file):

import ApexCharts from 'apexcharts'
window.ApexCharts = ApexCharts

This npm/Vite setup is optional if you prefer using the CDN, or if ApexCharts is already available in your project.

Usage

Basic example

In your controller add:

$chart = (new LarapexChart)->setTitle('Posts')
                   ->setDataset([150, 120])
                   ->setLabels(['Published', 'No Published']);

Remember to import the Facade to your controller with

use vnusWilliams\LarapexCharts\Facades\LarapexChart;

Or importing the LarapexChart class:

use vnusWilliams\LarapexCharts\LarapexChart;

Then in your view (Blade file) add:

 <!doctype html>
 <html lang="en">
 <head>
     <meta charset="UTF-8">
     <meta name="viewport"
           content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
     <meta http-equiv="X-UA-Compatible" content="ie=edge">
     <title>Chart Sample</title>
 </head>
 <body>
 
     {!! $chart->container() !!}
 
     {{ $chart->script() }}
 </body>
 </html>

$chart->script() first uses window.ApexCharts (useful when ApexCharts is loaded via npm/Vite), and automatically falls back to the CDN only if ApexCharts is not already available globally.

Livewire support (v2 & v3)

If you render charts inside Livewire components (including conditional rendering/tabs/selectors), keep using the same API:

{!! $chart->container() !!}

Then place the global script directive once in your main layout (before </body>):

@larapexChartScripts

The directive now automatically:

  • initializes all charts found in the page,
  • re-initializes charts after Livewire DOM updates,
  • destroys stale chart instances when elements disappear,
  • keeps working normally in non-Livewire projects.

Optional: if you update data from Livewire and need a full page chart refresh, emit:

$this->dispatch('larapex:refresh'); // Livewire v3

or

$this->emit('larapex:refresh'); // Livewire v2

More complex example

$chart = (new LarapexChart)->setType('area')
        ->setTitle('Total Users Monthly')
        ->setSubtitle('From January to March')
        ->setXAxis([
            'Jan', 'Feb', 'Mar'
        ])
        ->setDataset([
            [
                'name'  =>  'Active Users',
                'data'  =>  [250, 700, 1200]
            ]
        ]);

You can create a variety of charts including: Line, Area, Bar, Horizontal Bar, Heatmap, pie, donut and Radialbar.

More examples

Check the documentation on: Larapex Chart Docs

Contributing

The author Ariel Mejia Dev.

License

MIT

Support the project

Hey 👋 thanks for considering making a donation, with these donations I can continue working to contribute to opensource projects.

Roadmap for future versions

  • Add blade directive @apexchartscdn
  • Add blade directive @script($chart)
  • Add a chain options setter for charts
  • Update Github Actions to run tests
  • Update the package in general for more efficient & modern practices (spatie skeleton package)
  • Add ReactJS + Inertia Support
  • Add More complex charts
  • Add More complex boilerplate code using Laravel/Prompts
  • Add more complex boilerplate code examples using Laravel Trends Package

统计信息

  • 总下载量: 32
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固