slavkovrn / yii2-visualize
jQuery Visualize 是 Yii 2.0 框架的扩展,用于绘制展示图表
1.0.1
2017-08-05 11:06 UTC
Requires
- yiisoft/yii2: ~2.0
This package is auto-updated.
Last update: 2024-09-12 04:43:19 UTC
README
该扩展使用 visualize.jQuery.js,并从定义的结构化 PHP 数组中生成图表。
安装
安装此扩展的首选方式是通过 Composer。
运行以下命令之一:
composer require slavkovrn/yii2-visualize
或者将以下内容添加到你的 composer.json 文件的 require 部分:
"slavkovrn/yii2-visualize": "*"
用法
在你的视图中设置扩展链接
<?php use slavkovrn\visualize\VisualizeWidget; ?> <?= VisualizeWidget::widget([ 'id' => 'graphic', // Id of visualize widget should be unique at page 'class' => 'graphic', // Class to define stile 'name' => 'Visualize', // Name of visualize widget 'style' => 'light', // Style of widget (only 'dark' or 'light' option) 'width' => 800, // Width of widget in pixels 'height' => 200, // Height of widget in pixels 'graphic' => [ // data of chart of structure defined 'SIN' => [ number_format(0,5) => sin(0), number_format(Pi()/4,5) => sin(Pi()/4), number_format(Pi()/2,5) => sin(Pi()/2), number_format(Pi()/2+Pi()/4,5) => sin(Pi()/2+Pi()/4), number_format(Pi(),5) => sin(Pi()), number_format(Pi()+Pi()/4,5) => sin(Pi()+Pi()/4), number_format(Pi()+Pi()/2,5) => sin(Pi()+Pi()/2), number_format(Pi()+Pi()/2+Pi()/4,5) => sin(Pi()+Pi()/2+Pi()/4), number_format(2*Pi(),5) => sin(2*Pi()), ], 'COS' => [ number_format(0,5) => cos(0), number_format(Pi()/4,5) => cos(Pi()/4), number_format(Pi()/2,5) => cos(Pi()/2), number_format(Pi()/2+Pi()/4,5) => cos(Pi()/2+Pi()/4), number_format(Pi(),5) => cos(Pi()), number_format(Pi()+Pi()/4,5) => cos(Pi()+Pi()/4), number_format(Pi()+Pi()/2,5) => cos(Pi()+Pi()/2), number_format(Pi()+Pi()/2+Pi()/4,5) => cos(Pi()+Pi()/2+Pi()/4), number_format(2*Pi(),5) => cos(2*Pi()), ], ] ]) ?>