We have tried to bind the google chart in IBM Domino Xpages application. But Unable to view the chart. Below is the code.
I taken on input field and in this field set the values and trying to take the values from javascript like document.getElementById("#{id:txtValues}").value. but didn't get the values.
Same details we can put on button click and prompt the alert values are coming properly. But in your script getting issues and values coming blank.
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="
http://www.ibm.com/xsp/core">
<script type="text/javascript" src="
https://www.gstatic.com/charts/loader.js"></script>
<xp:inputText id="txtValues">
<xp:this.defaultValue><![CDATA[#{javascript:"['Opportunity Details', 'Total Values'],['Work', 21],['Eat', 12],['Commute', 22],['Watch TV', 32],['Sleep', 57]"}]]></xp:this.defaultValue>
</xp:inputText>
<div id="piechart" style="width: 900px; height: 500px;"></div>
<script type='text/javascript' src='
https://www.google.com/jsapi'></script>
<script>
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
document.getElementById("#{id:txtValues}").value
]);
var options = {
title: 'Opportunity Details'
};
var chart = new google.visualization.PieChart(document.getElementById('piechart'));
chart.draw(data, options);
}
</script>
</xp:view>