Laravel Charts 图表 使用
2

composer require consoletvs/charts:6.*

可能报错

zsh: no matches found: consoletvs/charts:6.*

此时,需要在 ~/.zshrc 添加

alias composer='noglob composer'
composer require consoletvs/charts:6.*
php artisan vendor:publish --tag=charts_config
php artisan make:chart SampleChart

然后在控制器调用SampleChart类

use App\Charts\SampleChart;
$chart = new SampleChart;
$chart->labels(['One', 'Two', 'Three', 'Four']);
$chart->dataset('My dataset', 'line', [1, 2, 3, 4]);
$chart->dataset('My dataset 2', 'line', [4, 3, 2, 1]);
return view('sample_view', compact('chart'));

最后在HTML渲染

{!! $chart->container() !!}
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.min.js"></script>
{!! $chart->script() !!}
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
讨论数量: 3

第一次安装composer包报这个错

$ composer require consoletvs/charts:6.*
    1/8:        https://packagist.laravel-china.org/p/provider-latest$8330e6c47f0d7928991cc29870036aad273a568fbd7bbc507356bbd5d48c8466.json
    2/8:        https://packagist.laravel-china.org/p/provider-2018-10$0e1d6b404e963f8180f7e3bfb719d80f547b1e78a2b2932a00cb7d976faff11d.json
    3/8:        https://packagist.laravel-china.org/p/provider-2018-01$ba7b7983a3c1301d163f90d298d6e0d606b3a895a32a7c847591cb9c1ee056b8.json
    4/8:        https://packagist.laravel-china.org/p/provider-2018-04$312fbc0c21e13dafb9783c7dd9f8ffdaf59c3857a7f9973247136070e75374fd.json
    5/8:        https://packagist.laravel-china.org/p/provider-2018-07$416f0a818f89f18a25b366ff7c8b8c3b7cf29833cf18e3dcd1b0f18495020ef1.json
    6/8:        https://packagist.laravel-china.org/p/provider-2016$0236be99dd3571ad95d3a0ceb7f3988286a5ccc50c573194633f8d8276767a6d.json
    7/8:        https://packagist.laravel-china.org/p/provider-2015$5771d431334174a36135b01b11b4b3250cc810539ed792701516780e38858a3d.json
    8/8:        https://packagist.laravel-china.org/p/provider-2017$4fa82b14f6b97fb059cdf0bf51bfd586631b1c4d058e51eb1b15327b7b10c1ae.json
    Finished: success: 8, skipped: 0, failure: 0, total: 8
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)

VirtualAlloc() failed: [0x00000008] ▒洢▒ռ䲻▒㣬▒޷▒▒▒▒▒▒▒▒▒

VirtualFree() failed: [0x000001e7] ▒▒ͼ▒▒▒▒▒▒Ч▒ĵ▒ַ▒▒

VirtualAlloc() failed: [0x00000008] ▒洢▒ռ䲻▒㣬▒޷▒▒▒▒▒▒▒▒▒

VirtualFree() failed: [0x000001e7] ▒▒ͼ▒▒▒▒▒▒Ч▒ĵ▒ַ▒▒

PHP Fatal error:  Out of memory (allocated 952107008) (tried to allocate 4096 bytes) in phar://D:/php_study/PHPTutorial/php/php-7.1.13-nts/composer/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52

Fatal error: Out of memory (allocated 952107008) (tried to allocate 4096 bytes) in phar://D:/php_study/PHPTutorial/php/php-7.1.13-nts/composer/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52
2周前
becage

@lovecn 你这个报错PHP内存不足,phpinfo()查看下memory_limit配置,设置大点试试。

memory_limit    128M    128M
2周前

修改 app\Providers\AppServiceProvider.php 好了

public function boot()
    {
        Schema::defaultStringLength(191);
        ini_set('memory_limit', '1G');
    }
1周前

  • 请注意单词拼写,以及中英文排版,参考此页
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`, 更多语法请见这里 Markdown 语法
  • 支持表情,使用方法请见 Emoji 自动补全来咯,可用的 Emoji 请见 :metal: :point_right: Emoji 列表 :star: :sparkles:
  • 上传图片, 支持拖拽和剪切板黏贴上传, 格式限制 - jpg, png, gif
  • 发布框支持本地存储功能,会在内容变更时保存,「提交」按钮点击时清空
  请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!