定制 sjaakp/yii2-gcharts 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sjaakp/yii2-gcharts

Composer 安装命令:

composer require sjaakp/yii2-gcharts

包简介

Google Charts the Yii 2.0 way

README 文档

README

Google Charts the Yii 2.0 way

Latest Stable Version Total Downloads License

yii2-gcharts is a collection of widgets to render selected Google Charts in the Yii 2.0 PHP Framework, like you would use a GridView.

Currently, yii2-gcharts consists of the following widgets:

A demonstration of Yii2-gcharts is here.

Installation

Install yii2-gcharts with Composer. Either add the following to the require section of your composer.json file:

"sjaakp/yii2-gcharts": "*"

Or run:

composer require sjaakp/yii2-gcharts "*"

You can manually install yii2-gcharts by downloading the source in ZIP-format.

Using yii2-gcharts

Use the yii2 charts widgets just like you would use a GridView. For instance, in the Controller you might have something like:

<?php
// ...
public function actionPie()	{
	$dataProvider = new ActiveDataProvider([
		'query' => Country::find(),
	    'pagination' => false
	]);
	
	return $this->render('pie', [
		'dataProvider' => $dataProvider
	]);
}
// ...
?>

To render a PieChart in the View we could use:

<?php
use sjaakp\gcharts\PieChart;
?>
...
<?= PieChart::widget([
    'height' => '400px',
    'dataProvider' => $dataProvider,
    'columns' => [
        'name:string',
        'population'
    ],
    'options' => [
        'title' => 'Countries by Population'
    ],
]) ?>
...

Each of the chart types has slight variations in the column interpretation, and its own set of options. Consult the Google Charts documentation.

Options

All the yii2-gcharts widgets share the same options:

dataProvider

The data provider for the chart. This property is required. In most cases, it will be an ActiveDataProvider or an ArrayDataProvider.

columns

Chart column configuration array. Each array element configures one chart column. Each column configuration is an array or a string shortcut.

An array column configuration can have the following members (all are optional, but at least one must be given):

  • attribute The attribute name associated with this column. When value is not specified, the value of the attribute will be retrieved from each data model.

  • formatted The Google Charts formatted version of the data. Can be a callable of the form function($model, $attribute, $index, $widget).

  • label The label assigned to the data. If not given, it is either retrieved from the model or derived from attribute.

  • pattern The Google Charts pattern.

  • role The Google Charts role. Can be one of:

    • "annotation"
    • "annotationText"
    • "certainty"
    • "emphasis"
    • "interval"
    • "scope"
    • "style"
    • "tooltip"
  • type The Google Charts data type. Can be one of:

    • "number" (default)
    • "string"
    • "boolean"
    • "date"
    • "datetime"
    • "timeofday"
  • value The data value. This can be a callable of the form function($model, $attribute, $index, $widget). If not given, the value of the model's attribute is taken.

The string shortcut configuration specifies the attribute, type, and label in the format "attribute:type:label". Both type and label are optional; they take their default values if omitted.

mode

string This determines which variant of the chart is drawn. Must be one of:

  • "classic" (default) Draws the 'ordinary' version of the chart,
  • "material" Draws the new, Material version of the chart, if available,
  • "transition" Draws the Material version, if available, and also applies convertOptions() to the options

Notice that only a few of the charts are currently available in Material version and that they're in early beta, lacking lots of the 'classic' options.

Notice also that currently, the Material options are undocumented, so the only practical way to work with Material charts is using the "transition" mode.

version

string The version of the gcharts library used. Must be one of:

  • "current" (default),
  • "upcoming",
  • number

More information.

mapsApiKey

string Applies to GeoChart only. It is advised to provide GeoChart with an API-key of Google Maps.

sjaakp/yii2-gcharts 适用场景与选型建议

sjaakp/yii2-gcharts 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 35.64k 次下载、GitHub Stars 达 22, 最近一次更新时间为 2015 年 10 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「extension」 「charts」 「yii」 「widget」 「yii2」 「visualization」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 sjaakp/yii2-gcharts 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 sjaakp/yii2-gcharts 我们能提供哪些服务?
定制开发 / 二次开发

基于 sjaakp/yii2-gcharts 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 35.64k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 22
  • 点击次数: 14
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 22
  • Watchers: 6
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-10-29