如何在Yii中给予自己的id到High Chart的容器中

j0pj023g  于 2022-11-09  发布在  其他
关注(0)|答案(2)|浏览(160)

我正在使用high-chart扩展,但我不知道如何将ID提供给容器,现在获得随机id,如yw11,yw12等,如何将我自己的id提供给容器,如graph1, graph2等,

zf2sa74q

zf2sa74q1#

您有两个选择:
1.将小部件id容器更改为此行中的状态。
1.直接设置容器的id:

$this->Widget('ext.highcharts.HighchartsWidget',array(
    'options' =>array(   
        'chart' => array('renderTo' => $id),                                 
        'title' => array('text' => 'title'),
        'yAxis' => array(
            'title' => array('text' => 'y-values'),                           
        )
    )        
));
dced5bon

dced5bon2#

将id设置为yii2中的highcharts:

echo Highcharts::widget([
    'id' => 'YOUR-CUSTOM-ID',
    'options' => [
        'chart' => [
            'type' => 'column',
            'margin' => [60, 10, 40, 40],
        ],
        'title' => [
            'text' => 'Symmetrical Distribution',
            'x' => 25
        ],
        'subtitle' => [
            'text' => 'Fisher\'s Iris Data: Sepal Width',
            'x' => 25,
        ],
        'legend' => [
            'enabled' => false,
        ],
        'credits' => [
            'enabled' => false,
        ],
        'tooltip' => [
        ],
        'scripts' => [
            'highcharts-more', // enables supplementary chart types (gauge, arearange, columnrange, etc.)
            'modules/exporting', // adds Exporting button/menu to chart
            'themes/grid'        // applies global 'grid' theme to all charts
        ],
        'plotOptions' => [
            'series' => [
                'pointPadding' => 0,
                'groupPadding' => 0.5,
                'borderColor' => 'rgba(255,255,255,0.5)',
                'color' => '#434348',
            ]
        ],
        'xAxis' => [
            'title' => [
                'text' => 'Sepal Width (cm)'
            ]
        ],
        'yAxis' => [
            'title' => [
                'text' => ''
            ]
        ],
        'series' => [
            [
                'name' => 'Distribution',
                'data' => [[2.1, 4], [2.3000000000000003, 7], [2.5, 13], [2.7, 23], [2.9000000000000004, 36], [3.1, 24], [3.3000000000000003, 18], [3.5000000000000004, 10], [3.7000000000000006, 9], [3.9000000000000004, 3], [4.1, 2], [4.300000000000001, 1]]
            ]
        ]
    ]
]);

相关问题