I thought I'd try using JavaScript's template strings to produce some 
charts, but cannot make them work. The idea was to pass a variable into the 
visualization chart code. The code I used was:

function newCharts(){
chartType=`BarChart`;
var chartStr = 
`google.visualization.${chartType}(document.getElementById('awstats-graph'))`;
console.log(chartStr);
newChart = new chartStr;
newChart.draw(drawData); 
}

The console output looks OK and gives:

google.visualization.BarChart(document.getElementById('awstats-graph'))

But then I get the error:

Uncaught Error: Error handling Query strict JSON response: TypeError: 
chartStr is not a constructor

Does this mean there's something wrong with the code or that I cannot use 
this method?

I got what I wanted to do by using the drawchart method - 
https://developers.google.com/chart/interactive/docs/reference#drawchart

but am curious about the template strings.

The working code can be see at https://brisray.com/utils/awslogs/

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-visualization-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-visualization-api/d421ba86-9892-4c83-a635-dce9f99a47e3n%40googlegroups.com.

Reply via email to