简体   繁体   English

悬停值标签上的Google图表工具提示触发器

[英]Google Charts tooltip trigger on hover value label

I have a problem with Google Charts. 我对Google图表有疑问。 I have a bar chart with some big and small values. 我有一些大小值的条形图。 The bars also have a value label. 这些条也有一个值标签。 If I hover the bars, the tooltip will be shown. 如果将鼠标悬停在条形图上,将显示工具提示。 But when I hover the value label (inside or outside the bar), no tooltip is shown. 但是,当我将值标签悬停在条形图的内部或外部时,没有显示工具提示。 So i have no possibility to show the tooltip on very small bars. 因此,我无法在很小的栏上显示工具提示。

Simplified Example: https://jsfiddle.net/2d0kbLnm/40/ 简化示例: https : //jsfiddle.net/2d0kbLnm/40/

Do you know how to tell Google Charts to show the tooltip on hover the value labels?. 您知道如何告诉Google图表在悬浮值标签时显示工具提示吗?

A focusTarget: 'category' enforces further informations on the tooltip, that i don't want. focusTarget: 'category'强制在工具提示上提供我不想要的其他信息。 The x-Axis value (with a blue dot) and the y-Axis title are inserted in the tooltip. x轴值(带有蓝色圆点)和y轴标题插入工具提示中。 Can I prevent this? 我可以预防吗? I want only show my html value. 我只想显示我的html值。 Furthermore the tooltip also hides on hovering the value label. 此外,工具提示也会隐藏在值标签上。

Thank you for any help and ideas. 感谢您的帮助和想法。

heiwil heiwil

there is another column role that will show additional text on hover of the annotation, 还有一个列角色将在注释的悬停时显示其他文本,
it is --> role: 'annotationText' 它是-> role: 'annotationText'

it is not necessarily a tooltip, and will not display html, 它不一定是工具提示,也不会显示html,
but does appear when the annotation is hovered. 但是当悬停注释时确实会出现。

this is the only "standard" option available. 这是唯一可用的“标准”选项。

see following working snippet, 请参阅以下工作片段,
the 'annotationText' is added in a data view calculated column, 在数据视图计算列中添加了'annotationText'
so the content may be built dynamically. 因此内容可以动态构建。
hover the annotation to see the result. 将鼠标悬停在注释上即可查看结果。

 google.charts.load('current', { packages: ['corechart'] }).then(function () { var data = google.visualization.arrayToDataTable([ ['Element', 'Saldo', {role: 'style', type: 'string'}, {role: 'annotation', type: 'string'}], ['Element 1', 60000.15, '#3949AB', '60,000.15 CHF'], ['Element 2', 14.87, '#3D5AFE', '14.87 EUR'], ['Element 3', -13451.31, '#cc0000', '-13,451.31 EUR'], ['Element 4', 0, '#42A5F5', '0 CHF'] ]); var view = new google.visualization.DataView(data); view.setColumns([0, 1, 2, 3, { calc: function (dt, row) { return dt.getValue(row, 0) + ' - ' + dt.getColumnLabel(1) + ': ' + dt.getFormattedValue(row, 1); }, role: 'annotationText', type: 'string' }]); var options = { legend: { position: 'none' }, hAxis: { logscale: true }, vAxis: { gridlines: { color: 'transparent' }, textPosition: 'none' } }; var chart = new google.visualization.ColumnChart( document.getElementById('chart_div') ); chart.draw(view, options); // <-- use view to draw chart }); 
 <script src="https://www.gstatic.com/charts/loader.js"></script> <div id="chart_div"></div> 

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

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