A Laravel wrapper for apex charts

Overview

Larapex Charts

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.

Installation

Use composer.

composer require arielmejiadev/larapex-charts

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 ArielMejiaDev\LarapexCharts\Facades\LarapexChart

Or importing the LarapexChart class:

use ArielMejiaDev\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() !!}
 
     <script src="{{ $chart->cdn() }}"></script>
 
     {{ $chart->script() }}
 </body>
 </html>

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, Horizantal 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.

To do for version 4

  • Add blade directive @apexchartscdn
  • Add blade directive @script($chart)
  • Add a command to generate a blade component with the boilerplate directives just to include it on any blade file.
  • Add a command to generate a vue component with all the boilerplate to just pass a chart prop and include the component on any vue component.
Comments
  • php artisan make:chart is not a recognized command

    php artisan make:chart is not a recognized command

    When entering php artisan make:chart MyChart, the command is not recognized with the error Command "make:chart" is not defined.. The command does not appear as a possible command when using php artisan list. My composer.json looks like this:

    {
        "name": "laravel/laravel",
        "type": "project",
        "description": "The Laravel Framework.",
        "keywords": [
            "framework",
            "laravel"
        ],
        "license": "MIT",
        "require": {
            "php": "^8.0",
            "ext-intl": "*",
            "ext-json": "*",
            "ext-pdo": "*",
            "arielmejiadev/larapex-charts": "^2.1",
            "barryvdh/laravel-dompdf": "^0.9.0",
            "beyondcode/laravel-websockets": "^1.12",
            "codezero/laravel-unique-translation": "^3.4",
            "fideloper/proxy": "^4.4",
            "fruitcake/laravel-cors": "^2.0",
            "grkamil/laravel-telegram-logging": "^v1.4.2",
            "guzzlehttp/guzzle": "^7.1.0",
            "laravel-arcanist/arcanist": "^0.3.0",
            "laravel/framework": "^8.6",
            "laravel/telescope": "^4.4",
            "laravel/tinker": "^2.4",
            "laravel/ui": "^3.0",
            "league/flysystem-sftp": "~1.0",
            "maatwebsite/excel": "^3.1",
            "predis/predis": "^1.1",
            "sopamo/laravel-filepond": "^0.6.1",
            "spatie/laravel-backup": "^7.5",
            "spatie/laravel-menu": "^3.6",
            "spatie/laravel-sluggable": "^2.6",
            "spatie/laravel-translatable": "^4.6",
            "spatie/menu": "^2.8",
            "tymon/jwt-auth": "^1.0"
        },
        "require-dev": {
            "barryvdh/laravel-ide-helper": "^2.7",
            "facade/ignition": "^2.3.7",
            "fzaninotto/faker": "^1.9.1",
            "imanghafoori/laravel-microscope": "dev-master",
            "laravel/dusk": "^6.10.0",
            "matt-allan/laravel-code-style": "^0.6.0",
            "mockery/mockery": "^1.4.0",
            "mrclay/shibalike": "^1.0",
            "nunomaduro/collision": "^5.0",
            "phpunit/phpunit": "^9.3"
        },
        "config": {
            "optimize-autoloader": true,
            "preferred-install": "dist",
            "sort-packages": true
        },
        "autoload": {
            "psr-4": {
                "App\\": "app/",
                "Database\\Factories\\": "database/factories/",
                "Database\\Seeders\\": "database/seeders/"
            }
        },
        "autoload-dev": {
            "psr-4": {
                "Tests\\": "tests/"
            }
        },
        "minimum-stability": "dev",
        "prefer-stable": true,
        "scripts": {
            "post-autoload-dump": [
                "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
                "@php artisan package:discover --ansi"
            ],
            "post-root-package-install": [
                "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
            ],
            "post-create-project-cmd": [
                "@php artisan key:generate --ansi"
            ],
            "check-style": "php-cs-fixer fix --dry-run --diff",
            "fix-style": "php-cs-fixer fix"
        }
    }
    
    
    opened by Eixix 7
  • Publishing stubs and commands

    Publishing stubs and commands

    The stubs and commands are published by the service provider each time the application is started, so manual removal does not help. This is the first time I encounter such strange behavior. Besides, I like the package very much.

    opened by kamilkozak 5
  • Add support for livewire

    Add support for livewire

    Hi,

    I am trying to implement larapex charts with livewire. It currently works fine.

    image

    but when I try to add buttons to change the chart with data for that button the chart is not rendered.

    image

    It seems like it cannot be re-rendered.

    Is there a solution to this issue?

    opened by roraBIH 4
  • Adding support for Sparklines chart type

    Adding support for Sparklines chart type

    Following on from this thread on Twitter.

    These are the bad boys I'm looking for!

    https://apexcharts.com/javascript-chart-demos/sparklines/basic/ https://apexcharts.com/javascript-chart-demos/dashboards/modern/

    At first look I think we can just create a new chart type class but I'm not sure, I'm going to take a look this week.

    opened by jamesmills 3
  • Can you hide all data with one button?

    Can you hide all data with one button?

    Hi,

    Firstly let me start with a huge thanks for this great package!

    I know that clicking on a legend item will show/hide it from the graph

    Interactivity with Legend Enable show/hide a series when it is clicked When a user clicks a legend, the series associated with that legend is toggled in appearance. legend: { onItemClick: { toggleDataSeries: true }, }

    I was wondering if anyone has a working example using this package where you can add a button to show/hide all series data or select which is shown on loading the graph?

    Thanks in advance!

    James

    opened by jamesmills 3
  • :heavy_plus_sign: Adding required dependency: php version

    :heavy_plus_sign: Adding required dependency: php version

    Added the php version required to the composer file. The code used doesn't work below php7.

    More specifically scalar type hints. See here:

    https://3v4l.org/Mp7GNj

    opened by ordago 3
  • setting custom tags

    setting custom tags

    Hi there,

    Thank you for the package, its excellent to work with. Have you considered adding the ability to set custom tags, such as setCustom('sparkline: {enabled: !0}');

    opened by ecoplace 3
  • Installation failed with Laravel 9

    Installation failed with Laravel 9

    $ composer require arielmejiadev/larapex-charts
    Using version ^3.0 for arielmejiadev/larapex-charts
    ./composer.json has been updated
    Running composer update arielmejiadev/larapex-charts
    Loading composer repositories with package information
    Updating dependencies
    Your requirements could not be resolved to an installable set of packages.
    
      Problem 1
        - arielmejiadev/larapex-charts[3.0.0, ..., 3.0.1] require illuminate/support ^8.0 -> found illuminate/support[v8.0.0, ..., 8.x-dev] but these were not loaded, likely because it conflicts with another require.
        - Root composer.json requires arielmejiadev/larapex-charts ^3.0 -> satisfiable by arielmejiadev/larapex-charts[3.0.0, 3.0.1].
    

    This is a completely fresh install of a new Laravel 9 app based on Laravel 9 docs:

    composer create-project laravel/laravel example-app
    cd example-app
    php artisan serve
    

    I am out of my depth here but maybe something to do with illuminate/support being replaced by laravel/framework?

    opened by eina84 2
  • Tooltip / hover not working well

    Tooltip / hover not working well

    https://gyazo.com/0036b5a5d371f8bed4a42d3055f1f892

    The hover to show the data only shows when you hover on the labels it self. Tried to pull in the latest cdn and host the js files myself but that didn't work.

    Cheers :)

    opened by JessedeB 2
  • copy(app/Console/Commands/ChartMakeCommand.php): Failed to open stream: Permission denied

    copy(app/Console/Commands/ChartMakeCommand.php): Failed to open stream: Permission denied

    Hi @ArielMejiaDev ! I'm having problems updating from php 7.4 to 8.0. I'm using Vagrant + Homestead and your package throws me this error:

    copy(/home/vagrant/code/<project>/app/Console/Commands/ChartMakeCommand.php): Failed to open stream: Permission denied

    image

    Any ideas? The command file already exists

    opened by magarrent 2
  • Stubs and Commands

    Stubs and Commands

    Hello, thanks for a wonderful package. Is it possible to do away with the automatic creation of stubs and commands... I find them not useful at the moment

    opened by MainaUrbanus 2
  • Formatting of yaxis and labels

    Formatting of yaxis and labels

    As seen on ApexCharts, there is a possibility of formatting y-axis and labels, also seen an issue posted before, which was closed.

    Is this a feature not documented? I have tried looking through the code, don't see anything obvious.

    opened by AaronNeonDigital 0
  • setSparkline returns undefined method

    setSparkline returns undefined method

    Great work on the library.

    I've just upgraded to v5 for the setSparkline support. Unfortunately I get the following error:

    Call to undefined method ArielMejiaDev\LarapexCharts\LineChart::setSparkline()

    Chart code:

    public function build(): LineChart
        {
            return $this->chart->lineChart()
                ->addData('Physical sales', [40, 93, 35, 42, 18, 82])
                ->setSparkline();
        }
    

    I've tried to debug as much as I can but can't get to the bottom of it. I'm running version 5.1.0.

    opened by rgbaman 0
  • Support

    Support "Stacked" Option.

    I've been a user of this package for quite some time! Nice package indeed! Just threw an PR hoping that "stacked" option is going to be available too!

    opened by k-masatany 0
  • add options to custom override config in chart

    add options to custom override config in chart

    example usage public function build(): \ArielMejiaDev\LarapexCharts\LineChart { return $this->chart->lineChart() ->setHeight(150) //->setTitle('Sales during 2021.') //->setSubtitle('Physical sales vs Digital sales.') ->addData('Physical sales', [40, 93, 35, 42, 18, 82]) //->addData('Digital sales', [70, 29, 77, 28, 55, 45]) //->setXAxis(['January', 'February', 'March', 'April', 'May', 'June']) ->setOptions([ 'xaxis' => [ 'labels' => ['show' => false] ] ]) ; } in this example i override value from xaxis.labels.show to false, default is true

    opened by pandigresik 3
Releases(5.2.0)
  • 5.2.0(Sep 19, 2022)

  • 5.1.0(Sep 18, 2022)

    it fixes an issue related to a pour readable method.

    Charts by default would work without grid.

    To add a default grid (gray and some opacity... plays really well with TailwindUI styles)

    $chart->areaChart()->setGrid();
    To customize the grid color and opacity you can pass params to the grid setter:
    
    $chart->areaChart()->setGrid('#93c5fd', 0.2);
    
    Source code(tar.gz)
    Source code(zip)
  • 5.0.0(Sep 18, 2022)

    It fixes this issues:

    The stubs and commands are published by the service provider each time the application is started It should be only published on vendor:publish. No every time. It will break on anything hosted on serverless (by publishing files on every request).

    reference here: https://github.com/ArielMejiaDev/larapex-charts/issues/40

    Source code(tar.gz)
    Source code(zip)
  • 4.1.0(Jul 12, 2022)

  • 4.0.0(Mar 10, 2022)

  • 3.0.1(Jul 27, 2021)

  • 3.0.0(Jul 27, 2021)

  • 2.1.1(Jun 24, 2021)

  • 2.1.0(Feb 15, 2021)

  • 2.0.0(Feb 14, 2021)

    New release adding lot of cool features:

    New Charts:

    • Radial Bar Chart
    • Radar Chart
    • Polar Area Chart

    New Methods:

    • setMarkers(), to add markers on every chart series.
    • zoom(), to show or hide the zoom button (available only on blade views).
    • setToolbar(), to show or hide the top right corner chart toolbar.
    • addData method to add data in shorter and expressive way (it work with all charts).
    • addBar() an alias of addData() method to add data in a more eloquent way for bar * horizontal bar charts.
    • addLine() an alias of addData() method to add data in a more eloquent way for a line chart.
    • addArea() an alias of addData() method to add data in a more eloquent way for an area chart.
    • more addData() aliases based on the chart type.
    • charts constructors (now you do not need to remember and pass the chart type a string, there are constructors for every chart).
    • pieChart(), donutChart(), radialBarChart(), polarAreaChart(), lineChart(), areaChart(), barChart(), horizontalBarChart(), heatMapChart(), radarChart()

    Changes on existing methods:

    • setGrid, now add more params to customize more the charts.

    Deprecated methods:

    • setType() in version 1.0.0 to 1.0.5 this method set the type of chart property, now the package has more chart classes behind so this method is not necessary any more, its recommended to use instead the chart constructor methods, like for example in line chart lineChart().

    • setData you are still able to add data manually, but it is recommended to use the method addData()and all its aliases based on the chart type to get shorter, fluent and expressive syntax.

    In the next yearly release (2023) this methods would be deleted from the package.

    Source code(tar.gz)
    Source code(zip)
  • 1.0.5(Feb 7, 2020)

    Patch release.

    Remove the Facade of the package to avoid confution, Facades woks fine as single instance, but with more than one chart on the same method it would override data, to avoid the confution the Facade LarapexChart is removed since this version.

    Source code(tar.gz)
    Source code(zip)
  • 1.0.4(Jan 16, 2020)

  • 1.0.3(Jan 15, 2020)

  • 1.0.2(Jan 15, 2020)

  • 1.0.1(Jan 15, 2020)

  • 1.0.0(Jan 14, 2020)

Owner
ArielMejiaDev
Laravel | VueJS | Opensource | InertiaJS
ArielMejiaDev
Laravel component to create gorgeous Charts.css charts.

Laravel component to create gorgeous Charts.css charts. This package will help you generate CSS only charts based on the Charts.css library. Installat

Maarten Paauw 105 Sep 26, 2022
Charts - a Laravel library used to create Charts using Chartisan

Charts is a Laravel library used to create Charts using Chartisan. Chartisan does already have a PHP adapter. However, this library attempts to provide more laravel-like features into it by providing support for chart creation using the artisan command, middleware support and routing support.

Mohammad 2 Mar 14, 2022
Laravel charts is a package to simplify the use of charts.

Laravel Charts Laravel charts is a package to simplify the use of charts. Features Autoregister your charts Customize routing, middleware and prefix t

Datalogix 2 Aug 5, 2022
Generate trends for your models. Easily generate charts or reports.

Laravel Trend Generate trends for your models. Easily generate charts or reports. Support us Like our work? You can support us by purchasing one of ou

Flowframe 139 Dec 27, 2022
Opensource tinyman charts software

This software is live at https://freetinycharts.ovh How-to install: In a linux box with apache,php & mysql, as root: Unpack zip mkdir /scripts/ cp *.p

Pablo Manuel Castelo Vigo 14 Dec 8, 2022
Mollie API client wrapper for Laravel & Mollie Connect provider for Laravel Socialite

Mollie for Laravel Laravel-Mollie incorporates the Mollie API and Mollie Connect into your Laravel or Lumen project. Accepting iDEAL, Apple Pay, Banco

Mollie 289 Nov 24, 2022
A Laravel Wrapper for the CoinDCX API. Now easily connect and consume the CoinDCX Public API in your Laravel apps without any hassle.

This package provides a Laravel Wrapper for the CoinDCX API and allows you to easily communicate with it. Important Note This package is in early deve

Moinuddin S. Khaja 2 Feb 16, 2022
A CommonMark wrapper for Laravel

Laravel Markdown Laravel Markdown was created by, and is maintained by Graham Campbell, and is a CommonMark wrapper for Laravel. It ships with integra

Graham Campbell 1.2k Jan 2, 2023
Laravel wrapper package for the Aimon.it API

Laravel Aimon Package A laravel wrapper package for the Aimon.it API. For more information see Aimon Requirements Laravel 6 or later Installation Inst

Ruslan 3 Aug 7, 2022
PayuMoney Gateway wrapper for Laravel.

PayuMoney Integration with Laravel Easy to use integration for PayUMoney into Laravel apps. Video Tutorial Usage composer require infyomlabs/laravel-p

InfyOmLabs (InfyOm Technologies) 10 Nov 29, 2022
A Laravel wrapper for spatie/dns. Allows to query and validate DNS records.

A Laravel wrapper for spatie/dns. Allows to query and validate DNS records.

Astrotomic 22 Nov 17, 2022
Laravel API wrapper to interact fluently with your Janus Media Server

Laravel API wrapper to interact fluently with your Janus Media Server. Core server interactions, as well as the video room plugin included.

Richard  Tippin 11 Aug 21, 2022
A laravel wrapper for BnpParibas Mercanet payment gateway

Laravel Mercanet A laravel wrapper for BnpParibas Mercanet which provide a lightweight public api to process your online payments from your laravel ap

Mouad ZIANI 29 Nov 27, 2022
Open Food Facts API wrapper for Laravel

Laravel Open Food Facts API This package provides a convenient wrapper to the Open Food Facts API for Laravel applications (5.7+). Installation You ca

Open Food Facts 112 Jan 4, 2023
a Google API v3 wrapper for Laravel 4.x

A Google API v3 wrapper for Laravel 4 This package enables a Laravel flavoured way to manage Google services through its API interface (v3) Installati

null 4 Nov 29, 2022
27Laracurl Laravel wrapper package for PHP cURL class that provides OOP interface to cURL. [10/27/2015] View Details

Laracurl Laravel cURL Wrapper for Andreas Lutro's OOP cURL Class Installation To install the package, simply add the following to your Laravel install

zjango 8 Sep 9, 2018
Laravel wrapper for Sentry Official API

Laravel Sentry API Provides a simple laravel wrapper to some of the endpoints listed on (Official Sentry API)[https://docs.sentry.io/api/]. **Note: Th

Pedro Santiago 1 Nov 1, 2021
A wrapper package to run mysqldump from laravel console commands.

A wrapper package to run mysqldump from laravel console commands.

Yada Khov 24 Jun 24, 2022
Laravel wrapper for the Gmail API

Laravel Gmail Gmail Gmail API for Laravel 8 You need to create an application in the Google Console. Guidance here. if you need Laravel 5 compatibilit

Daniel Castro 244 Jan 3, 2023