exocet/yii2-chart-widget Chart implementation of chartist for yii2 framework

yii2-widget-chart

  1. Resources
  2. Installation
  3. Example Usage
  4. Ajax Example Usage
  5. License

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

0 0
1 follower
70 downloads
Yii Version: 2.0
License: MIT
Category: Others
Developed by: xchwarze
Created on: Sep 5, 2023
Last updated: 7 months ago
Packagist Profile
Github Repository

Related Extensions