如何从Google Chart API获取条形名称 [英] How to get the bar names from Google Chart api

查看:21
本文介绍了如何从Google Chart API获取条形名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我被困了几天!
我制作了一个应用来显示猫的品种以及何时在欧洲发现它们.

这是我的代码:

由于论坛想要重新格式化,因此我无法在此处发布我的代码.
检查我的Google云端硬盘:
我的代码

我想做的就是获取时间轴栏中的名称.例如,如果我单击"pers(ion)",我想动态地使div包含有关pers(ion)的更多信息.但是因为它没有类或ID,所以我无法获得它.

现在有人容易做到这一点吗?

解决方案

这将帮助您获取BAR的名称.如果您的数据是

  var data = new google.visualization.arrayToDataTable([['Object','Count'],["ApexClass",apexCount],["Sobjects",objectCount],["ApexPage",vfPageCount],[角色",rolesCount],["Dashboard",dashboardCount],[个人资料",profileCount]]); 

然后在选择处理程序中将其写入

  google.visualization.events.addListener(barchart,'select',countsChartSelectListener);函数countsChartSelectListener(){var selectedItem = barchart.getSelection()[0];如果(selectedItem){var barName = data.getValue(selectedItem.row,0); 

I am stuck for a couple of days!
I making an app that show cat breeds and when they are discovered in europe.

This is my code:

Since I can't post my code here because the forum want to reformat it.
Check my Google drive:
My code
https://docs.google.com/document/d/1wiwgFI3tGimvXKzOinLUZMYXAaMVscECeQopiyEHB98/edit?usp=sharing

And It returns a good looking chart that looks like this:

What I trying to do is getting the name that's inside a bar of the timeline. As an example, if I click on "pers(ion)" , I want to make dynamicaly a div with more information about the pers(ion). But because it doesn't get a class or id I can't get it.

Does anybody now an easy way do do this?

解决方案

This will help you get the name of the BAR. If you data is

var data = new google.visualization.arrayToDataTable([
    ['Object', 'Count'],
    ["ApexClass", apexCount],
    ["Sobjects", objectCount],
    ["ApexPage", vfPageCount],
    ["Role", rolesCount],
    ["Dashboard", dashboardCount],
    ["Profile", profileCount]

    ]);

Then in select Handler write this

google.visualization.events.addListener(barchart, 'select', countsChartSelectListener);
    function countsChartSelectListener(){
        var selectedItem = barchart.getSelection()[0];
        if (selectedItem) {
            var barName = data.getValue(selectedItem.row, 0);

这篇关于如何从Google Chart API获取条形名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆