Skip to content

Commit

Permalink
Made ability to add multiple packages
Browse files Browse the repository at this point in the history
  • Loading branch information
daredloco committed Aug 7, 2023
1 parent 6c322c9 commit 62b39ca
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/LagoonServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Helvetitec\LagoonCharts;

use Exception;
use Helvetitec\LagoonCharts\Http\Livewire\LineChart;
use Helvetitec\LagoonCharts\Http\Livewire\PieChart;
use Helvetitec\LagoonCharts\Http\Livewire\AreaChart;
Expand Down Expand Up @@ -35,10 +36,26 @@ public function boot()
Livewire::component('lagoon-waterfall-chart', WaterfallChart::class);
Livewire::component('lagoon-timeline', Timeline::class);

Blade::directive('lagoonScripts', function ($localization, $package = 'corechart') {
Blade::directive('lagoonScripts', function ($localization, $packages = 'corechart') {
if(is_array($packages)){
$packagesStr = '[';
foreach($packages as $package)
{
if($packagesStr != '[')
{
$packagesStr .= ',';
}
$packagesStr .= $package;
}
$packagesStr .= ']';

$packages = $packagesStr;
}else{
$packages = '['.$packages.']';
}
return '<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load(\'current\', {\'packages\':[\''.$package.'\'], \'language\': \''.$localization.'\'});
google.charts.load(\'current\', {\'packages\':[\''.$packages.'\'], \'language\': \''.$localization.'\'});
</script>';
});

Expand Down

0 comments on commit 62b39ca

Please sign in to comment.