【问题标题】:Yii2 Highcharts syntax in functionYii2 Highcharts 函数中的语法
【发布时间】:2015-10-19 13:36:44
【问题描述】:

我想在 Highcharts Yii2 中的饼图图例中添加图像。请参阅example,但我无法将其写入我的 PHP 小部件中的 labelFormat 部分。

<? = \dosamigos\highcharts\HighCharts::widget([
  'clientOptions' => [
    'chart' => [
      'type' => 'pie'
    ],
    'legend' => [
      'useHTML' => TRUE,
      'labelFormatter' => "function () {
        return '<img src='http://highcharts.com/demo/gfx/sun.png'/>' + this.name;
      }",
      'itemMarginBottom' => 5
    ],
    ...
?>

【问题讨论】:

  • 查看你的 js 控制台,如果有任何错误
  • 控制台没有错误。

标签: javascript php highcharts yii2


【解决方案1】:

我认为应该有:

'legend' => [
  'useHTML' => TRUE,
  'labelFormatter' => new JsExpression('function () { return \"<img src="http://highcharts.com/demo/gfx/sun.png"/>\" + this.name; }'),
  'itemMarginBottom' => 5
],

根据here的第一个提示。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-07-25
    • 2019-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-08
    相关资源
    最近更新 更多