使用带多行的JSON填充图表时,Google图表中的工具提示

时间:2013-11-05 16:13:55

标签: javascript json charts google-visualization tooltip

使用stackoverflow我正在使用Google创建自己的图表。 我读过这个: Tooltip in Google Chart while populating chart using JSON并且通过这条“指示”,我尝试用自定义工具提示但没有结果的多线图表。

我尝试过类似的东西

{"cols": [{"id": "", "label": "Date", "type": "string"},
    {"id": "", "label": "price", "type": "number"},
    {"id": "", "role": "tooltip", "type": "string", "p" : { "role" : "tooltip" } } 
    {"id": "", "label": "price2", "type": "number"},
    {"id": "", "role": "tooltip", "type": "string", "p" : { "role" : "tooltip" } } 
],
"rows": [
    {"c":[{"v": "Apr 24th","f":"null"}, {"v": 56000,"f":"56000"}, {"v": "24 April, Price - 56000, Seller-abcd"}, {"v": 50000,"f":"56000"}, {"v": "24 April, Price - 56000, Seller-abcd"}]},
    {"c":[{"v": "May 3rd","f":"null"}, {"v": 68000,"f":"68000"}, {"v": "3 May, Price - 68000, Seller-abcd"}, {"v": 56000,"f":"56000"}, {"v": "24 April, Price - 56000, Seller-abcd"}]},
    {"c":[{"v": "May 13th","f":"null"}, {"v": 50400,"f":"50400"}, {"v": "23 May, Price - 50000, Seller-abcd"}, {"v": 56000,"f":"56000"}, {"v": "24 April, Price - 66000, Seller-abcd"}]}
]}

那有什么问题?我想指定:用单行(复制上面链接的代码)这很好用,我的好图表:D 有人可以帮帮我吗?

1 个答案:

答案 0 :(得分:0)

您在第一个工具提示列后缺少逗号:

"cols": [
    {"id": "", "label": "Date", "type": "string"},
    {"id": "", "label": "price", "type": "number"},
    {"id": "", "role": "tooltip", "type": "string", "p" : { "role" : "tooltip" } }, // <--- need a comma here
    {"id": "", "label": "price2", "type": "number"},
    {"id": "", "role": "tooltip", "type": "string", "p" : { "role" : "tooltip" } } 
]