- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有一个使用 Google Charts 的基本面积图.我可以为图表上的每个点设置工具提示,但有没有办法为一列中的所有点设置一个工具提示。
这是所需行为的屏幕截图:
您可以看到,当光标位于图表上的一个点上时,会绘制一条垂直线,并显示一个工具提示来描述该列中的所有数据(两条线的数据)。查看live example如果需要,请点击此处。
这可以通过 Google Charts 实现吗?
最佳答案
您需要做的就是将以下内容添加到您的选项中(在折线图的情况下):focusTarget: 'category'
这是一个例子(只需打开 Google Playground 并将以上行添加到末尾的选项中):
function drawVisualization() {
// Create and populate the data table.
var data = google.visualization.arrayToDataTable([
['x', 'Cats', 'Blanket 1', 'Blanket 2'],
['A', 1, 1, 0.5],
['B', 2, 0.5, 1],
['C', 4, 1, 0.5],
['D', 8, 0.5, 1],
['E', 7, 1, 0.5],
['F', 7, 0.5, 1],
['G', 8, 1, 0.5],
['H', 4, 0.5, 1],
['I', 2, 1, 0.5],
['J', 3.5, 0.5, 1],
['K', 3, 1, 0.5],
['L', 3.5, 0.5, 1],
['M', 1, 1, 0.5],
['N', 1, 0.5, 1]
]);
// Create and draw the visualization.
new google.visualization.LineChart(document.getElementById('visualization')).
draw(data, {curveType: "function",
width: 500, height: 400,
vAxis: {maxValue: 10},
// This line will make you select an entire row of data at a time
focusTarget: 'category'
}
);
}
简单易行!有关详细信息,请参阅 focusTarget in the Google Documentation
如果你想要更复杂的东西,你可以摆弄 domain Data Role
下面是一段代码示例:
google.load('visualization', '1.1', {'packages':['corechart']});
google.setOnLoadCallback(drawChart_C6);
function drawChart_C6() {
var data = new google.visualization.DataTable();
data.addColumn({type: 'string', role: 'domain'}, '2009 Quarter');
data.addColumn('number', '2009 Sales');
data.addColumn('number', '2009 Expenses');
data.addColumn({type: 'string', role: 'domain'}, '2008 Quarter');
data.addColumn('number', '2008 Sales');
data.addColumn('number', '2008 Expenses');
data.addRows([
['Q1 \'09', 1000, 400, 'Q1 \'08', 800, 300],
['Q2 \'09', 1170, 460, 'Q2 \'08', 750, 400],
['Q3 \'09', 660, 1120, 'Q3 \'08', 700, 540],
['Q4 \'09', 1030, 540, 'Q4 \'08', 820, 620]
]);
var chart = new google.visualization.LineChart(document.getElementById('chart_C6'));
chart.draw(data, {width: 400, height: 240, legend:'right', focusTarget: 'category'});
}
关于javascript - 谷歌图表 : One Tooltip for Entire Column,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15351243/
我有一个多行的 Google LineChart。这些点不共享相同的 X 值,所以我必须以某种方式格式化我的数据以使其工作: var data = google.visualization.array
如何在某些 View 上显示工具提示/提示? 例如,在按钮上。 最佳答案 感谢两位 Andrew和 Sorin为解决方向。所提出的解决方案大多有效,但是当我使用它们时,它们完全弄乱了布局。事实证明,工
我在 DataGridView 上使用 winforms ToolTip 类(不是 datagridview 的工具提示,因为我需要自定义格式。) 然后我在 DataGridView 的 CellMo
我有两个工具提示,一个在外部元素上,另一个在内部元素上,如下所示: 如何在显示内部工具提示时删除外部工具提示? Here's a Fiddle 代码非常标准,但请记住,有时 v-tooltip像模式一
是的,这个问题已经被问过here在 SO。 问题是该问题的解决方案是隐藏工具提示,我真的需要删除而不是隐藏它。 我正在使用我制作的几个函数向我的表单中的几个控件添加工具提示。 有两个函数,一个是设置T
我的方法是使用特定的工具提示格式配置图表: Highcharts.chart('container', { tooltip: { formatter: function
我正在尝试在带有 Datagrid 的 WPF 窗体的单元格上设置工具提示。这行得通,但我不希望它在没有弹出文本可显示的单元格中弹出。 我在这里看到过类似的问题,但我无法让这些解决方案发挥作用。 这是
Angular 2 (2.0.0-rc.4)我使用 Bootstrap 的 Tooltip,Tooltip 需要在准备好后执行 javascript: $(function () { $('[da
目前我正在尝试将 ToolTip 的 IsOpen 属性绑定(bind)到我的支持 View 模型的属性。此外,绑定(bind)模式设置为“OneWayToSource”。 这是应用于 TreeVie
我应该关注以下 HTML 验证错误吗? …rel="tooltip" data-placement="bottom" data-original-title="Permalink">
我有一组数据,正在以散点图形式绘制。当我将鼠标悬停在其中一个圆圈上时,我希望它弹出数据(例如 x、y 值,也许更多)。这是我尝试使用的: vis.selectAll("circle") .dat
http://jsfiddle.net/Margo/yKG7X/1/我正在使用工具提示功能,就像 fiddle 一样。 $("#placeholder").bind("plothover",
当前的 Android YouTube 应用程序为导航用户界面提供了有用的提示。例如:当用户第一次在播放视频时切换选项卡时,会弹出一个带有箭头的小“工具提示”,上面写着“您也可以通过左右滑动来切换选项
我正在为我的项目使用 NVD3 库,并编写了以下代码。 var chart = nv.models.lineChart() .useInteractiveGuideline(t
我正在显示 jQuery UI Tooltip悬停时,就在我的元素中间。但是当将鼠标悬停在工具提示上时,工具提示本身就会消失。 (传播问题) 元素: 带有工具提示: 因此,当我将鼠标悬停在工具提示本身
我正在尝试使用从以下内容中找到的 .tooltip():Jquery-ui tooltip 。我拥有的是一个 Rails 应用程序,它在表格中包含一些信息。在单独的牢房中。目前,您可以通过单击单元格来
我使用 Highcharts 创建了一个图表。 工具提示在 FF 和 IE 中工作正常,但在 chorme 中,文本超出了框架。 我尝试使用 HTML tooltip: { //Tr
长话短说:我有一个窗口,在列表框中显示一堆图表。当鼠标悬停在图表上(使用 LineSeries)时,数据点后面有一条线(捕捉到数据点位置)。在那条线附近,我将展示一个由弹出窗口制成的工具提示,其中显示
现在使用 nv.d3 示例中的 stackedAreaChart(),当您将鼠标悬停在时间序列中的某个点上时,您会得到一个工具提示。 我垂直对齐了 3 个时间序列。如果鼠标悬停在其中任何一个点上,我希
我创建了一个具有两个数据集的 Chart JS 2 图。 当我将鼠标悬停在一行上时,我只会得到当前行的数据,但我也想查看另一行的数据。 如何在工具提示中添加特定日期的所有数据? 最佳答案 要在工具提示
我是一名优秀的程序员,十分优秀!