如何在Google可视化API中使用多行标注? [英] How to have multiple-line annotations in Google Visualization API?
问题描述
我试图使用google可视化API生成一个带注释的LineChart,并且尽管我有它的工作,但我希望能够在有可能的情况下使注释具有换行符。不幸的是,Google的API似乎忽略了任何换行信息,并在一行中显示所有内容。有没有人想出了解决这个问题的方法?
下面是一个例子:
var data = new google.visualization.DataTable();
data.addColumn('string','Month');
data.addColumn('number','Sales');
data.addColumn({type:'string',role:'annotation'});
data.addColumn({type:'string',role:'annotationText'});
data.addRows([
['April',1000,'A','Stolen data \\\
So-so month'],
['May',1170,'B' ,咖啡溢出,另一行,第三行],
['June',660,'C','Wumpus attack']
]);
我试过 \\\
并且这些都不起作用。 c> p':{'html':true}} 这样的工具提示
,\\ n和< br />
data .addColumn({type:'string',role:'tooltip','p':{'html':true}});
然后添加< br />
到您的工具提示内容
I'm attempting to generate an annotated LineChart using the google visualization API, and while I have it working, I would like to be able to have annotations have line-breaks if possible. Unfortunately, it seems like Google's API ignores any newline information and displays everything on a single line. Has anyone come up with a way around this?
Here's an example:
var data = new google.visualization.DataTable();
data.addColumn('string', 'Month');
data.addColumn('number', 'Sales');
data.addColumn({type:'string', role:'annotation'});
data.addColumn({type:'string', role:'annotationText'});
data.addRows([
['April',1000, 'A', "Stolen data\nSo-so month"],
['May', 1170, 'B', "Coffee spill\nAnother line\nA third line"],
['June', 660, 'C', "Wumpus attack"]
]);
I've tried \n, \\n, and <br />
and those aren't working.
Add p': {'html': true}}
to your tooltip like this
data.addColumn({type:'string', role:'tooltip','p': {'html': true}});
then your add <br/>
to your tooltip content
这篇关于如何在Google可视化API中使用多行标注?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!