ede*_*ded 2 javascript google-api google-visualization google-datatable
在谷歌图表数据表对象中,我可以使用获取当前选择点值(V轴/ Y轴)datatable.getValue(...).但是,如果我想从X轴获得时间/日期/年份(见截图).我没有找到任何数据表的功能来实现这一点.有谁知道怎么做?

这是我的代码
google.visualization.events.addListener(chart, 'select', function(a, b, c, d) {
var selectedItem = chart.getSelection()[0];
if (selectedItem) {
// Get the current Y-axis value which is 1120
var value = data.getValue(selectedItem.row, selectedItem.column);
alert('The user selected ' + value);
// How I can get the value of 2015 which is the X-axis value??????
}
});
Run Code Online (Sandbox Code Playgroud)
在大多数情况下,您的轴值将在第0列,因此只需更改selectedItem.column为0,您将获得轴值:
var axisValue = data.getValue(selectedItem.row, 0);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1458 次 |
| 最近记录: |