1. tomms tomms
  2. PowerBuilder
  3. Wednesday, 27 May 2020 07:36 AM UTC
why this is js script does not work to appear Google Chart ? i use powerbuilder 2019 R2, i send the sample application

google.load("visualization", "1", {packages:["corechart"]});  google.setOnLoadCallback(function() {  drawChart();	} );
function drawChart() { var datosjson; var col = 'name'; var typecol = 'string'; var col1 = 'salesterritory_salesytd'; var typecol1 = 'number'; var col2 = 'salesterritory_saleslastyear'; var typecol2 = 'number'; var title = '';
$.getJSON("json1.json",function(data) { var datatable = new google.visualization.DataTable();
datatable.addColumn(typecol,col);
datatable.addColumn(typecol1,col1);
datatable.addColumn(typecol2,col2);
$.each(data, function(index,value){datatable.addRow([value.name,value.salesterritory_salesytd,value.salesterritory_saleslastyear]);
 }); var options = { "title": title, "width": 650, "backgroundColor": "#E4E4E42",  "is3D": true, "legend": {position: "left", textStyle: {fontSize: 10}, maxLines: 2}, "titleTextStyle": { fontSize: 35, bold: true, color:"blue"}, "height": 500};
 var chart = new google.visualization.PieChart(document.getElementById("chart_div"));
 chart.draw(datatable, options);  });}
Attachments (1)
References
  1. https://www.youtube.com/watch?v=CAra7K14Skg&list=PLvzlhZn-71T_8NgbvJVFlzO8SJbm65I0P&index=11&t=0s
Marco Meoni Accepted Answer Pending Moderation
  1. Thursday, 28 May 2020 07:00 AM UTC
  2. PowerBuilder
  3. # 1

Hello Tomms,

see my previous message, you must also include the Google Charts loader:

https://developers.google.com/chart/interactive/docs/basic_load_libs

Best,

.m

Comment
There are no comments made yet.
Marco Meoni Accepted Answer Pending Moderation
  1. Wednesday, 27 May 2020 11:35 AM UTC
  2. PowerBuilder
  3. # 2

Hi Tomms,
you are missing an important piece here.
The code you posted is only the Javascript, which I see it renders a Pie in the HTML tag "chart_div".
Now you need to prepare the HTML template, and in there make room for the chart_div DIV element.
For example:

<html><body>
<p class="title">My Pie</p>
<div id="chart_div" class="graphs"></div>
<footer><script type="text/javascript" src="/thejavascriptfile.js"></script></footer>
</body></html>

As you can see, in the HTML above you can specify your JS file and the template part. Please keep in mind that the JS is based on Google Charts, so you must also include the Chart loader JS, e.g.

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>

Once you have HTML + JS (+ CSS) you can use the new PB WebBrowser to load the .html and have the Pie displayed.

Best,

.m

Comment
  1. tomms tomms
  2. Thursday, 28 May 2020 00:41 AM UTC
i already put that script in HTML, but not working , the chart not appear , this is the sample html script i create :



<!DOCTYPE html>

<head>

























</head>



<center><div id="chart_div" ></div></center>



  1. Helpful
  1. tomms tomms
  2. Thursday, 28 May 2020 00:45 AM UTC
is my concern the JSON can do with that technique
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.