miloschuman / yii2-highcharts

Highcharts widget for Yii 2 Framework
http://www.yiiframework.com/extension/yii2-highcharts-widget/
MIT License
166 stars 63 forks source link

pie with gradient #49

Closed arsitek closed 7 years ago

arsitek commented 7 years ago

Any example to create pie chart with gradient color like this http://www.highcharts.com/demo/pie-gradient?

Thank you for help

bscheshirwork commented 7 years ago

Use setupOptions property - set setupOption['color'] to text of js function (from your example)

You should use yii\web\JsExpression

    echo Highcharts::widget([
        'scripts' => [
            'modules/exporting', // adds Exporting button/menu to chart
        ],
        'setupOption' => ['color' => new yii\web\JsExpression(<<<JSE
function (color) {
    return {
        radialGradient: {
            cx: 0.5,
            cy: 0.3,
            r: 0.7
        },
        stops: [
            [0, color],
            [1, Highcharts.Color(color).brighten(-0.3).get('rgb')] // darken
        ]
    };
}
JSE
        )],
        'options' => ... 
    ]);
miloschuman commented 7 years ago

Thanks for helping out, @bscheshirwork.

harsh-growfitter commented 4 years ago

using this gives the following error: Setting unknown property: miloschuman\highcharts\Highcharts::setupOption