在Google图表自定义html工具提示中添加php datatable中的属性 [英] Adding property in php datatable for google chart custom html tooltips
问题描述
$ datatable = array('cols'=> array(
array('type'=>'string','role'=>'domain' =''Month'),
array('type'=>'string','role'=>'tooltip'),
array('type'=>'string' ,'role'=>'domain','label'=>'Omzet'),
array('type'=>'number','label'=>'Omzet'$ jaar )
array('type'=>'number','label'=>'Omzet'($ jaar-1)),
array('type'=>'string ','role'=>'domain','label'=>'Aantal'),
array('type'=>'number','label'=>'Aantal' jaar),
array('type'=>'number','label'=>'Aantal'($ jaar-1))
));
并填充如下:
$ datatable ['rows'] [] = array('c'=> array(
array('v'=> $ monthname),
array 'v'=>'< h1> custom< / h1> tooltip'$ monthname),
array('v'=>'Omzet'。$ monthname),
array v'=> $ row ['totaal']),
数组('v'=> $ omzet),
数组('v'=>'Aantal'),
array('v'=> $ row ['aantal']),
array('v'=> $ aantal)
));
然而,对于可以在JavaScript中为google图表指定的datatable,您必须添加类似
dataTable.addColumn({'type':'string','role':'tooltip','p' html':true}});
否则,工具提示将作为纯文本而不是html标记出来
https://developers.google.com/chart/interactive/docs/customizing_tooltip_content#customizing -html-content
这意味着我必须以某种方式添加'p':{'html':true} 财产到我的datatable
我已经尝试通过编辑它
array('type'=>'string','role'=>'tooltip','p'=>'{html:true}'),
pre>
甚至
array('type'=> ;'string','role'=>'tooltip','html'=> true),
但是没有一个似乎无法正常工作,我无法在google上找到一个方法。
我希望我给了足够的信息如果还有什么需要,请让我知道。
这是我第一次在这里发帖,所以请很好((
解决方案你正在跟踪
array('type'=> 'string','role'=> 'tooltip','p'=> '{html:true}'),
,但是您需要为'html'添加一个数组:true
part。
它应该像
array('type'=>'string','role'=>'tooltip','p'=>数组('html'=> true));
我在这里尝试过:链接到测试
I am trying to create custom html tooltips in my google chart by adding them into the datatable, right now my datatable is being created in PHP like this:
$datatable = array('cols' => array( array('type' => 'string', 'role' => 'domain', 'label' => 'Month'), array('type' => 'string', 'role' => 'tooltip'), array('type' => 'string', 'role' => 'domain', 'label' => 'Omzet'), array('type' => 'number', 'label' => 'Omzet '.$jaar), array('type' => 'number', 'label' => 'Omzet '.($jaar-1)), array('type' => 'string', 'role' => 'domain', 'label' => 'Aantal'), array('type' => 'number', 'label' => 'Aantal '.$jaar), array('type' => 'number', 'label' => 'Aantal '.($jaar-1)) ));
and filled like this:
$datatable['rows'][] = array('c' => array( array('v' => $monthname), array('v' => '<h1>custom</h1> tooltip '.$monthname), array('v' => 'Omzet '.$monthname), array('v' => $row['totaal']), array('v' => $omzet), array('v' => 'Aantal'), array('v' => $row['aantal']), array('v' => $aantal) ));
however for the datatable you can specify in Javascript for the google chart, you have to add something like
dataTable.addColumn({'type': 'string', 'role': 'tooltip', 'p': {'html': true}});
otherwise the tooltip would come out as plain text instead of html markup https://developers.google.com/chart/interactive/docs/customizing_tooltip_content#customizing-html-content
which means I will have to somehow add the 'p' : { 'html' : true } property to my datatable
I have tried by editing it to
array('type' => 'string', 'role' => 'tooltip', 'p' => '{ html : true}'),
or even to
array('type' => 'string', 'role' => 'tooltip', 'html' => true),
but none of these seem to work and I can't find a way to do it on google either.
I hope i've given enough information to help come up with an answer, if there's anything more you need please let me know.
This is my first time posting a question here so please be nice (:
解决方案You were on the right track with
array('type' => 'string', 'role' => 'tooltip', 'p' => '{ html : true}'),
but you need to have an additional array for the'html': true
part.It should look like
array('type' => 'string', 'role' => 'tooltip', 'p' => array('html' => true));
I tried it out here: Link to test
这篇关于在Google图表自定义html工具提示中添加php datatable中的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!