PHPackages                             nterms/yii2-redactor-charts - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. nterms/yii2-redactor-charts

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

nterms/yii2-redactor-charts
===========================

An asset bundle to use chart.js plugin for Imperavi Redactor

1.0.0(10y ago)027MITPHP

Since Oct 12Pushed 10y ago1 watchersCompare

[ Source](https://github.com/nterms/yii2-redactor-charts)[ Packagist](https://packagist.org/packages/nterms/yii2-redactor-charts)[ RSS](/packages/nterms-yii2-redactor-charts/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

yii2-redactor-charts
====================

[](#yii2-redactor-charts)

A Chart.js plugin for Imperavi Redactor WYSIWYG editor. This plugin enables creating and inserting Bar, Line and Radar type charts to the content edited with Redactor.

[![Latest Stable Version](https://camo.githubusercontent.com/38e2fb98bb8ee307202f688d06f24672041bb1dde5e88009f98179c9ed9b9610/68747470733a2f2f706f7365722e707567782e6f72672f6e7465726d732f796969322d7265646163746f722d6368617274732f762f737461626c65)](https://packagist.org/packages/nterms/yii2-redactor-charts) [![Total Downloads](https://camo.githubusercontent.com/650f16e0cd08e33084b972b7325aa3a47b68d1b53d0f81578cd2900fdadee90d/68747470733a2f2f706f7365722e707567782e6f72672f6e7465726d732f796969322d7265646163746f722d6368617274732f646f776e6c6f616473)](https://packagist.org/packages/nterms/yii2-redactor-charts) [![Latest Unstable Version](https://camo.githubusercontent.com/a533535e1650c64d7a2797388e5dfce40e32c927d585fc09c0bd11519e4bc502/68747470733a2f2f706f7365722e707567782e6f72672f6e7465726d732f796969322d7265646163746f722d6368617274732f762f756e737461626c65)](https://packagist.org/packages/nterms/yii2-redactor-charts) [![License](https://camo.githubusercontent.com/9400f50b8e6e81d4dbf13c8c2d902a64b6ca0d2eff018642de0cbee8a295adfa/68747470733a2f2f706f7365722e707567782e6f72672f6e7465726d732f796969322d7265646163746f722d6368617274732f6c6963656e7365)](https://packagist.org/packages/nterms/yii2-redactor-charts)

Prerequisites
-------------

[](#prerequisites)

This plugin works only on Imperavi Redactor WYSIWYG editor. You may use Redactor by directly loading `redactor.js` and `redactor.css` or useing some Yii2 extension. There are few yii2 extensions developed for integrating Redactor with your Yii2 project. This plugin does not depend on any specific extension. Theoretically it should work with all of those extensions. Here is a list of yii2-redactor extension I could find. Its up to your choice to use one suits for you.

- [asofter/yii2-imperavi-redactor](https://github.com/asofter/yii2-imperavi-redactor) - Tested
- [yiidoc/yii2-redactor](https://github.com/yiidoc/yii2-redactor)
- [vova07/yii2-imperavi-widget](https://github.com/vova07/yii2-imperavi-widget)

Please find the usage instructions for each of the above extensions below under [Usage](#usage) section.

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist nterms/yii2-redactor-charts "*"

```

or add

```
"nterms/yii2-redactor-charts": "*"

```

to the require section of your `composer.json` file.

Usage
---------------------------------------

[](#usage-)

Register the asset bundle with your view. In case you register the asset bundle in your view file:

```
\nterms\redactor\charts\ChartsRedactorPluginAsset::register($this);
```

Now enable the `charts` plugin when you initialize Redactor. In JavaScript:

```
$('#textarea').redactor({
    plugins: ['charts'],
});
```

### Use with [asofter/yii2-imperavi-redactor](https://github.com/asofter/yii2-imperavi-redactor) - Tested

[](#use-with-asofteryii2-imperavi-redactor---tested)

Register the `ChartsRedactorPluginAsset` asset bundle as shown above and enable the plugin:

```
yii\imperavi\Widget::widget([
    'options' => [
        'lang' => 'ru',
    ],
    'plugins' => [
        'charts',
    ]
]);
```

In case the plugin is not loaded. Check the order of the JavaScript files loded on your page. You can simply set the `charts` plugin related asset files load after the widget assets by adding following to your application configuration. On your `web.php` add:

```
'assetManager' => [
    'bundles' => [
        'nterms\redactor\charts\ChartsRedactorPluginAsset' => [
            'depends' => [
                'yii\imperavi\ImperaviRedactorAsset',
                'nterms\redactor\charts\ChartjsAsset',
            ],
        ],
    ],
],
```

This indicates that `ChartsRedactorPluginAsset` asset bundle depends on asset bundle of the widget, making it load assets in proper order. Make sure you add `nterms\redactor\charts\ChartjsAsset` to the list as this overwrites the original list.

### Use with [yiidoc/yii2-redactor](https://github.com/yiidoc/yii2-redactor) - Not tested

[](#use-with-yiidocyii2-redactor---not-tested)

Register the `ChartsRedactorPluginAsset` asset bundle as shown above and enable the plugin:

```
