Answer the question
In order to leave comments, you need to log in
How to bind a click handler on a point in Highcharts?
Good afternoon.
In Yii2 I use the widget www.yiiframework.com/extension/yii2-highcharts-widget
<?php
use miloschuman\highcharts\Highcharts;
$this->registerAssetBundle('yii\web\YiiAsset');
echo Highcharts::widget([
'options' => [
'title' => ['text' => 'Статистика за месяц'],
'xAxis' => [
'categories' => array_keys($statistic)
],
'yAxis' => [
'title' => ['text' => 'Достижения цели']
],
'series' => [
['name' => 'Jane', 'data' => array_values($statistic), 'class'=>'test-class'],
],
'plotOptions' => [
'series' => [
'cursor' => 'pointer',
'point' => [
'events' => [
'click' => 'function(e){ alert(this.x); }'
]
]
]
]
]
]);
Uncaught TypeError: ((jQuery.event.special[handleObj.origType] || (intermediate value)).handle || handleObj.handler).apply is not a function
...],"plotOptions":{"series":{"cursor":"pointer","point":{"events":{"click":"function(e){ alert(this.x); }"}}}}});
Answer the question
In order to leave comments, you need to log in
use yii\web\JsExpression;
upd. More
<?php
use miloschuman\highcharts\Highcharts;
use yii\web\JsExpression;
$this->registerAssetBundle('yii\web\YiiAsset');
echo Highcharts::widget([
'options' => [
'title' => ['text' => 'Статистика за месяц'],
'xAxis' => [
'categories' => array_keys($statistic)
],
'yAxis' => [
'title' => ['text' => 'Достижения цели']
],
'series' => [
['name' => 'Jane', 'data' => array_values($statistic), 'class'=>'test-class'],
],
'plotOptions' => [
'series' => [
'cursor' => 'pointer',
'point' => [
'events' => [
'click' => new JsExpression('function(e){ alert(this.x); }')
]
]
]
]
]
]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question