I have data I want to enter into a table chart and some of the data is multiline. I can use a replace function to replace the new lines with something else, but testing has given me nothing that works.
Here's my test code so far
var data = google.visualization.arrayToDataTable([
['Name'],
['Tong \n Ning mu'],
['Huang Ang fa'],
['Teng nu']
]);
var wrapper = new google.visualization.ChartWrapper({
chartType: 'Table',
dataTable: data,
options: {'title': 'Countries'},
containerId: 'visualization'
});
wrapper.draw();
The \\n does not get replaced with a new line. Neither does \\r\\n. They both just disappear.
Edit: I found one solution below but is there any way to do it without using html?
Use the HTML line creak: <br />
, and set the Table's allowHtml
option to true
:
var data = google.visualization.arrayToDataTable([
['Name'],
['Tong<br />Ning mu'],
['Huang Ang fa'],
['Teng nu']
]);
var wrapper = new google.visualization.ChartWrapper({
chartType: 'Table',
dataTable: data,
options: {
'title': 'Countries',
allowHtml: true
},
containerId: 'visualization'
});
wrapper.draw();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.