Skip to content

Commit

Permalink
Merge branch 'feature/htmlable' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
leandrocfe committed Jan 14, 2025
2 parents 83859a9 + 2cbc037 commit d54f528
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 21 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## 3.1.6

- Add htmlable
- Fixed chart background
- Update docs

## 3.1.5

### Changed
Expand Down
42 changes: 33 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,15 @@ protected static ?string $heading = 'Blog Posts Chart';

Optionally, you can use the `getHeading()` method.

## Hiding header content
## Setting a widget subheading

You can hide header content by **NOT** providing these
You may set a widget subheading:

- $heading
- getHeading()
- getFormSchema()
- getOptions()
```php
protected static ?string $subheading = 'This is a subheading';
```

Optionally, you can use the `getSubheading()` method.

## Setting a chart id

Expand Down Expand Up @@ -195,8 +196,10 @@ You can also use the `getFooter()` method:
Custom view:

```php
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Contracts\View\View;
protected function getFooter(): string|View

protected function getFooter(): null|string|Htmlable|View
{
return view('custom-footer', ['text' => 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.']);
}
Expand All @@ -212,13 +215,25 @@ protected function getFooter(): string|View
Html string:

```php
use Illuminate\Support\HtmlString;
protected function getFooter(): string|View
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Contracts\View\View;
protected function getFooter(): null|string|Htmlable|View
{
return new HtmlString('<p class="text-danger-500">Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>');
}
```

## Hiding header content

You can hide header content by **NOT** providing these

- $heading
- getHeading()
- $subheading
- getSubheading()
- getFormSchema()
- getOptions()

## Filtering chart data

You can set up chart filters to change the data shown on chart. Commonly, this is used to change the time period that chart data is rendered for.
Expand Down Expand Up @@ -283,6 +298,15 @@ protected function getFormSchema(): array
}
```

### Changing the filter form width

You can change the filter form width by setting the `$filterFormWidth` property:

```php
use Filament\Support\Enums\MaxWidth;
protected static MaxWidth|string $filterFormWidth = MaxWidth::Medium;
```

### Single select

To set a default filter value, set the `$filter` property:
Expand Down
6 changes: 3 additions & 3 deletions apexcharts.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function apexcharts({
this.updateChart({
theme: { mode: theme },
chart: {
background: 'inherit'
background: this.options.chart.background || 'inherit'
}
})
}
Expand All @@ -44,7 +44,7 @@ export default function apexcharts({
initChart: function () {

this.options.theme = { mode: this.theme }
this.options.chart.background = 'inherit'
this.options.chart.background = this.options.chart.background || 'inherit'

this.options = merge(this.options, this.extraJsOptions)

Expand All @@ -55,4 +55,4 @@ export default function apexcharts({
this.chart.updateOptions(options, false, true, true)
},
}
}
}
2 changes: 1 addition & 1 deletion dist/apexcharts.js

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions src/Concerns/HasFooter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@

namespace Leandrocfe\FilamentApexCharts\Concerns;

use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Contracts\View\View;

trait HasFooter
{
protected static ?string $footer = null;

/**
* Retrieves the footer string or view object.
*
* @return null|string|\Illuminate\Contracts\View\View The footer value.
*/
protected function getFooter(): null|string|\Illuminate\Contracts\View\View
protected function getFooter(): null|string|Htmlable|View
{
return static::$footer;
}
Expand Down
7 changes: 5 additions & 2 deletions src/Concerns/HasHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Leandrocfe\FilamentApexCharts\Concerns;

use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Contracts\View\View;

trait HasHeader
{
protected static ?string $heading = null;
Expand All @@ -11,15 +14,15 @@ trait HasHeader
/**
* Retrieves the heading used in the class.
*/
protected function getHeading(): ?string
protected function getHeading(): null|string|Htmlable|View
{
return static::$heading;
}

/**
* Retrieves the subheading used in the class.
*/
protected function getSubheading(): ?string
protected function getSubheading(): null|string|Htmlable|View
{
return static::$subheading;
}
Expand Down

0 comments on commit d54f528

Please sign in to comment.