简体   繁体   English

带有Google图表和Laravel的自定义工具提示

[英]Custom tooltip with google chart and Laravel

I´m trying to create customs tooltips with google charts and Laravel. 我正在尝试使用Google图表和Laravel创建海关工具提示。

    var rdb = new google.visualization.arrayToDataTable([
    ['', 'Contract Cost', 'Deployment Cost', {label: 'T2', role: 'tooltip'}],
    @foreach($rdbs as $rdb)
        @foreach ($rdb as $result)         
        ['{{mb_strimwidth($result->product, 0,50,"...")}}', {{$result->contract_costs}},{{$result->deployment_costs}},'{{$result->product}}'],
        @endforeach   
    @endforeach   

The '' has a product name limit to 50, the tooltips that I need to show have full product name. ''的产品名称限制为50,我需要显示的工具提示中包含完整的产品名称。 ¿Any idea why this code doesn't work? ¿知道这个代码为什么不起作用吗? The tooltips show name with limit to 50, not with the full name. 工具提示显示的名称不能超过50个,而不能显示全名。

Update: 更新:

var full= $( "panel-body" ).width();

    var options = {
        width: full,
        height: rdb.getNumberOfRows()*20,
        bars: 'horizontal', 
    }   

when using custom tooltips, 使用自定义工具提示时,
the tooltip role needs to follow the series column it represents 工具提示角色需要遵循其代表的系列列
each y-axis series should have its own tooltip column 每个y轴系列应具有其自己的工具提示列

you have two y-axis series ( 'Contract Cost' & 'Deployment Cost' ) 您有两个 y轴系列( 'Contract Cost''Deployment Cost'
but only one tooltip column 但只有一个工具提示列

to correct and show the full name for both tooltips, 更正并显示两个工具提示的全名,
add another tooltip column after 'Contract Cost' 'Contract Cost'之后添加另一个工具提示列

var rdb = new google.visualization.arrayToDataTable([
['', 'Contract Cost', {label: 'T1', role: 'tooltip'}, 'Deployment Cost', {label: 'T2', role: 'tooltip'}],
@foreach($rdbs as $rdb)
    @foreach ($rdb as $result)         
    ['{{mb_strimwidth($result->product, 0,50,"...")}}',{{$result->contract_costs}},'{{$result->product}}',{{$result->deployment_costs}},'{{$result->product}}'],
    @endforeach   
@endforeach   

EDIT 编辑

column roles , such as 'tooltip' , are not supported by Material charts... 材质图表不支持 列角色 ,例如'tooltip' ...

see --> Tracking Issue for Material Chart Feature Parity 请参阅-> 物料图特征奇偶校验的跟踪问题
for the several other options that are not supported... 对于其他不支持的其他选项...

Material --> google.charts.Bar -- packages: ['bar'] 材料 -> google.charts.Bar packages: ['bar']

Classic --> google.visualization.BarChart -- packages: ['corechart'] 经典 -> google.visualization.BarChart packages: ['corechart']

note: there is an option to style Classic charts similar to Material charts 注意:有一个样式可以设置类似于 材料图的经典图样式

theme: 'material'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM