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

How to add the following function? #62

Closed ajoudeh closed 6 years ago

ajoudeh commented 6 years ago

Dear,

How i can create same below example using your Widget? Specially the Function Part


$(function() {
        // Create the chart
        chart = new Highcharts.Chart({
            chart: {
                renderTo: 'container',
                type: 'pie'
            },
            title: {
                text: 'Direct Facility'
            },
            yAxis: {
                title: {
                    text: 'Total percent market share'
                }
            },
            plotOptions: {
                pie: {
                    shadow: false
                }
            },
            tooltip: {
                formatter: function() {
                    return '<b>'+ this.point.name +'</b>: '+ this.y +' %';
                }
            },
            series: [{
                //name: 'Browsers',
                data: [{
                name:"Amount",y:60,color:'#5c99fc'},{name:"Target Amount",y:100,color:'#cfcfcf'}],
                size: '80%',
                innerSize: '80%',
                showInLegend:false,
                dataLabels: {
                    enabled: false
                }
            }],
         },                            
 function(chart) { // on complete
              var textX = chart.plotLeft + (chart.plotWidth  * 0.5);
         var textY = chart.plotTop  + (chart.plotHeight * 0.5);

         var span = '<span id="pieChartInfoText" style="position:absolute; text-align:center;">';
         span += '<span style="font-size: 32px">50%</span><br>';
        span += '<span style="font-size: 16px">to goal</span>';
         span += '</span>';

         $("#addText").append(span);
         span = $('#pieChartInfoText');
         span.css('left', textX + (span.width() * -0.5));
         span.css('top', textY + (span.height() * -0.5));

         }

);
    });
miloschuman commented 6 years ago

You can use yii\web\JsExpression.

See the first tip in Readme.md#tips for sample usage.