Jump to content
Salesforce and other SMB Solutions are coming soon. ×

Creating webpage using data:text in caclulation


flashkiwi

Recommended Posts

Hi Again,

 

I have progessed significantly since my last question.....

 

Now I am trying to use the Google Visualisation API to generate charts. It works fine hard coded (called from text file) but I for some reason the FM cacluator wont let me load it. It gives an error "The specificed table cant be found" and highlights "Javascript". I am assuming that FMPro thinks that it should be a table. I have have run similar code (HTML only - no JS) in the calculator with no problem. Anybody have any ideas?

 

Code below

 

Thanks in advance

 

Greg

 

 

"data:text/html," &

 

Let(

[guage_1 = Round(Nerang River::ECuSm_median; 1);

guage_2 = Round(Nerang River::DOpec_median; 1);

guage_3 = Round(Nerang River::Temp_median; 1)];

 

"

google.load("visualization", "1", {packages:["gauge"]});

google.setOnLoadCallback(drawChart);

function drawChart() {

var data = new google.visualization.DataTable();

data.addColumn('string', 'Label');

data.addColumn('number', 'Value');

data.addRows(3);

data.setValue(0, 0, 'CM');

data.setValue(0, 1, & (guage_1) &);

data.setValue(1, 0, 'DO');

data.setValue(1, 1, & (guage_2) &);

data.setValue(2, 0, 'Temp');

data.setValue(2, 1, & (guage_3) &);

var chart = new google.visualization.Gauge(document.getElementById('chart_div'));

var options = {width: 400, max: 120, height: 120, greenFrom: 20, greenTo: 70, redFrom: 90, redTo: 120, yellowFrom:70, yellowTo: 90, minorTicks: 10};

chart.draw(data, options); }

"

)

Link to comment
Share on other sites

Well, yeah...

 

"

"

 

etc

 

see the backslashes? Those are escapes in FileMaker.

 

(and if you ever need an actual backslash, you have to escape the backslash itself, too)

Link to comment
Share on other sites

Solved....sort off....! I appreciate everybodies help! I did crosspost on the FM TechTalk site as well. I can get it working on the PC no problem but not on the Mac

 

It now should be easy to dynamically create charts (if you are online of course) or implement any other Google API.

 

One thing that helped troubleshooting was looking at the ...temp.html FM creates after the calc - this made it easy to modify the calc.

 

Final code below (key is \ before " as pointed out above and the addition of the subsitute clause)

 

"data:text/html," &

 

Let(

[guage_1 = Round(Nerang River::ECuSm_median; 1);

guage_2 = Round(Nerang River::DOpec_median; 1);

guage_3 = Round(Nerang River::Temp_median; 1)];

 

substitute(

"

google.load(\"visualization\", \"1\", {packages:[\"gauge\"]});

google.setOnLoadCallback(drawChart);

function drawChart() {

var data = new google.visualization.DataTable();

data.addColumn('string', 'Label');

data.addColumn('number', 'Value');

data.addRows(3);

data.setValue(0, 0, 'CM');

data.setValue(0, 1, guage_1);

data.setValue(1, 0, 'DO');

data.setValue(1, 1, guage_2);

data.setValue(2, 0, 'Temp');

data.setValue(2, 1, guage_3);

var chart = new google.visualization.Gauge(document.getElementById

('chart_div'));

var options = {width: 400, max: 120, height: 120, greenFrom: 20, greenTo:70, redFrom: 90, redTo: 120, yellowFrom:70, yellowTo: 90, minorTicks: 10};

chart.draw(data, options); }

"

;

[ "guage_1"; guage_1];

[ "guage_2"; guage_2];

[ "guage_3"; guage_3]

))

Link to comment
Share on other sites



×
×
  • Create New...

Important Information

Terms of Use