I'm creating my Google Apps Script(GAS) app with VSCode and clasp.
Now, "scriptlets" causes problems in my "index.html"(the picture below).
Does anyone know how to fix it?
I'm creating my Google Apps Script(GAS) app with VSCode and clasp.
Now, "scriptlets" causes problems in my "index.html"(the picture below).
Does anyone know how to fix it?
This is just my guess from your question. From new Chart
of your showing script in the image, if you are using Chart.js, under type: 'bar'
, the value of data.datasets
is required to be an array including the objects. If my understanding is correct, how about the following modification?
As sample data, if datasets
in Google Apps Script side is as follows,
const data = [
{ label: 'sample A', data: [1, 2, 3, 4, 5], backgroundColor: "rgba(255,0,0,1)" },
{ label: 'sample B', data: [5, 4, 3, 2, 1], backgroundColor: "rgba(0,255,0,1)" },
];
how about the following modification?
// Please replace your data.
const data = [
{ label: 'sample A', data: [1, 2, 3, 4, 5], backgroundColor: "rgba(255,0,0,1)" },
{ label: 'sample B', data: [5, 4, 3, 2, 1], backgroundColor: "rgba(0,255,0,1)" },
];
const htmlTemplate = HtmlService.createTemplateFromFile("index"); // Please replace your actual HTML filename.
htmlTemplate.datasets = JSON.stringify(data);
const htmlOutput = htmlTemplate.evaluate();
// Please use htmlOutput in your script.
datasets: [<?!= datasets ?>]
datasets: <?!= datasets ?>
If your datasets
is like '{"label":"sample A","data":[1,2,3,4,5],"backgroundColor":"rgba(255,0,0,1)"},{"label":"sample B","data":[5,4,3,2,1],"backgroundColor":"rgba(0,255,0,1)"}'
, I think that you can modify as follows. In this case, I think that you can use your current datasets: [<?!= datasets ?>]
.
const htmlTemplate = HtmlService.createTemplateFromFile("index"); // Please replace your actual HTML filename.
htmlTemplate.datasets = '{"label":"sample A","data":[1,2,3,4,5],"backgroundColor":"rgba(255,0,0,1)"},{"label":"sample B","data":[5,4,3,2,1],"backgroundColor":"rgba(0,255,0,1)"}'; // Please replace your data.
const htmlOutput = htmlTemplate.evaluate();
// Please use htmlOutput in your script.
datasets
and your whole script from your question. So, when my guess of your question was not correct, can you provide your whole script for correctly replicating your current issue? By this, I would like to confirm it.