File manager - Edit - /home/u816558632/domains/postills.com/public_html/public/consoletvs.tar
Back
charts/.gitignore 0000644 00000000012 15002264225 0010007 0 ustar 00 .DS_Store charts/.gitattributes 0000644 00000000102 15002264225 0010712 0 ustar 00 # Auto detect text files and perform LF normalization * text=auto charts/composer.json 0000644 00000001372 15002264225 0010553 0 ustar 00 { "name": "consoletvs/charts", "description": "The laravel charting package", "license": "MIT", "type": "library", "require": { "php": ">=7.0", "illuminate/support": "^5.0|^6.0|^7.0|^8.0|^9.0|^10.0", "illuminate/console": "^5.0|^6.0|^7.0|^8.0|^9.0|^10.0", "balping/json-raw-encoder": "^1.0" }, "authors": [ { "name": "Èrik Campobadal Forés ", "email": "soc@erik.cat" } ], "autoload": { "psr-4": { "ConsoleTVs\\Charts\\": "src/" } }, "extra": { "laravel": { "providers": [ "ConsoleTVs\\Charts\\ChartsServiceProvider" ] } }, "minimum-stability": "dev" } charts/README.md 0000644 00000002116 15002264225 0007305 0 ustar 00 > **Warning** > If you're wondering what happened to the v7 version please read this: https://github.com/ConsoleTVs/Charts/issues/1#issuecomment-1208550258 ## What is charts? Charts is a PHP (Laravel) library to handle all the charts in your application. It supports multiple charting libraries and they allow to be loaded over AJAX with a nice loading animation. It uses a simple API to create all the JS logic for you. You just need to write a few PHP lines :) ## Documentation The [documentation for laravel-charts v6](https://charts.erik.cat) can be found here, by pressing the image below. <p align="center"><a href="https://charts.erik.cat"><img height="250" src="https://i.imgur.com/F0PDyYE.png"></a></p> ## Example screenshot A sample screenshot of a chartjs chart created using Charts. <p align="center"><img src="https://image.prntscr.com/image/FDJCr7ywShKMUlFitEc_Ww.png"></p> ## License [](https://app.fossa.io/projects/git%2Bgithub.com%2FConsoleTVs%2FCharts?ref=badge_large) charts/LICENSE 0000644 00000002102 15002264225 0007026 0 ustar 00 MIT License Copyright (c) Èrik Campobadal Forés <soc@erik.cat> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. charts/.github/ISSUE_TEMPLATE/question.md 0000644 00000000162 15002264225 0013741 0 ustar 00 --- name: Question about: Questions and troubleshooting title: "[QUESTION]" labels: question assignees: '' --- charts/.github/ISSUE_TEMPLATE/bug_report.md 0000644 00000002056 15002264225 0014246 0 ustar 00 --- name: Bug report about: Create a report to help us improve title: "[BUG]" labels: bug assignees: '' --- **Required information** - Charts Version [e.g. 6] - Laravel Version [e.g. 5.8] - PHP Version [e.g. 7.2] - Frontend JS Library Used: [e.g. Chart.js] **Describe the bug** A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behavior: 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' 4. See error **Expected behavior** A clear and concise description of what you expected to happen. **Screenshots** If applicable, add screenshots to help explain your problem. **Code To Reproduce** If applicable, add a code to reproduce the problem. **Desktop (please complete the following information):** - OS: [e.g. iOS] - Browser [e.g. chrome, safari] - Version [e.g. 22] **Smartphone (please complete the following information):** - Device: [e.g. iPhone6] - OS: [e.g. iOS8.1] - Browser [e.g. stock browser, safari] - Version [e.g. 22] **Additional context** Add any other context about the problem here. charts/.github/ISSUE_TEMPLATE/feature_request.md 0000644 00000001145 15002264225 0015277 0 ustar 00 --- name: Feature request about: Suggest an idea for this project title: "[FEATURE]" labels: enhancement assignees: '' --- **Is your feature request related to a problem? Please describe.** A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] **Describe the solution you'd like** A clear and concise description of what you want to happen. **Describe alternatives you've considered** A clear and concise description of any alternative solutions or features you've considered. **Additional context** Add any other context or screenshots about the feature request here. charts/.github/FUNDING.yml 0000644 00000000107 15002264225 0011201 0 ustar 00 # These are supported funding model platforms patreon: ErikCampobadal charts/src/Config/charts.php 0000644 00000000736 15002264225 0012025 0 ustar 00 <?php return [ /* |-------------------------------------------------------------------------- | Default library used in charts. |-------------------------------------------------------------------------- | | This value is used as the default chart library used when creating | any chart in the command line. Feel free to modify it or set it up | while creating the chart to ignore this value. | */ 'default_library' => 'Chartjs', ]; charts/src/Features/Chartjs/Dataset.php 0000644 00000003477 15002264225 0014102 0 ustar 00 <?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, ]); } /** * Set the label of the dataset. * * @param $label string * * @return self */ public function label($label) { return $this->options([ 'label' => $label, ]); } } charts/src/Features/Chartjs/Chart.php 0000644 00000004762 15002264225 0013554 0 ustar 00 <?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, ], ]); } } charts/src/Features/Fusioncharts/Dataset.php 0000644 00000000706 15002264225 0015144 0 ustar 00 <?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, ]); } } charts/src/Features/Fusioncharts/Chart.php 0000644 00000004170 15002264225 0014617 0 ustar 00 <?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, ]); } } charts/src/Features/Echarts/Dataset.php 0000644 00000000701 15002264225 0014060 0 ustar 00 <?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, ]); } } charts/src/Features/Echarts/Chart.php 0000644 00000007645 15002264225 0013552 0 ustar 00 <?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; } } charts/src/Features/C3/Dataset.php 0000644 00000000112 15002264225 0012730 0 ustar 00 <?php namespace ConsoleTVs\Charts\Features\C3; trait Dataset { // } charts/src/Features/C3/Chart.php 0000644 00000002136 15002264225 0012414 0 ustar 00 <?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, ], ]); } } charts/src/Features/Highcharts/Dataset.php 0000644 00000000671 15002264225 0014561 0 ustar 00 <?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, ]); } } charts/src/Features/Highcharts/Chart.php 0000644 00000004370 15002264225 0014235 0 ustar 00 <?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}%", ], ], ]); } } charts/src/Features/Frappe/Dataset.php 0000644 00000000501 15002264225 0013702 0 ustar 00 <?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, ]); } } charts/src/Features/Frappe/Chart.php 0000644 00000004632 15002264225 0013367 0 ustar 00 <?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, ], ]); } } charts/src/Classes/DatasetClass.php 0000644 00000004563 15002264225 0013306 0 ustar 00 <?php namespace ConsoleTVs\Charts\Classes; use Illuminate\Support\Collection; class DatasetClass { /** * Defines the name of the dataset. * * @var string */ public $name = 'Undefined'; /** * Defines the dataset type. * * @var string */ public $type = ''; /** * Stores the dataset values. * * @var array */ public $values = []; /** * Stores the dataset options. * * @var array */ public $options = []; /** * Defines the undefined color. * * @var string */ public $undefinedColor = '#22292F'; /** * Creates a new dataset with the given values. * * @param string $name * @param string $type * @param array $values */ public function __construct(string $name, string $type, array $values) { $this->name = $name; $this->type = $type; $this->values = $values; return $this; } /** * Set the dataset type. * * @param string $type * * @return self */ public function type(string $type) { $this->type = $type; return $this; } /** * Set the dataset values. * * @param array|Collection $values * * @return self */ public function values($values) { if ($values instanceof Collection) { $values = $values->toArray(); } $this->values = $values; return $this; } /** * Set the dataset options. * * @param array|Collection $options * @param bool $overwrite * * @return self */ public function options($options, bool $overwrite = false) { if ($overwrite) { $this->options = $options; } else { $this->options = array_replace_recursive($this->options, $options); } return $this; } /** * Matches the values of the dataset with the given number. * * @param int $values * @param bool $strict * * @return void */ public function matchValues(int $values, bool $strict = false) { while (count($this->values) < $values) { array_push($this->values, 0); } if ($strict) { $this->values = array_slice($this->values, 0, $values); } } } charts/src/Classes/BaseChart.php 0000644 00000026153 15002264225 0012566 0 ustar 00 <?php namespace ConsoleTVs\Charts\Classes; use Balping\JsonRaw\Encoder; use Balping\JsonRaw\Raw; use Illuminate\Support\Collection; use Illuminate\Support\Facades\View; class BaseChart { /** * Stores the chart ID. * * @var string */ public $id; /** * Stores the chart datasets. * * @var array */ public $datasets = []; /** * Stores the dataset class to be used. * * @var object */ protected $dataset = DatasetClass::class; /** * Stores the chart labels. * * @var array */ public $labels = []; /** * Stores the chart container. * * @var string */ public $container = ''; /** * Stores the chart options. * * @var array */ public $options = []; /** * Stores the plugins options. * * @var array */ public $plugins = []; /** * Stores the plugin views. * * @var array */ public $pluginsViews = []; /** * Stores the chart script. * * @var string */ public $script = ''; /** * Stores the chart type. * * @var string */ public $type = ''; /** * Stores the API url if the chart is loaded over API. * * @var string */ public $api_url = ''; /** * Determines if the loader is show. * * @var bool */ public $loader = true; /** * Determines if the loader color. * * @var string */ public $loaderColor = '#22292F'; /** * Stores the height of the chart. * * @var int */ public $height = 400; /** * Stores the width of the chart. * * @var int */ public $width = null; /** * Stores the available chart letters to create the ID. * * @var array */ public $scriptAttributes = [ 'type' => 'text/javascript', ]; /** * Stores the available chart letters to create the ID. * * @var string */ private $chartLetters = 'abcdefghijklmnopqrstuvwxyz'; /** * Chart constructor. */ public function __construct() { $this->id = substr(str_shuffle(str_repeat($x = $this->chartLetters, ceil(25 / strlen($x)))), 1, 25); } /** * Adds a new dataset to the chart. * * @param string $name * @param array|Collection $data */ public function dataset(string $name, string $type, $data) { if ($data instanceof Collection) { $data = $data->toArray(); } $dataset = new $this->dataset($name, $type, $data); array_push($this->datasets, $dataset); return $dataset; } /** * Set the chart labels. * * @param array|Collection $labels * * @return self */ public function labels($labels) { if ($labels instanceof Collection) { $labels = $labels->toArray(); } $this->labels = $labels; return $this; } /** * Set the chart options. * * @param array|Collection $options * @param bool $overwrite * * @return self */ public function options($options, bool $overwrite = false) { if (!empty($options['plugins'])) { $options['plugins'] = new Raw(trim(preg_replace('/\s\s+/', ' ', $options['plugins']))); } if ($options instanceof Collection) { $options = $options->toArray(); } if ($overwrite) { $this->options = $options; } else { $this->options = array_replace_recursive($this->options, $options); } return $this; } /** * Set the plugins options. * * @param array|Collection $options * @param bool $overwrite * * @return self */ public function plugins($plugins, bool $overwrite = true) { if ($plugins instanceof Collection) { $plugins = $plugins->toArray(); } if ($overwrite) { $this->plugins = $plugins; } else { $this->plugins = array_replace_recursive($this->plugins, $plugins); } return $this; } /** * Set the chart container. * * @param string $container * * @return self */ public function container(string $container = null) { if (!$container) { return View::make($this->container, ['chart' => $this]); } $this->container = $container; return $this; } /** * Set the chart script. * * @param string $script * * @return self */ public function script(string $script = null) { if (count($this->datasets) == 0 && !$this->api_url) { throw new \Exception('No datasets provided, please provide at least one dataset to generate a chart'); } if (!$script) { return View::make($this->script, ['chart' => $this]); } $this->script = $script; return $this; } /** * Set the chart type. * * @param string $type * * @return self */ public function type(string $type) { $this->type = $type; return $this; } /** * Set the chart height. * * @param int $height * * @return self */ public function height(int $height) { $this->height = $height; return $this; } /** * Set the chart width. * * @param int $width * * @return self */ public function width(int $width) { $this->width = $width; return $this; } /** * Formats the type to be a correct output. * * @return string */ public function formatType() { return $this->type ? $this->type : $this->datasets[0]->type; } /** * Formats the labels to be a correct output. * * @return string */ public function formatLabels() { return Encoder::encode($this->labels); } /** * Formats the chart options. * * @param bool $strict * * @return string */ public function formatOptions(bool $strict = false, bool $noBraces = false) { if (!$strict && count($this->options) === 0) { return ''; } $options = Encoder::encode($this->options); return $noBraces ? substr($options, 1, -1) : $options; } /** * Formats the plugins options. * * @param bool $strict * * @return string */ public function formatPlugins(bool $strict = false, bool $noBraces = false) { if (!$strict && count($this->plugins) === 0) { return ''; } $plugins = str_replace('"', '', Encoder::encode($this->plugins)); return $noBraces ? substr($plugins, 1, -1) : $plugins; } /** * Use this to pass values to json without any modification * Useful for defining callbacks. * * @param string $value * * @return \Balping\JsonRaw\Raw */ public function rawObject(string $value) { return new Raw($value); } /** * Reset the chart options. * * @return self */ public function reset() { return $this->options([], true); } /** * Formats the datasets for the output. * * @return string */ public function formatDatasets() { // This little boy was commented because it's not compatible // in laravel < 5.4 // // return Collection::make($this->datasets) // ->each // ->matchValues(count($this->labels)) // ->map // ->format($this->labels) // ->toJson(); return Encoder::encode( Collection::make($this->datasets) ->each(function ($dataset) { $dataset->matchValues(count($this->labels)); }) ->map(function ($dataset) { return $dataset->format($this->labels); }) ->toArray() ); } /** * Indicates that the chart information will be loaded over API. * * @param string $api_url * * @return self */ public function load(string $api_url) { $this->api_url = $api_url; return $this; } /** * Determines if the chart should show a loader. * * @param bool $loader * * @return self */ public function loader(bool $loader) { $this->loader = $loader; return $this; } /** * Determines the loader color. * * @param string $color * * @return self */ public function loaderColor(string $color) { $this->loaderColor = $color; return $this; } /** * Alias for the formatDatasets() method. * * @return string */ public function api() { return $this->formatDatasets(); } /** * Sets an HTML attribute the the script tag of the chart. * * @param string $key * @param string $value * * @return self */ public function setScriptAttribute(string $key, string $value) { $this->scriptAttributes[$key] = $value; return $this; } /** * Returns the string formatting of the script attributes. * * @return string */ public function displayScriptAttributes(): string { $result = ''; foreach ($this->scriptAttributes as $key => $value) { echo " {$key}=\"{$value}\""; } return $result; } /** * Formats the container options. * * @param string $type * @param bool $maxIfNull * * @return string */ public function formatContainerOptions(string $type = 'css', bool $maxIfNull = false) { $options = ''; $height = ($maxIfNull && !$this->height) ? '100%' : $this->height; $width = ($maxIfNull && !$this->width) ? '100%' : $this->width; switch ($type) { case 'css': $options .= " style='"; (!$height) ?: $options .= "height: {$height}px !important;"; (!$width) ?: $options .= "width: {$width}px !important;"; $options .= "' "; break; case 'js': if ($height) { if (is_int($height)) { $options .= "height: {$height}, "; } else { $options .= "height: '{$height}', "; } } if ($width) { if (is_int($width)) { $options .= "width: {$width}, "; } else { $options .= "width: '{$width}', "; } } break; default: (!$height) ?: $options .= " height='{$this->height}' "; (!$this->width) ?: $options .= " width='{$this->width}' "; } return $options; } } charts/src/Classes/Chartjs/Dataset.php 0000644 00000001572 15002264225 0013713 0 ustar 00 <?php namespace ConsoleTVs\Charts\Classes\Chartjs; use ConsoleTVs\Charts\Classes\DatasetClass; use ConsoleTVs\Charts\Features\Chartjs\Dataset as DatasetFeatures; class Dataset extends DatasetClass { use DatasetFeatures; /** * Creates a new dataset with the given values. * * @param string $name * @param string $type * @param array $values */ public function __construct(string $name, string $type, array $values) { parent::__construct($name, $type, $values); $this->options([ 'borderWidth' => 2, ]); } /** * Formats the dataset for chartjs. * * @return array */ public function format() { return array_merge($this->options, [ 'data' => $this->values, 'label' => $this->name, 'type' => $this->type, ]); } } charts/src/Classes/Chartjs/Chart.php 0000644 00000001721 15002264225 0013363 0 ustar 00 <?php namespace ConsoleTVs\Charts\Classes\Chartjs; use ConsoleTVs\Charts\Classes\BaseChart; use ConsoleTVs\Charts\Features\Chartjs\Chart as ChartFeatures; class Chart extends BaseChart { use ChartFeatures; /** * Chartjs dataset class. * * @var object */ public $dataset = Dataset::class; /** * Initiates the Chartjs Line Chart. * * @return self */ public function __construct() { parent::__construct(); $this->container = 'charts::chartjs.container'; $this->script = 'charts::chartjs.script'; return $this->options([ 'maintainAspectRatio' => false, 'scales' => [ 'xAxes' => [], 'yAxes' => [ [ 'ticks' => [ 'beginAtZero' => true, ], ], ], ], ]); } } charts/src/Classes/Fusioncharts/Dataset.php 0000644 00000004530 15002264225 0014762 0 ustar 00 <?php namespace ConsoleTVs\Charts\Classes\Fusioncharts; use ConsoleTVs\Charts\Classes\DatasetClass; use ConsoleTVs\Charts\Features\Fusioncharts\Dataset as DatasetFeatures; use Illuminate\Support\Collection; class Dataset extends DatasetClass { use DatasetFeatures; /** * Store the private datasets that contains a special formatting. * * @var array */ public $specialDatasets = ['pie2d', 'doughnut2d']; /** * Creates a new dataset with the given values. * * @param string $name * @param string $type * @param array $values */ public function __construct(string $name, string $type, array $values) { parent::__construct($name, $type, $values); } /** * Dataset representation. * * @var array */ public function format(array $labels = []) { return array_merge($this->options, [ 'data' => $this->formatValues($labels), 'seriesName' => $this->name, 'renderAs' => strtolower($this->type), ]); } /** * Formats the chart values. * * @param array $labels * * @return array */ protected function formatValues(array $labels) { $values = Collection::make($this->values); if (in_array(strtolower($this->type), $this->specialDatasets)) { $colors = $this->getColors($labels); return $values->map(function ($value, $key) use ($colors, $labels) { $val = [ 'label' => $labels[$key], 'value' => $value, ]; if ($colors->count() > 0) { $val['color'] = $colors->get($key); } return $val; })->toArray(); } return $values->map(function ($value) { return [ 'value' => $value, ]; })->toArray(); } /** * Get the chart colors. * * @param array $labels * * @return Collection */ protected function getColors(array $labels) { $colors = Collection::make(array_key_exists('color', $this->options) ? $this->options['color'] : []); while ($colors->count() < count($labels)) { $colors->push($this->undefinedColor); } return $colors; } } charts/src/Classes/Fusioncharts/Chart.php 0000644 00000004216 15002264225 0014437 0 ustar 00 <?php namespace ConsoleTVs\Charts\Classes\Fusioncharts; use ConsoleTVs\Charts\Classes\BaseChart; use ConsoleTVs\Charts\Features\Fusioncharts\Chart as ChartFeatures; use Illuminate\Support\Collection; class Chart extends BaseChart { use ChartFeatures; /** * Chartjs dataset class. * * @var object */ public $dataset = Dataset::class; /** * Theese array stores the types that are maintained to fusioncharts. * * @var array */ public $keepType = ['pie2d', 'doughnut2d']; /** * Determines the combo type of chart. * * @var array */ public $comboType = 'mscombi2d'; /** * Initiates the Chartjs Line Chart. * * @return self */ public function __construct() { parent::__construct(); $this->container = 'charts::fusioncharts.container'; $this->script = 'charts::fusioncharts.script'; return $this->options([ 'bgColor' => '#ffffff', 'borderAlpha' => 0, 'canvasBorderAlpha' => 0, 'usePlotGradientColor' => false, 'plotBorderAlpha' => 0, 'divlineColor' => '#22292F', 'divLineIsDashed' => true, 'showAlternateHGridColor' => false, 'captionFontBold' => true, 'captionFontSize' => 14, 'subcaptionFontBold' => false, 'subcaptionFontSize' => 14, 'legendBorderAlpha' => 0, 'legendShadow' => 0, 'hoverfillcolor' => '#CCCCCC', 'piebordercolor' => '#FFFFFF', 'hoverfillcolor' => '#CCCCCC', 'use3DLighting' => false, 'showShadow' => false, ]); } /** * Formats the labels for fusioncharts. * * @return string */ public function formatLabels() { return Collection::make($this->labels) ->map(function ($label) { return ['label' => $label]; }) ->toJson(); } } charts/src/Classes/Echarts/Dataset.php 0000644 00000003123 15002264225 0013700 0 ustar 00 <?php namespace ConsoleTVs\Charts\Classes\Echarts; use ConsoleTVs\Charts\Classes\DatasetClass; use ConsoleTVs\Charts\Features\Echarts\Dataset as DatasetFeatures; use Illuminate\Support\Collection; class Dataset extends DatasetClass { use DatasetFeatures; /** * Store the private datasets that contains a special formating. * * @var array */ public $specialDatasets = ['pie']; /** * Creates a new dataset with the given values. * * @param string $name * @param string $type * @param array $values */ public function __construct(string $name, string $type, array $values) { parent::__construct($name, $type, $values); } /** * Formats the dataset for chartjs. * * @return array */ public function format(array $labels = []) { return array_merge($this->options, [ 'data' => $this->getValues($labels), 'name' => $this->name, 'type' => strtolower($this->type), ]); } /** * Get the formated values. * * @param array $labels * * @return array */ protected function getValues(array $labels) { if (in_array(strtolower($this->type), $this->specialDatasets)) { return Collection::make($this->values) ->map(function ($value, $key) use ($labels) { return [ 'name' => $labels[$key], 'value' => $value, ]; })->toArray(); } return $this->values; } } charts/src/Classes/Echarts/Chart.php 0000644 00000002575 15002264225 0013366 0 ustar 00 <?php namespace ConsoleTVs\Charts\Classes\Echarts; use ConsoleTVs\Charts\Classes\BaseChart; use ConsoleTVs\Charts\Features\Echarts\Chart as ChartFeatures; class Chart extends BaseChart { use ChartFeatures; /** * Chartjs dataset class. * * @var object */ public $dataset = Dataset::class; /** * Store the theme for the chart. * * @var string */ public $theme = 'default'; /** * Initiates the Chartjs Line Chart. * * @return self */ public function __construct() { parent::__construct(); $this->container = 'charts::echarts.container'; $this->script = 'charts::echarts.script'; return $this->options([ 'legend' => [ 'show' => true, ], 'tooltip' => [ 'show' => true, ], 'xAxis' => [ 'show' => true, ], 'yAxis' => [ 'show' => true, ], ]); } /** * Formats the options. * * @return self */ public function formatOptions(bool $strict = false, bool $noBraces = false) { $this->options([ 'xAxis' => [ 'data' => json_decode($this->formatLabels()), ], ]); return parent::formatOptions($strict, $noBraces); } } charts/src/Classes/README.md 0000644 00000000104 15002264225 0011464 0 ustar 00 # Charts Classes All the charts classes are located in this folder charts/src/Classes/C3/Dataset.php 0000644 00000001275 15002264225 0012562 0 ustar 00 <?php namespace ConsoleTVs\Charts\Classes\C3; use ConsoleTVs\Charts\Classes\DatasetClass; use ConsoleTVs\Charts\Features\C3\Dataset as DatasetFeatures; class Dataset extends DatasetClass { use DatasetFeatures; /** * Creates a new dataset with the given values. * * @param string $name * @param string $type * @param array $values */ public function __construct(string $name, string $type, array $values) { parent::__construct($name, $type, $values); } /** * Formats the dataset for chartjs. * * @return array */ public function format() { return array_merge([$this->name], $this->values); } } charts/src/Classes/C3/Chart.php 0000644 00000002527 15002264225 0012237 0 ustar 00 <?php namespace ConsoleTVs\Charts\Classes\C3; use ConsoleTVs\Charts\Classes\BaseChart; use ConsoleTVs\Charts\Features\C3\Chart as ChartFeatures; use Illuminate\Support\Collection; class Chart extends BaseChart { use ChartFeatures; /** * C3 dataset class. * * @var object */ public $dataset = Dataset::class; /** * Initiates the C3 Line Chart. * * @return self */ public function __construct() { parent::__construct(); $this->container = 'charts::c3.container'; $this->script = 'charts::c3.script'; return $this; } /** * Formats the datasets. * * @return void */ public function formatDatasets() { $datasets = Collection::make($this->datasets); return json_encode([ 'columns' => Collection::make($this->datasets) ->each(function ($dataset) { $dataset->matchValues(count($this->labels)); }) ->map(function ($dataset) { return $dataset->format($this->labels); }) ->toArray(), 'type' => $datasets->first()->type, 'types' => $datasets->mapWithKeys(function ($d) { return [$d->name => $d->type]; })->toArray(), ]); } } charts/src/Classes/Highcharts/Dataset.php 0000644 00000004325 15002264225 0014400 0 ustar 00 <?php namespace ConsoleTVs\Charts\Classes\Highcharts; use ConsoleTVs\Charts\Classes\DatasetClass; use ConsoleTVs\Charts\Features\Highcharts\Dataset as DatasetFeatures; use Illuminate\Support\Collection; class Dataset extends DatasetClass { use DatasetFeatures; /** * Store the private datasets that contains a special formating. * * @var array */ public $specialDatasets = ['pie']; /** * Creates a new dataset with the given values. * * @param string $name * @param string $type * @param array $values */ public function __construct(string $name, string $type, array $values) { parent::__construct($name, $type, $values); } /** * Dataset representation. * * @var array */ public function format(array $labels = []) { return array_merge($this->options, [ 'data' => $this->formatValues($labels), 'name' => $this->name, 'type' => strtolower($this->type), ]); } /** * Formats the values. * * @param array $labels * * @return array */ protected function formatValues(array $labels) { if (in_array(strtolower($this->type), $this->specialDatasets)) { $colors = $this->getColors($labels); return Collection::make($this->values) ->map(function ($value, $key) use ($colors, $labels) { $val = [ 'name' => $labels[$key], 'y' => $value, ]; if ($colors->count() > 0) { $val['color'] = $colors->get($key); } return $val; })->toArray(); } return $this->values; } /** * Get the dataset colors;. * * @param array $labels * * @return Collection */ protected function getColors(array $labels) { $colors = Collection::make(array_key_exists('color', $this->options) ? $this->options['color'] : []); while ($colors->count() < count($labels)) { $colors->push($this->undefinedColor); } return $colors; } } charts/src/Classes/Highcharts/Chart.php 0000644 00000002353 15002264225 0014053 0 ustar 00 <?php namespace ConsoleTVs\Charts\Classes\Highcharts; use ConsoleTVs\Charts\Classes\BaseChart; use ConsoleTVs\Charts\Features\Highcharts\Chart as ChartFeatures; class Chart extends BaseChart { use ChartFeatures; /** * Chartjs dataset class. * * @var object */ public $dataset = Dataset::class; /** * Initiates the Highcharts Line Chart. * * @return self */ public function __construct() { parent::__construct(); $this->container = 'charts::highcharts.container'; $this->script = 'charts::highcharts.script'; return $this->options([ 'credits' => [ 'enabled' => false, ], 'title' => [ 'text' => null, ], ]); } /** * Format the options for highcharts. * * @return string */ public function formatOptions(bool $strict = false, bool $noBraces = false) { if (count($this->labels) > 0) { $this->options([ 'xAxis' => [ 'categories' => json_decode($this->formatLabels()), ], ]); } return parent::formatOptions($strict, $noBraces); } } charts/src/Classes/Frappe/Dataset.php 0000644 00000001536 15002264225 0013532 0 ustar 00 <?php namespace ConsoleTVs\Charts\Classes\Frappe; use ConsoleTVs\Charts\Classes\DatasetClass; use ConsoleTVs\Charts\Features\Frappe\Dataset as DatasetFeatures; class Dataset extends DatasetClass { use DatasetFeatures; /** * Creates a new dataset with the given values. * * @param string $name * @param string $type * @param array $values */ public function __construct(string $name, string $type, array $values) { parent::__construct($name, $type, $values); $this->options([]); } /** * Formats the dataset for chartjs. * * @return array */ public function format() { return array_merge($this->options, [ 'values' => $this->values, 'name' => $this->name, 'chartType' => $this->type, ]); } } charts/src/Classes/Frappe/Chart.php 0000644 00000003513 15002264225 0013203 0 ustar 00 <?php namespace ConsoleTVs\Charts\Classes\Frappe; use ConsoleTVs\Charts\Classes\BaseChart; use ConsoleTVs\Charts\Features\Frappe\Chart as ChartFeatures; class Chart extends BaseChart { use ChartFeatures; /** * Frappe dataset class. * * @var object */ public $dataset = Dataset::class; /** * Stores the default colors. * * @var array */ public $default_colors = [ '#E3342F', '#F6993F', '#FFED4A', '#38C172', '#4DC0B5', '#3490DC', '#6574CD', '#9561E2', '#F66D9B', ]; /** * Determines the special charts. * * @var array */ public $special_datasets = [ 'pie', 'percentage', ]; /** * Initiates the Frappe Chart. * * @return self */ public function __construct() { parent::__construct(); $this->container = 'charts::frappe.container'; $this->script = 'charts::frappe.script'; return $this->options([ 'barOptions' => [ 'spaceRatio' => 0.75, ], ]); } /** * Format the datasets. * * @param bool $strict * @param bool $noBraces * * @return self */ public function formatOptions(bool $strict = false, bool $noBraces = false) { $colors = []; $default = 0; foreach ($this->datasets as $dataset) { $color = $this->default_colors[$default]; if (array_key_exists('color', $dataset->options)) { $color = $dataset->options['color']; unset($dataset->options['color']); } else { $default++; } array_push($colors, $color); } $this->options([ 'colors' => $colors, ]); return parent::formatOptions($strict, $noBraces); } } charts/src/Commands/ChartsCommand.php 0000644 00000005412 15002264225 0013614 0 ustar 00 <?php namespace ConsoleTVs\Charts\Commands; use Illuminate\Console\Command; use Illuminate\Console\GeneratorCommand; use Symfony\Component\Console\Input\InputArgument; class ChartsCommand extends GeneratorCommand { /** * The console command name. * * @var string */ protected $name = 'make:chart'; /** * The console command description. * * @var string */ protected $description = 'Creates a new chart'; /** * The type of class being generated. * * @var string */ protected $type = 'Chart'; /** * Get the stub file for the generator. * * @return string */ protected function getStub() { return __DIR__.'/stubs/chart.stub'; } /** * Execute the console command. * * @return mixed */ public function handle() { $this->line('[Charts] Creating chart...'); $this->handleParentMethodCall(); $name = $this->qualifyClass($this->getNameInput()); $path = $this->getPath($name); $this->info("[Charts] Chart created! - Location: {$path}"); } /** * Build the class with the given name. * * @param string $name * * @return string */ protected function buildClass($name) { $stub = parent::buildClass($name); return str_replace( ['Library'], [$this->argument('library') ? ucfirst($this->argument('library')) : ucfirst(config('charts.default_library'))], $stub ); } /** * Get the default namespace for the class. * * @param string $rootNamespace * * @return string */ protected function getDefaultNamespace($rootNamespace) { return $rootNamespace.'\Charts'; } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['name', InputArgument::REQUIRED, 'The name of the chart file'], ['library', InputArgument::OPTIONAL, 'Library of the chart'], ]; } /** * Calls the right parent method depending on laravel version. * Adds support for Laravel v5.4. * * @return void */ protected function handleParentMethodCall() { if (!is_callable('parent::handle')) { return parent::fire(); } parent::handle(); } /** * Qualifies the class name by delegating to the right parent method. * * @param string $name * * @return string */ protected function qualifyClass($name) { if (!is_callable('parent::qualifyClass')) { return parent::parseName($name); } return parent::qualifyClass($name); } } charts/src/Commands/README.md 0000644 00000000106 15002264225 0011632 0 ustar 00 # Charts Commands All the charts commands are located in this folder charts/src/Commands/stubs/chart.stub 0000644 00000000411 15002264225 0013512 0 ustar 00 <?php namespace DummyNamespace; use ConsoleTVs\Charts\Classes\Library\Chart; class DummyClass extends Chart { /** * Initializes the chart. * * @return void */ public function __construct() { parent::__construct(); } } charts/src/Views/c3/container.blade.php 0000644 00000000153 15002264225 0013757 0 ustar 00 <div id="{{ $chart->id }}" {!! $chart->formatContainerOptions('css') !!}> </div> @include('charts::loader') charts/src/Views/c3/script.blade.php 0000644 00000002302 15002264225 0013277 0 ustar 00 <script {!! $chart->displayScriptAttributes() !!}> function {{ $chart->id }}_create(data) { {{ $chart->id }}_rendered = true; document.getElementById("{{ $chart->id }}_loader").style.display = 'none'; document.getElementById("{{ $chart->id }}").style.display = 'block'; window.{{ $chart->id }} = c3.generate({ bindto: '#{{ $chart->id }}', data: data, {!! $chart->formatOptions(false, true) !!} }); } @if ($chart->api_url) let {{ $chart->id }}_refresh = function (url) { document.getElementById("{{ $chart->id }}").style.display = 'none'; document.getElementById("{{ $chart->id }}_loader").style.display = 'flex'; if (typeof url !== 'undefined') { {{ $chart->id }}_api_url = url; } fetch({{ $chart->id }}_api_url) .then(data => data.json()) .then(data => { {{ $chart->id }}.load(data); document.getElementById("{{ $chart->id }}_loader").style.display = 'none'; document.getElementById("{{ $chart->id }}").style.display = 'block'; }); }; @endif @include('charts::init') </script> charts/src/Views/README.md 0000644 00000000100 15002264225 0011160 0 ustar 00 # Charts Views All the charts views are located in this folder charts/src/Views/highcharts/container.blade.php 0000644 00000000154 15002264225 0015577 0 ustar 00 <div id="{{ $chart->id }}" {!! $chart->formatContainerOptions('css') !!}> </div> @include('charts::loader') charts/src/Views/highcharts/script.blade.php 0000644 00000002167 15002264225 0015127 0 ustar 00 <script {!! $chart->displayScriptAttributes() !!}> function {{ $chart->id }}_create(data) { {{ $chart->id }}_rendered = true; document.getElementById("{{ $chart->id }}_loader").style.display = 'none'; window.{{ $chart->id }} = new Highcharts.Chart("{{ $chart->id }}", { series: data, {!! $chart->formatOptions(false, true) !!} }); } @if ($chart->api_url) let {{ $chart->id }}_refresh = function (url) { document.getElementById("{{ $chart->id }}").style.display = 'none'; document.getElementById("{{ $chart->id }}_loader").style.display = 'flex'; if (typeof url !== 'undefined') { {{ $chart->id }}_api_url = url; } fetch({{ $chart->id }}_api_url) .then(data => data.json()) .then(data => { document.getElementById("{{ $chart->id }}_loader").style.display = 'none'; document.getElementById("{{ $chart->id }}").style.display = 'block'; {{ $chart->id }}.update({series: data}); }); }; @endif @include('charts::init') </script> charts/src/Views/chartjs/container.blade.php 0000644 00000000210 15002264225 0015102 0 ustar 00 <canvas style="display: none;" id="{{ $chart->id }}" {!! $chart->formatContainerOptions('html') !!}></canvas> @include('charts::loader') charts/src/Views/chartjs/script.blade.php 0000644 00000003244 15002264225 0014436 0 ustar 00 @foreach ($chart->plugins as $plugin) @include($chart->pluginsViews[$plugin]) @endforeach <script {!! $chart->displayScriptAttributes() !!}> var ctvChart = document.getElementById('{{ $chart->id }}').getContext('2d'); function {{ $chart->id }}_create(data) { {{ $chart->id }}_rendered = true; document.getElementById("{{ $chart->id }}_loader").style.display = 'none'; document.getElementById("{{ $chart->id }}").style.display = 'block'; window.{{ $chart->id }} = new Chart(document.getElementById("{{ $chart->id }}").getContext("2d"), { type: {!! $chart->type ? "'{$chart->type}'" : 'data[0].type' !!}, data: { labels: {!! $chart->formatLabels() !!}, datasets: data }, options: {!! $chart->formatOptions(true) !!}, plugins: {!! $chart->formatPlugins(true) !!} }); } @if ($chart->api_url) let {{ $chart->id }}_refresh = function (url) { document.getElementById("{{ $chart->id }}").style.display = 'none'; document.getElementById("{{ $chart->id }}_loader").style.display = 'flex'; if (typeof url !== 'undefined') { {{ $chart->id }}_api_url = url; } fetch({{ $chart->id }}_api_url) .then(data => data.json()) .then(data => { document.getElementById("{{ $chart->id }}_loader").style.display = 'none'; document.getElementById("{{ $chart->id }}").style.display = 'block'; {{ $chart->id }}.data.datasets = data; {{ $chart->id }}.update(); }); }; @endif @include('charts::init') </script> charts/src/Views/loader.blade.php 0000644 00000003322 15002264225 0012737 0 ustar 00 <div id="{{ $chart->id }}_loader" style=" display: flex; justify-content: center; opacity: {{ $chart->loader ? '1' : '0' }}; align-items: center; {{ $chart->height ? 'height: ' . $chart->height . 'px;' : '' }} {{ $chart->width ? 'width: ' . $chart->width . 'px;' : '' }} "> <svg width="50" height="50" viewBox="0 0 38 38" xmlns="http://www.w3.org/2000/svg"> <defs> <linearGradient x1="8.042%" y1="0%" x2="65.682%" y2="23.865%" id="a"> <stop stop-color="{{ $chart->loaderColor }}" stop-opacity="0" offset="0%"/> <stop stop-color="{{ $chart->loaderColor }}" stop-opacity=".631" offset="63.146%"/> <stop stop-color="{{ $chart->loaderColor }}" offset="100%"/> </linearGradient> </defs> <g fill="none" fill-rule="evenodd"> <g transform="translate(1 1)"> <path d="M36 18c0-9.94-8.06-18-18-18" id="Oval-2" stroke="url(#a)" stroke-width="2"> <animateTransform attributeName="transform" type="rotate" from="0 18 18" to="360 18 18" dur="0.9s" repeatCount="indefinite" /> </path> <circle fill="{{ $chart->loaderColor }}" cx="36" cy="18" r="1"> <animateTransform attributeName="transform" type="rotate" from="0 18 18" to="360 18 18" dur="0.9s" repeatCount="indefinite" /> </circle> </g> </g> </svg> </div> charts/src/Views/echarts/container.blade.php 0000644 00000000153 15002264225 0015103 0 ustar 00 <div id="{{ $chart->id }}" {!! $chart->formatContainerOptions('css') !!}> </div> @include('charts::loader') charts/src/Views/echarts/script.blade.php 0000644 00000002317 15002264225 0014431 0 ustar 00 <script {!! $chart->displayScriptAttributes() !!}> function {{ $chart->id }}_create(data) { {{ $chart->id }}_rendered = true; document.getElementById("{{ $chart->id }}_loader").style.display = 'none'; window.{{ $chart->id }} = echarts.init(document.getElementById("{{ $chart->id }}"),'{{ $chart->theme }}'); window.{{ $chart->id }}.setOption({ series: data, {!! $chart->formatOptions(false, true) !!} }); } @if ($chart->api_url) let {{ $chart->id }}_refresh = function (url) { document.getElementById("{{ $chart->id }}").style.display = 'none'; document.getElementById("{{ $chart->id }}_loader").style.display = 'flex'; if (typeof url !== 'undefined') { {{ $chart->id }}_api_url = url; } fetch({{ $chart->id }}_api_url) .then(data => data.json()) .then(data => { document.getElementById("{{ $chart->id }}_loader").style.display = 'none'; document.getElementById("{{ $chart->id }}").style.display = 'block'; {{ $chart->id }}.setOption({series: data}); }); }; @endif @include('charts::init') </script> charts/src/Views/frappe/container.blade.php 0000644 00000000075 15002264225 0014732 0 ustar 00 <div id="{{ $chart->id }}"> </div> @include('charts::loader') charts/src/Views/frappe/script.blade.php 0000644 00000003506 15002264225 0014256 0 ustar 00 <script {!! $chart->displayScriptAttributes() !!}> function {{ $chart->id }}_getType(data) { var special_datasets = {!! json_encode($chart->special_datasets) !!}; for (var i = 0; i < special_datasets.length; i++) { for (var k = 0; k < data.length; k++) { if (special_datasets[i] == data[k].chartType) { return special_datasets[i]; } } } return 'axis-mixed'; } function {{ $chart->id }}_create(data) { {{ $chart->id }}_rendered = true; document.getElementById("{{ $chart->id }}_loader").style.display = 'none'; window.{{ $chart->id }} = new frappe.Chart("#{{ $chart->id }}", { {!! $chart->formatContainerOptions('js') !!} labels: {!! $chart->formatLabels() !!}, type: {{ $chart->id }}_getType(data), data: { labels: {!! $chart->formatLabels() !!}, datasets: data }, {!! $chart->formatOptions(false, true) !!} }); } @if ($chart->api_url) let {{ $chart->id }}_refresh = function (url) { document.getElementById("{{ $chart->id }}").style.display = 'none'; document.getElementById("{{ $chart->id }}_loader").style.display = 'flex'; if (typeof url !== 'undefined') { {{ $chart->id }}_api_url = url; } fetch({{ $chart->id }}_api_url) .then(data => data.json()) .then(data => { document.getElementById("{{ $chart->id }}_loader").style.display = 'none'; document.getElementById("{{ $chart->id }}").style.display = 'block'; {{ $chart->id }}.update({labels: {!! $chart->formatLabels() !!}, datasets: data}); }); }; @endif @include('charts::init') </script> charts/src/Views/fusioncharts/container.blade.php 0000644 00000000154 15002264225 0016163 0 ustar 00 <div id="{{ $chart->id }}" {!! $chart->formatContainerOptions('css') !!}> </div> @include('charts::loader') charts/src/Views/fusioncharts/script.blade.php 0000644 00000003745 15002264225 0015516 0 ustar 00 <script {!! $chart->displayScriptAttributes() !!}> function {{ $chart->id }}_create(data) { {{ $chart->id }}_rendered = true; document.getElementById("{{ $chart->id }}_loader").style.display = 'none'; @if ($chart->type) let {{ $chart->id }}_type = {{ $chart->type }} @else let {{ $chart->id }}_type = data[0].renderAs; @endif if (!{!! json_encode($chart->keepType) !!}.includes({{ $chart->id }}_type)) { {{ $chart->id }}_type = "{{ $chart->comboType }}" } FusionCharts.ready(function () { window.{{ $chart->id }} = new FusionCharts({ type: {{ $chart->id }}_type, renderAt: "{{ $chart->id }}", dataFormat: 'json', {!! $chart->formatContainerOptions('js', true) !!} dataSource: { categories: [{ category: {!! $chart->formatLabels() !!} }], dataset: data, chart: {!! $chart->formatOptions(true) !!} } }).render(); }); } @if ($chart->api_url) let {{ $chart->id }}_refresh = function (url) { document.getElementById("{{ $chart->id }}").style.display = 'none'; document.getElementById("{{ $chart->id }}_loader").style.display = 'flex'; if (typeof url !== 'undefined') { {{ $chart->id }}_api_url = url; } fetch({{ $chart->id }}_api_url) .then(data => data.json()) .then(data => { document.getElementById("{{ $chart->id }}_loader").style.display = 'none'; document.getElementById("{{ $chart->id }}").style.display = 'block'; let chartData = {{ $chart->id }}.getChartData("json"); chartData.dataset = data; {{ $chart->id }}.setChartData(chartData, "json"); }); }; @endif @include('charts::init') </script> charts/src/Views/init.blade.php 0000644 00000001235 15002264225 0012435 0 ustar 00 let {{ $chart->id }}_rendered = false; @if ($chart->api_url) let {{ $chart->id }}_api_url = "{!! $chart->api_url !!}"; @endif let {{ $chart->id }}_load = function () { if (document.getElementById("{{ $chart->id }}") && !{{ $chart->id }}_rendered) { @if ($chart->api_url) fetch({{ $chart->id }}_api_url) .then(data => data.json()) .then(data => { {{ $chart->id }}_create(data) }); @else {{ $chart->id }}_create({!! $chart->formatDatasets() !!}) @endif } }; window.addEventListener("load", {{ $chart->id }}_load); document.addEventListener("turbolinks:load", {{ $chart->id }}_load); charts/src/ChartsServiceProvider.php 0000644 00000001754 15002264225 0013615 0 ustar 00 <?php namespace ConsoleTVs\Charts; use Illuminate\Routing\Router; use Illuminate\Support\ServiceProvider; class ChartsServiceProvider extends ServiceProvider { /** * Bootstrap the application services. * * @return void */ public function boot(Router $router) { $this->publishes([ __DIR__.'/Config/charts.php' => config_path('charts.php'), ], 'charts_config'); $this->loadViewsFrom(__DIR__.'/Views', 'charts'); $this->publishes([ __DIR__.'/Views' => resource_path('views/vendor/charts'), ]); if ($this->app->runningInConsole()) { $this->commands([ \ConsoleTVs\Charts\Commands\ChartsCommand::class, ]); } } /** * Register the application services. * * @return void */ public function register() { $this->mergeConfigFrom( __DIR__.'/Config/charts.php', 'charts' ); } }
| ver. 1.4 |
Github
|
.
| PHP 8.2.28 | Generation time: 0 |
proxy
|
phpinfo
|
Settings