以下内容打破了我的 google.visualization.DataTable。我从谷歌日历中提取这个。
// this one has a line break/enter/new line in google calendar after 5
Kanji lessons from 11 to 15 or Kanji lesson's from 1 to 5
Beginner students dont have matome quiz. They have usual Katakana quiz from ta to po.
但以下工作正常。
// this does not have it.
Kanji lessons from 11 to 15 or Kanji lesson's from 1 to 5. Beginner students dont have matome quiz. They have usual Katakana quiz from ta to po.
我尝试了以下方法。但到目前为止,它们都没有奏效。
$description = str_replace(" "," ",$description);
$description_arr=explode("\\n",$description);
$description = implode("<br />", $description_arr);
整个代码
// Load the Visualization API and the piechart package.
google.load('visualization', '1.0', {'packages':['table,corechart']});
google.setOnLoadCallback(drawTable);
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
// start of tabel
function drawTable() {
var data = new google.visualization.DataTable();
//data.addColumn('string', 'Calendar Name');
data.addColumn('string', 'Date Due');
data.addColumn('string', 'Summary');
data.addColumn('string', 'Date Created');
data.addColumn('string', 'Description');
data.addRows([
<?php
if(count($events))
{
foreach($events->items as $item)
{
//$displayName = str_replace("'", "\'", $item->organizer->displayName);
$summary = str_replace("'", "\'", $item->getSummary());
$datedue = str_replace("'", "\'", $item->start->date);
$description = str_replace("'", "\'", $item->description);
$description = str_replace(" "," ",$description);
// $description_arr=explode("\\n",$description);
// $description = implode("<br />", $description_arr);
echo "['".$datedue."','".$summary . "','" . substr($item->created, 0, 10) ."','".$description."' ],\n";
//echo "['".$displayName."','".$summary."','".$date . "','" . substr($item->created, 0, 10) ."','".$descrption."' ],\n";
}
}
else
{
echo "Calendar is private.";
}
?>
]);
var table = new google.visualization.Table(document.getElementById('table_div'));
table.draw(data, {showRowNumber: true, allowHtml:true});
}
// end of table