duanjiao6735
2017-10-05 13:24
浏览 56

自定义工具提示与谷歌图表和Laravel

I´m trying to create customs tooltips with google charts and 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. ¿Any idea why this code doesn't work? The tooltips show name with limit to 50, not with the full name.

Update:

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

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

图片转代码服务由CSDN问答提供 功能建议

我正在尝试使用谷歌图表和Laravel创建海关工具提示。

  var rdb = new google.visualization.arrayToDataTable([
 ['','合同费用','部署费用',{标签:'T2',角色:'工具提示'}],
 @foreach  ($ rdbs为$ rdb)
 @foreach($ rdb as $ result)
 ['{{mb_strimwidth($ result-> product,0,50,“...”)}}',{{$ 结果 - > contract_costs}},{{$ result-> deployment_costs}},'{{$ result-> product}}'],
 @endforeach 
 @endforeach 
   
 
 

''的产品名称限制为50,我需要显示的工具提示具有完整的产品名称。¿任何想法为什么此代码不起作用?工具提示显示名称限制为50 ,而不是全名。

更新:

  var full = $(“panel-body  “).width(); 
 
 var options = {
 width:full,
 height:rdb.getNumberOfRows()* 20,
 bars:'horizo​​ntal',
} 
    
 
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douwen7603 2017-10-05 14:02
    已采纳

    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

    you have two y-axis series ('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'

    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...

    see --> Tracking Issue for Material Chart Feature Parity
    for the several other options that are not supported...

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

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

    note: there is an option to style Classic charts similar to Material charts

    theme: 'material'
    
    已采纳该答案
    打赏 评论

相关推荐 更多相似问题