wladiz2001 / visjs
Visjs 4 集成于 Laravel > 5.5
1.0.3
2019-03-10 02:15 UTC
Requires
Requires (Dev)
- mockery/mockery: ^1.1
- orchestra/testbench: ~3.0
- phpunit/phpunit: ~7.0
- sempro/phpunit-pretty-print: ^1.0
This package is not auto-updated.
Last update: 2024-10-01 03:19:03 UTC
README
一个简单的包,用于简化并自动化 Laravel 5.x 中(网络)图表的使用
使用 Visjs。
代码灵感来源于 laravel-chartjs。
安装
通过 Composer
$ composer require wladiz2001/visjs
最后,目前,您必须安装并将 Visjs 库添加到您的布局/模板中,该库可以在以下位置轻松下载:[http://visjs.org/](http://visjs.org/)。此设置也将得到改进。
用法
您可以向服务容器请求负责构建图表的服务,并通过流畅的接口传递图表设置。
$service = app()->visjs ->name() ->type() ->size() ->datasets() ->options();
目前,构建器需要图表名称、图表类型(可以是 Visjs 支持的任何类型)以及其他自定义配置,如数据集、大小和选项。
在数据集接口中,您可以向图表传递任何配置和选项。Visjs 文档中提供的所有选项都受支持。只需用 PHP 数组表示法编写配置即可!
高级 Visjs 选项
由于当前版本允许添加基于简单 JSON 字符串的选项,因此无法生成如下选项:
options: { scales: { xAxes: [{ type: 'time', time: { displayFormats: { quarter: 'MMM YYYY' } } }] } }
使用 optionsRaw(string) 方法可以以原始格式添加选项
$chart->optionsRaw = "{ legend: { display:false }, scales: { xAxes: [{ gridLines: { display:false } }] } }";
示例
1 - 网络图表
// ExampleController.php $edges = [ ["from" => 7905, "to" => "7886", "label" => 50068, "length" => 10], ["from" => -1, "to" => "7905", "label" => 100, "group" => 40] ]; $nodes = [ ["id" => -10, "shape" => "circularImage", "size" => 40, "color" => '#999', "borderWidth" => 1], ["id" => 7905, "label" => "loyal", "value" => 500, "group" => 'big1'], ["id" => 7886, "label" => "sensitive", "value" => 100, "group" => 'big2'] ]; $visjs = app()->visjs ->name('networkChartTest') ->type('Network') ->size(['width' => 400, 'height' => 200]) ->datasets(["nodes" => $nodes, "edges" => $edges]) ->options([]); return view('example', compact('visjs')); // example.blade.php <div style="width:75%;"> {!! $visjs->render() !!} </div>
注意
本 README 以及本包正在开发中,但将不断更新,并将在准备好生产版本时通知您。感谢您的理解。
如有任何问题或建议,请尽量提出问题!
许可
VisJs 是开源软件,使用 MIT 许可证。
变更日志
有关最近更改的更多信息,请参阅变更日志。
测试
$ composer test
贡献
有关详细信息,请参阅contributing.md 以及待办事项列表。
安全
如果您发现任何安全相关问题,请通过作者电子邮件而不是使用问题跟踪器。