/ / por que esse código gera um erro de sintaxe durante a renderização de dois gráficos do google diferentes - javascript, google-visualization

Por que esse código gera um erro de sintaxe durante a renderização de dois gráficos diferentes do Google - javascript, google-visualization

Alguém pode me ajudar a descobrir por que estou recebendo um erro de sintaxe quando eu ligar

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

na parte html.Eu poderia processar o primeiro gráfico mais cedo, mas esse erro surgiu quando eu adicionei outro gráfico do google para o script.I acho que eu poderia ter feito algum erro enquanto combina os dois.Pode alguém, por favor deixe-me saber o erro.

 <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>

Respostas:

0 para resposta № 1

Vi o JSON inválido:

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 mais inválido:

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

As barras invertidas precisam ser escapadas, tente o seguinte:

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

Também para corrigir o código

Dado por @ user3630022 - você tem 3 colunas no json, mas apenas 2 addColum