Skip to content

Commit

Permalink
Code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ian-patel committed May 17, 2024
1 parent 5f56bff commit 6576013
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public function render()
$inLivewire = $chart['inLivewire'] ?? false;
$view = $inLivewire ? 'chart-template::chart-template-livewire' : Config::getChartViewName(); // Should probably add another config setting for the Livewire version

$optionsRaw = isset($chart['optionsRaw']) ? $chart['optionsRaw'] : null;
$optionsRaw = $chart['optionsRaw'] ?? null;
$optionsSimple = isset($chart['options']) ? json_encode($chart['options']) : null;
$options = $optionsRaw ? $optionsRaw : $optionsSimple;

Expand Down
5 changes: 1 addition & 4 deletions src/Providers/ChartjsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public function boot()
$this->colours = config('chartjs.colours');

// Installation and setup

$this->publishes([
__DIR__.'/../../config/chartjs.php' => config_path('chartjs.php'),
], 'config');
Expand All @@ -45,13 +44,11 @@ public function boot()
// Delivery and view injection

if(config('chartjs.delivery') == 'binary') {

if(config('chartjs.version') == 4) {
view()->composer('chart-template::chart-template', function ($view) {
$view->with('chartJsScriptv4', file_get_contents(base_path('vendor/icehouse-ventures/laravel-chartjs/dist/chart.js')));
});
}
elseif(config('chartjs.version') == 3) {
} elseif(config('chartjs.version') == 3) {
view()->composer('chart-template::chart-template', function ($view) {
$view->with('chartJsScriptv3', file_get_contents(base_path('vendor/icehouse-ventures/laravel-chartjs/dist/chart3.js')));
});
Expand Down
12 changes: 8 additions & 4 deletions src/Support/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Config
{
public static function allowedChartTypes()
{
if(self::chartJsVersion() > 3) {
if (self::chartJsVersion() > 3) {
return ['bar', 'bubble', 'scatter', 'doughnut', 'line', 'pie', 'polarArea', 'radar'];
}
return ['bar', 'horizontalBar', 'bubble', 'scatter', 'doughnut', 'line', 'pie', 'polarArea', 'radar'];
Expand All @@ -31,22 +31,26 @@ public static function dateAdapter()

public static function useCustomView()
{
if(!config('chartjs.custom_view')) {
if (!config('chartjs.custom_view')) {
return false;
}
if(config('chartjs.custom_view') === 'false') {

if (config('chartjs.custom_view') === 'false') {
return false;
}
if(config('chartjs.custom_view')) {

if (config('chartjs.custom_view')) {
return true;
}

return false;
}

public static function getChartViewName()
{
if (self::useCustomView()) {
$customViewPath = resource_path('views/vendor/laravelchartjs/custom-chart-template.blade.php');

if (File::exists($customViewPath)) {
return 'vendor.laravelchartjs.custom-chart-template';
}
Expand Down

0 comments on commit 6576013

Please sign in to comment.