Skip to content

xchwarze/yii2-chart-widget

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yii2-widget-chart

Wrapper for CHARTIST.JS library

Resources

Installation

The preferred way to install this extension is through composer

Either run

$ php composer.phar require --prefer-dist "exocet/yii2-chart-widget"

or add

{
	"require": {
  		"exocet/yii2-chart-widget": "~1.0"
	}
}

to the require section of your composer.json

Example Usage

<?php
/* @var $this yii\web\View */

use exocet\yii2\chart\Chart;
use yii\web\JsExpression;

$this->title = 'my example';
$this->params['breadcrumbs'][] = $this->title;

?>
<?php
echo Chart::widget([
           'type'              => Chart::TYPE_LINE,
           'disableCss'        => true, //disable chartist css
           'label'             => true, //enable labels plugin
           'labels'            => [1, 2, 3, 4],
           'series'            => [[100, 120, 180, 200]],
           'clientOptions'     => [
               'showLine' => false,
               'axisX'    => [
                   'labelInterpolationFnc' => new JsExpression('function(value, index) {
                       return index % 13 === 0 ? \'W\' + value : null;
                   }')
               ]
           ],
           'responsiveOptions' => [
               'screen and (min-width: 640px)' => [
                   'axisX' => [
                       'labelInterpolationFnc' => new JsExpression('function(value, index) {
                           return index % 4 === 0 ? \'W\' + value : null;
                       }')
                   ]
               ]
           ]
      ]);
?>

Ajax Example Usage

<?php
/* @var $this yii\web\View */

use exocet\yii2\chart\Chart;
use yii\web\JsExpression;
use yii\helpers\Url;

$this->title = 'my example';
$this->params['breadcrumbs'][] = $this->title;

?>
<?php
echo Chart::widget([
           'type'              => Chart::TYPE_LINE,
           'ajax'              => Url::to(['ajax-data']),
      ]);
?>

License

yii2-chart-widget is released under MIT license. See bundled LICENSE for details

About

Chart implementation of chartist for yii2 framework

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages