PHP code example of larawire-garage / larapex-livewire

1. Go to this page and download the library: Download larawire-garage/larapex-livewire library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

larawire-garage / larapex-livewire example snippets


// change theme from chart component

$this->chart = (new WireableAreaChart($this->chart_id))
                    ->addArea('sample-1', $this->dataSource())
                    ->theme('auto'); // support: light, dark, auto

// customize theme colors in config

'default_theme'    => 'auto',

'available_themes' => [
    'light' => [
        'background_color' => '#fff',
        'font_color'       => '#000',
    ],
    'dark'  => [
        'background_color' => '#ffffff00',
        'font_color'       => '#f1f1f1',
    ],
],

php artisan vendor:publish --tag=larapex-livewire-configs

php artisan vendor:publish --tag=larapex-livewire-assets

// layouts.app.blade.php
<body>
    <!-- Your layout HTML content -->

    @yield('scripts')

    @stack('lw_scripts')
</body> 

php artisan make:larapex YOUR_CHART_CLASS_NAME

private function dataSource(){
    // Data generating logic
}

public function build()
{
    $this->chart = (new WireableAreaChart($this->chart_id))
        ->addArea('sample-1', $this->dataSource());
}

$this->dispatch('refresh:chart', ['min' => rand(1, 5), 'max' => rand(1, 30)])->to(MyChart::class);
$this->dispatch('update:chart:options')->to(MyChart::class);
$this->dispatch('reset:chart')->to(MyChart::class);
$this->dispatch('delete:chart')->to(MyChart::class);

public function jsCallback($key, $jsFunc) 
Bash
php artisan vendor:publish --tag=larapex-livewire-configs --force