diff --git a/README.md b/README.md
index f119ac2..a049c42 100755
--- a/README.md
+++ b/README.md
@@ -44,12 +44,14 @@ Livewire Charts supports out of the box the following types of charts
- Pie Chart (`LivewirePieChart` component)
- Column/Multi Line Chart (`LivewireColumnChart` component)
- Area Chart (`LivewireAreaChart` component)
+- Radar Chart (`LivewireRadarChart` component)
Each one comes with its own "model" class that allows you to define the chart's data and render behavior.
- `LivewireLineChart` uses `LineChartModel` to set up data points, markers, events and other ui customizations.
- `LivewirePieChart` uses `PieChartModel` to set up data slices, events and other ui customizations.
- `LivewireColumnChart` uses `ColumnChartModel` to set up data columns, events and other ui customizations.
- `LivewireAreaChart` uses `AreaChartModel` to set up data points, events and other ui customizations.
+- `LivewireRadarChart` uses `RadarChartModel` to set up data points, events and other ui customizations.
For example, to render a column chart, we can create an instance of `ColumnChartModel` and add some data to it
```php
@@ -97,6 +99,7 @@ LivewireCharts::columnChartModel();
LivewireCharts::multiColumnChartModel();
LivewireCharts::pieChartModel();
LivewireCharts::areaChartModel();
+LivewireCharts::radarChartModel();
```
## Enabling Interactions
@@ -157,7 +160,7 @@ The parent component renders the charts as follows
For each chart, a specific model class needs to be used. Here, it is detailed the api available
for each type of chart.
-#### All
+### All
| Method | Description |
|--------|-------------|
@@ -174,7 +177,7 @@ for each type of chart.
| sparklined() | Enables Apex Charts sparkline feature |
| setSparklineEnabled(boolean $isEnabled) | Enables/Disables Apex Charts sparkline feature |
-#### LivewireLineChart
+### LivewireLineChart
| Method | Description |
|--------|-------------|
@@ -185,7 +188,7 @@ for each type of chart.
| addMarker(string $title, double $value) | Adds a marker point to the line chart. Markers are used to emphasize particular points in the chart (singleLine only) |
| withOnPointClickEvent(string $eventName) | Event Name that will be fired when a point/marker of the chart is clicked |
-#### LivewireColumnChart
+### LivewireColumnChart
| Method | Description |
|--------|-------------|
@@ -199,7 +202,7 @@ for each type of chart.
| addSeriesColumn(string $seriesName, string $title, double $value, array $extras = []) | Adds a column to a multicolumn chart. `$extras` is forwarded on click event |
| onColumnClickEventName(string $eventName) | Event Name that will be fired when a column of the chart is clicked |
-#### LivewirePieChart
+### LivewirePieChart
| Method | Description |
|--------|-------------|
@@ -207,7 +210,7 @@ for each type of chart.
| addSlice(string $title, double $value, string $color, array $extras = []) | Adds a slice to the chart with the specified color. `$extras` is forwarded on click event |
| withOnSliceClickEvent(string $eventName) | Event Name that will be fired when a column of the chart is clicked |
-#### LivewireAreaChart
+### LivewireAreaChart
| Method | Description |
|--------|-------------|
@@ -216,6 +219,13 @@ for each type of chart.
| setXAxisVisible(boolean $visible) | Shows/hides xAxis labels |
| setYAxisVisible(boolean $visible) | Shows/hides yAxis labels |
+### LivewireRadarChart
+
+| Method | Description |
+|--------|-------------|
+| addSeries(string $seriesName, string $title, double $value, array $extras = []) | |
+| withOnPointClickEvent(string $eventName) | Event Name that will be fired when a point of the chart is clicked |
+
## Advanced Usage - Integrating Scripts
The directive `@livewireChartsScripts` adds a `script` tag that includes `public/vendor/livewire-charts/app.js`.
diff --git a/resources/views/livewire-radar-chart.blade.php b/resources/views/livewire-radar-chart.blade.php
new file mode 100644
index 0000000..94ad8bb
--- /dev/null
+++ b/resources/views/livewire-radar-chart.blade.php
@@ -0,0 +1,102 @@
+
+
diff --git a/src/Charts/LivewireRadarChart.php b/src/Charts/LivewireRadarChart.php
new file mode 100644
index 0000000..48690e3
--- /dev/null
+++ b/src/Charts/LivewireRadarChart.php
@@ -0,0 +1,36 @@
+radarChartModel = $radarChartModel->toArray();
+ }
+
+ public function onPointClick($point)
+ {
+ $onPointClickEventName = data_get($this->radarChartModel, 'onPointClickEventName', null);
+
+ if ($onPointClickEventName === null) {
+ return;
+ }
+
+ $this->emit($onPointClickEventName, $point);
+ }
+
+ public function render()
+ {
+ return view('livewire-charts::livewire-radar-chart');
+ }
+}
diff --git a/src/Facades/LivewireCharts.php b/src/Facades/LivewireCharts.php
index 6ea734e..f5f3de2 100644
--- a/src/Facades/LivewireCharts.php
+++ b/src/Facades/LivewireCharts.php
@@ -6,6 +6,7 @@ use Asantibanez\LivewireCharts\Models\AreaChartModel;
use Asantibanez\LivewireCharts\Models\ColumnChartModel;
use Asantibanez\LivewireCharts\Models\LineChartModel;
use Asantibanez\LivewireCharts\Models\PieChartModel;
+use Asantibanez\LivewireCharts\Models\RadarChartModel;
use Illuminate\Support\Facades\Facade;
/**
@@ -17,6 +18,7 @@ use Illuminate\Support\Facades\Facade;
* @method static ColumnChartModel multiColumnChartModel()
* @method static AreaChartModel areaChartModel()
* @method static PieChartModel pieChartModel()
+ * @method static RadarChartModel radarChartModel()
*/
class LivewireCharts extends Facade
{
diff --git a/src/LivewireCharts.php b/src/LivewireCharts.php
index 1ffaf98..c898458 100644
--- a/src/LivewireCharts.php
+++ b/src/LivewireCharts.php
@@ -8,6 +8,7 @@ use Asantibanez\LivewireCharts\Models\AreaChartModel;
use Asantibanez\LivewireCharts\Models\ColumnChartModel;
use Asantibanez\LivewireCharts\Models\LineChartModel;
use Asantibanez\LivewireCharts\Models\PieChartModel;
+use Asantibanez\LivewireCharts\Models\RadarChartModel;
class LivewireCharts
{
@@ -44,4 +45,9 @@ class LivewireCharts
{
return new PieChartModel;
}
+
+ public function radarChartModel()
+ {
+ return new RadarChartModel();
+ }
}
diff --git a/src/LivewireChartsServiceProvider.php b/src/LivewireChartsServiceProvider.php
index d408f69..63de245 100755
--- a/src/LivewireChartsServiceProvider.php
+++ b/src/LivewireChartsServiceProvider.php
@@ -6,6 +6,7 @@ use Asantibanez\LivewireCharts\Charts\LivewireAreaChart;
use Asantibanez\LivewireCharts\Charts\LivewireColumnChart;
use Asantibanez\LivewireCharts\Charts\LivewireLineChart;
use Asantibanez\LivewireCharts\Charts\LivewirePieChart;
+use Asantibanez\LivewireCharts\Charts\LivewireRadarChart;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
use Livewire\Livewire;
@@ -56,6 +57,7 @@ class LivewireChartsServiceProvider extends ServiceProvider
Livewire::component('livewire-column-chart', LivewireColumnChart::class);
Livewire::component('livewire-pie-chart', LivewirePieChart::class);
Livewire::component('livewire-area-chart', LivewireAreaChart::class);
+ Livewire::component('livewire-radar-chart', LivewireRadarChart::class);
}
private function registerDirectives()
diff --git a/src/Models/RadarChartModel.php b/src/Models/RadarChartModel.php
new file mode 100644
index 0000000..4dacca0
--- /dev/null
+++ b/src/Models/RadarChartModel.php
@@ -0,0 +1,95 @@
+onPointClickEventName = null;
+
+ $this->opacity = 0.5;
+
+ $this->colors = ['#2E93fA', '#66DA26', '#546E7A', '#E91E63', '#FF9800'];
+
+ $this->data = collect();
+ }
+
+ public function setColors($colors)
+ {
+ $this->colors = $colors;
+
+ return $this;
+ }
+
+ public function setOpacity($opacity)
+ {
+ $this->opacity = $opacity;
+
+ return $this;
+ }
+
+ public function withOnPointClickEvent($onPointClickEventName)
+ {
+ $this->onPointClickEventName = $onPointClickEventName;
+
+ return $this;
+ }
+
+
+ public function addSeries($seriesName, $title, $value, $extras = [])
+ {
+ $series = $this->data->get($seriesName, collect());
+
+ $series->push([
+ 'seriesName' => $seriesName,
+ 'title' => $title,
+ 'value' => $value,
+ 'extras' => $extras,
+ ]);
+
+ $this->data->put($seriesName, $series);
+
+ return $this;
+ }
+
+ public function toArray()
+ {
+ return array_merge(parent::toArray(), [
+ 'onPointClickEventName' => $this->onPointClickEventName,
+ 'opacity' => $this->opacity,
+ 'colors' => $this->colors,
+ 'data' => $this->data->toArray(),
+ ]);
+ }
+
+ public function fromArray($array)
+ {
+ parent::fromArray($array);
+
+ $this->onPointClickEventName = data_get($array, 'onPointClickEventName', null);
+
+ $this->opacity = data_get($array, 'opacity', 0.5);
+
+ $this->colors = data_get($array, 'color', '#90cdf4');
+
+ $this->data = collect(data_get($array, 'data', []));
+ }
+}