0

次のコンテンツは、私の google.visualization.DataTable を壊します。これは Google カレンダーから取得しています。

// 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("&nbsp;&nbsp;"," ",$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
4

1 に答える 1