composer update
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace ConsoleTVs\Charts\Features\C3;
|
||||
|
||||
trait Chart
|
||||
{
|
||||
/**
|
||||
* Determines if the chart legend will be displayed.
|
||||
*
|
||||
* @param bool $display
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function legend(bool $display)
|
||||
{
|
||||
return $this->options([
|
||||
'legend' => [
|
||||
'show' => $display,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the chart grid will be shown.
|
||||
*
|
||||
* @param bool $display
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function grid(bool $display)
|
||||
{
|
||||
return $this->options([
|
||||
'grid' => [
|
||||
'x' => [
|
||||
'show' => $display,
|
||||
],
|
||||
'y' => [
|
||||
'show' => $display,
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the chart tooltip will be shown.
|
||||
*
|
||||
* @param bool $display
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function tooltip(bool $display)
|
||||
{
|
||||
return $this->options([
|
||||
'tooltip' => [
|
||||
'show' => $display,
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace ConsoleTVs\Charts\Features\C3;
|
||||
|
||||
trait Dataset
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
namespace ConsoleTVs\Charts\Features\Chartjs;
|
||||
|
||||
trait Chart
|
||||
{
|
||||
/**
|
||||
* Minalist chart display (Hide labels and axes).
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function minimalist(bool $display)
|
||||
{
|
||||
$this->displayLegend(!$display);
|
||||
|
||||
return $this->displayAxes(!$display);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the chart legend.
|
||||
*
|
||||
* @param bool $legend
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function displayLegend(bool $legend)
|
||||
{
|
||||
return $this->options([
|
||||
'legend' => [
|
||||
'display' => $legend,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the chart axis.
|
||||
*
|
||||
* @param bool $axes
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function displayAxes(bool $axes, bool $strict = false)
|
||||
{
|
||||
if ($strict) {
|
||||
return $this->options([
|
||||
'scale' => [
|
||||
'display' => $axes,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->options([
|
||||
'scales' => [
|
||||
'xAxes' => [
|
||||
[
|
||||
'display' => $axes,
|
||||
],
|
||||
],
|
||||
'yAxes' => [
|
||||
[
|
||||
'display' => $axes,
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the bar width of the X Axis.
|
||||
*
|
||||
* @param float $width
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function barWidth(float $width)
|
||||
{
|
||||
return $this->options([
|
||||
'scales' => [
|
||||
'xAxes' => [
|
||||
[
|
||||
'barPercentage' => $width,
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the chart title.
|
||||
*
|
||||
* @param string $title
|
||||
* @param int $font_size
|
||||
* @param string $color
|
||||
* @param string $font_weight
|
||||
* @param string $font_family
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function title(
|
||||
string $title,
|
||||
int $font_size = 14,
|
||||
string $color = '#666',
|
||||
string $font_weight = 'bold',
|
||||
string $font_family = "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif"
|
||||
) {
|
||||
return $this->options([
|
||||
'title' => [
|
||||
'display' => true,
|
||||
'fontFamily' => $font_family,
|
||||
'fontSize' => $font_size,
|
||||
'fontColor' => $color,
|
||||
'fontStyle' => $font_weight,
|
||||
'text' => $title,
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace ConsoleTVs\Charts\Features\Chartjs;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
trait Dataset
|
||||
{
|
||||
/**
|
||||
* Set the dataset border color.
|
||||
*
|
||||
* @param string|array|Collection $color
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function color($color)
|
||||
{
|
||||
if ($color instanceof Collection) {
|
||||
$color = $color->toArray();
|
||||
}
|
||||
|
||||
return $this->options([
|
||||
'borderColor' => $color,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the dataset background color.
|
||||
*
|
||||
* @param string|array|Collection $color
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function backgroundColor($color)
|
||||
{
|
||||
if ($color instanceof Collection) {
|
||||
$color = $color->toArray();
|
||||
}
|
||||
|
||||
return $this->options([
|
||||
'backgroundColor' => $color,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the dataset is filled.
|
||||
*
|
||||
* @param bool $filled
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function fill(bool $filled)
|
||||
{
|
||||
return $this->options([
|
||||
'fill' => $filled,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the chart line tension.
|
||||
*
|
||||
* @param int $tension
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function lineTension(float $tension)
|
||||
{
|
||||
return $this->options([
|
||||
'lineTension' => $tension,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the line to a dashed line in the chart options.
|
||||
*
|
||||
* @param array $dashed
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function dashed(array $dashed = [5])
|
||||
{
|
||||
return $this->options([
|
||||
'borderDash' => $dashed,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
|
||||
namespace ConsoleTVs\Charts\Features\Echarts;
|
||||
|
||||
trait Chart
|
||||
{
|
||||
/**
|
||||
* Show or hide the chart legend.
|
||||
*
|
||||
* @param bool $legend
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function displayLegend(bool $legend)
|
||||
{
|
||||
return $this->options([
|
||||
'legend' => [
|
||||
'show' => $legend,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show or hide the tooltip.
|
||||
*
|
||||
* @param bool $tooltip
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function tooltip(bool $tooltip)
|
||||
{
|
||||
return $this->options([
|
||||
'tooltip' => [
|
||||
'show' => $tooltip,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the chart label.
|
||||
*
|
||||
* @param string $label
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function label(string $label)
|
||||
{
|
||||
return $this->options([
|
||||
'yAxis' => [
|
||||
'name' => $label,
|
||||
'nameLocation' => 'middle',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the minimalistic.
|
||||
*
|
||||
* @param bool $minimalist
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function minimalist(bool $minimalist = true)
|
||||
{
|
||||
$this->displayAxes(!$minimalist);
|
||||
$this->displayLegend(!$minimalist);
|
||||
|
||||
return $this->options([
|
||||
'xAxis' => [
|
||||
'axisLabel' => [
|
||||
'show' => !$minimalist,
|
||||
],
|
||||
'splitLine' => [
|
||||
'show' => !$minimalist,
|
||||
],
|
||||
],
|
||||
'yAxis' => [
|
||||
'axisLabel' => [
|
||||
'show' => !$minimalist,
|
||||
],
|
||||
'splitLine' => [
|
||||
'show' => !$minimalist,
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the chart axes.
|
||||
*
|
||||
* @param bool $display
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function displayAxes(bool $display)
|
||||
{
|
||||
return $this->options([
|
||||
'xAxis' => [
|
||||
'show' => $display,
|
||||
'axisLine' => [
|
||||
'show' => $display,
|
||||
],
|
||||
'axisTick' => [
|
||||
'show' => $display,
|
||||
],
|
||||
],
|
||||
'yAxis' => [
|
||||
'show' => $display,
|
||||
'axisLine' => [
|
||||
'show' => $display,
|
||||
],
|
||||
'axisTick' => [
|
||||
'show' => $display,
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* ALlow to export the chart.
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function export(bool $export = true, string $title = ' ')
|
||||
{
|
||||
return $this->options([
|
||||
'toolbox' => [
|
||||
'show' => true,
|
||||
'feature' => [
|
||||
'saveAsImage' => [
|
||||
'title' => $title,
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the chart title.
|
||||
*
|
||||
* @param string $title
|
||||
* @param int $font_size
|
||||
* @param string $color
|
||||
* @param bool $bold
|
||||
* @param string $font_family
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function title(
|
||||
string $title,
|
||||
int $font_size = 14,
|
||||
string $color = '#666',
|
||||
bool $bold = true,
|
||||
string $font_family = "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif"
|
||||
) {
|
||||
return $this->options([
|
||||
'title' => [
|
||||
'show' => true,
|
||||
'text' => $title,
|
||||
'textStyle' => [
|
||||
'fontFamily' => $font_family,
|
||||
'fontSize' => $font_size,
|
||||
'color' => $color,
|
||||
'fontWeight' => $bold,
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the chart theme.
|
||||
*
|
||||
* @param string $theme
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function theme(string $theme)
|
||||
{
|
||||
$this->theme = $theme;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace ConsoleTVs\Charts\Features\Echarts;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
trait Dataset
|
||||
{
|
||||
/**
|
||||
* Set the dataset color.
|
||||
*
|
||||
* @param string|array|Collection $color
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function color($color)
|
||||
{
|
||||
if ($color instanceof Collection) {
|
||||
$color = $color->toArray();
|
||||
}
|
||||
|
||||
return $this->options([
|
||||
'color' => $color,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
namespace ConsoleTVs\Charts\Features\Frappe;
|
||||
|
||||
trait Chart
|
||||
{
|
||||
/**
|
||||
* Add a title to the Chart.
|
||||
*
|
||||
* @param string $title
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function title(string $title)
|
||||
{
|
||||
return $this->options([
|
||||
'title' => $title,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the spaceRatio of the bars.
|
||||
*
|
||||
* @param float $space
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function spaceRatio(float $space = 0.75)
|
||||
{
|
||||
return $this->options([
|
||||
'barOptions' => [
|
||||
'spaceRatio' => $space,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the bars are stacked.
|
||||
*
|
||||
* @param bool $stacked
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function stacked(bool $stacked)
|
||||
{
|
||||
return $this->options([
|
||||
'barOptions' => [
|
||||
'stacked' => $stacked,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the chart interactive with arrow keys and highlights the current active data point.
|
||||
*
|
||||
* @param bool $stacked
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function isNavigable(bool $value)
|
||||
{
|
||||
return $this->options([
|
||||
'isNavigable' => $value,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* To display data values over bars or dots in an axis graph.
|
||||
*
|
||||
* @param bool $stacked
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function valuesOverPoints(bool $value)
|
||||
{
|
||||
return $this->options([
|
||||
'valuesOverPoints' => $value,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the lines will show a dot.
|
||||
*
|
||||
* @param bool $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function hideDots(bool $value)
|
||||
{
|
||||
return $this->options([
|
||||
'lineOptions' => [
|
||||
'hideDots' => $value,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the line will be hidden.
|
||||
*
|
||||
* @param bool $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function hideLine(bool $value)
|
||||
{
|
||||
return $this->options([
|
||||
'lineOptions' => [
|
||||
'hideDots' => $value,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the line will be a heatline.
|
||||
*
|
||||
* @param bool $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function heatline(bool $value)
|
||||
{
|
||||
return $this->options([
|
||||
'lineOptions' => [
|
||||
'heatline' => $value,
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace ConsoleTVs\Charts\Features\Frappe;
|
||||
|
||||
trait Dataset
|
||||
{
|
||||
/**
|
||||
* Determines the color of the dataset.
|
||||
*
|
||||
* @param string $color
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function color(string $color)
|
||||
{
|
||||
return $this->options([
|
||||
'color' => $color,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace ConsoleTVs\Charts\Features\Fusioncharts;
|
||||
|
||||
trait Chart
|
||||
{
|
||||
/**
|
||||
* Set the chart label.
|
||||
*
|
||||
* @param string $label
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function label(string $label)
|
||||
{
|
||||
return $this->options([
|
||||
'yAxisName' => $label,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the chart title.
|
||||
*
|
||||
* @param string $title
|
||||
* @param int $font_size
|
||||
* @param string $color
|
||||
* @param bool $bold
|
||||
* @param string $font_family
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function title(
|
||||
string $title,
|
||||
int $font_size = 16,
|
||||
string $color = '#3D4852',
|
||||
bool $bold = true,
|
||||
string $font_family = "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif"
|
||||
) {
|
||||
return $this->options([
|
||||
'caption' => $title,
|
||||
'captionFontSize' => $font_size,
|
||||
'captionFontColor' => $color,
|
||||
'captionFontBold' => $bold,
|
||||
'captionFont' => $font_family,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the chart subtitle.
|
||||
*
|
||||
* @param string $subtitle
|
||||
* @param int $font_size
|
||||
* @param string $color
|
||||
* @param bool $bold
|
||||
* @param string $font_family
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function subtitle(
|
||||
string $subtitle,
|
||||
int $font_size = 12,
|
||||
string $color = '#3D4852',
|
||||
bool $bold = true,
|
||||
string $font_family = "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif"
|
||||
) {
|
||||
return $this->options([
|
||||
'subCaption' => $subtitle,
|
||||
'subCaptionFontSize' => $font_size,
|
||||
'subCaptionFontColor' => $color,
|
||||
'subCaptionFontBold' => $bold,
|
||||
'subCaptionFont' => $font_family,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the chart should show the export button.
|
||||
*
|
||||
* @param bool $export
|
||||
* @param bool $client
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function export(bool $export, bool $client = true)
|
||||
{
|
||||
return $this->options([
|
||||
'exportenabled' => $export,
|
||||
'exportatclient' => $client,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace ConsoleTVs\Charts\Features\Fusioncharts;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
trait Dataset
|
||||
{
|
||||
/**
|
||||
* Set the dataset color.
|
||||
*
|
||||
* @param string|array|Collection $color
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function color($color)
|
||||
{
|
||||
if ($color instanceof Collection) {
|
||||
$color = $color->toArray();
|
||||
}
|
||||
|
||||
return $this->options([
|
||||
'color' => $color,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
namespace ConsoleTVs\Charts\Features\Highcharts;
|
||||
|
||||
trait Chart
|
||||
{
|
||||
/**
|
||||
* Display the chart axes.
|
||||
*
|
||||
* @param bool $axes
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function displayAxes(bool $axes)
|
||||
{
|
||||
return $this->options([
|
||||
'xAxis' => [
|
||||
'visible' => $axes,
|
||||
],
|
||||
'yAxis' => [
|
||||
'visible' => $axes,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the legend.
|
||||
*
|
||||
* @param bool $legend
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function displayLegend(bool $legend)
|
||||
{
|
||||
return $this->options([
|
||||
'legend' => [
|
||||
'enabled' => $legend,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotates the labels of the xAxis.
|
||||
*
|
||||
* @param float $angle
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function labelsRotation(float $angle)
|
||||
{
|
||||
return $this->options([
|
||||
'xAxis' => [
|
||||
'labels' => [
|
||||
'rotation' => $angle,
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the chart style to minimalist.
|
||||
*
|
||||
* @param bool $display
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function minimalist(bool $display = false)
|
||||
{
|
||||
$this->displayLegend(!$display);
|
||||
|
||||
return $this->displayAxes(!$display);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the highcharts yAxis label.
|
||||
*
|
||||
* @param string $label
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function label(string $label)
|
||||
{
|
||||
return $this->options([
|
||||
'yAxis' => [
|
||||
'title' => [
|
||||
'text' => $label,
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the chart title.
|
||||
*
|
||||
* @param string $title
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function title(string $title)
|
||||
{
|
||||
return $this->options([
|
||||
'title' => [
|
||||
'text' => $title,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shapes the pie chart into a doughnut.
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function doughnut(int $size = 50)
|
||||
{
|
||||
return $this->options([
|
||||
'plotOptions' => [
|
||||
'pie' => [
|
||||
'innerSize' => "{$size}%",
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace ConsoleTVs\Charts\Features\Highcharts;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
trait Dataset
|
||||
{
|
||||
/**
|
||||
* Set the dataset color.
|
||||
*
|
||||
* @param string|array $color
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function color($color)
|
||||
{
|
||||
if ($color instanceof Collection) {
|
||||
$color = $color->toArray();
|
||||
}
|
||||
|
||||
return $this->options([
|
||||
'color' => $color,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user