/ / чому цей код кидає синтаксичну помилку під час візуалізації двох різних графіків Google - javascript, google-visualization

чому цей код викидає синтаксичну помилку при виготовленні двох різних діаграм Google - javascript, google-візуалізації

Хто-небудь може допомогти мені зрозуміти, що, чому я отримую синтаксичну помилку, коли я дзвоню

        <div id="chart_div_org"></div>

в html частині.Я міг би зробити першу діаграму раніше, але ця помилка з'явилася, коли я додав іншу діаграму google до script.I думаю, я міг би зробити деякі помилки при поєднанні two.Can хтось, будь ласка, дайте мені знати помилку.

 <script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
// Load the Visualization API and the orgchart package.
google.load("visualization", "1.0", {packages:["corechart","orgchart"]});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);

// Callback that creates and populates a data table,
// instantiates the org chart, passes in the data and
// draws it.

function drawChart() {
var data1 = google.visualization.arrayToDataTable([
["PROGRAM", "SUCCESSFUL STEPS",{ role: "annotation" } ,"ERRORS",{ role:
"annotation" },"WARNINGS", { role: "annotation" } ],
["Curian",  10, "Completed ", 1,"Errors", 4, "Warnings"],
["Pershing",  11, "Completed ", 2, "Errors",   4, "Warnings"],
["DBTCA",  6, "Completed"  , 3, "Errors",  1, "Warnings"],
["DBTCA",  1, "Completed",  4, "Errors",  5,  "Warnings"]
]);

var options1 = {
title: "CHECKLIST STEPS EXECUTION PROGRESS",
hAxis: {title: "PROGRAM", titleTextStyle: {color: "red"}}
};

var chart1 = new
google.visualization.ColumnChart(document.getElementById("chart_div"));
chart1.draw(data1, options1);


var data2 = new google.visualization.DataTable();
data2.addColumn("string", "Name");
data2.addColumn("string", "Location");

data2.addRows([

[{v:"FTP LOG", f:"FTP LOG"<div style="color:red; font-style:italic">FTP
LOG</div>"}, "", "The type of log"],
["\inf-ftp01-priLog", "FTP LOG", ""],
["\inf-ftp02-priLog", "FTP LOG", ""],

]);
var chart2 = new
google.visualization.OrgChart(document.getElementById("chart_div_org"));
chart2.draw(data2, {allowHtml:true});
}
</script>

Відповіді:

0 для відповіді № 1

Я помітив невірний JSON:

data2.addRows([
[{v:"FTP LOG", f:"FTP LOG"<div style="color:red; font-style:italic">FTP LOG</div>"}, "", "The type of log"],
^--closing quote---------------one more closing quote --^

Більш недійсний JSON:

    ["\inf-ftp02-priLog", "FTP LOG", ""], <----- remove this comma..
]

Слід зняти скидання, спробуйте виконати такі дії:

["\\inf-ftp01-pri\Log\", "FTP LOG", ""],

Також виправити код

Дано @ user3630022 - у вас є 3 колонки в json, але тільки 2 addColum