4

I've got the extensions ExternalData and GoogleCharts installed.

Can External data (e.g., the result of a SQL query from a database) become the numbers for a chart (via any extension e.g. for GoogleCharts)?

Can you point to any page on a wiki that shows the syntax?

1

Yes. This worked on a local wiki (so no URL available, sorry).

First add to LocalSettings.php

$srfgFormats[] = 'googlepie';
$srfgFormats[] = 'googlebar';

In the wiki, create a property of type page called Id Field in List.

Then in the page where you want to show the data:

{{#get_db_data:
db=data
|from=MyTable as I 
|where=1 GROUP BY MyField
|limit=999
|order by=COUNT(*) DESC 
|data=Field=MyField,count=COUNT(*)
}}

Store the data

{{#store_external_table:Is Field in List |Has field={{{Field}}} |Has count={{{count}}}}}

Display the stored data excluding the first column as a table

{{#ask:[[Is Field in List::{{PAGENAME}}]]|?Has field=Field |?Has count=Count |format=table|mainlabel=-}}

Display the stored data excluding the first column as a googlebar

{{#ask:[[Is Field in List::{{PAGENAME}}]]|?Has field|?Has count|format=googlebar|mainlabel=-}}

Display the stored data excluding the first column as a googlepie

{{#ask:[[Is Field in List::{{PAGENAME}}]]|?Has field|?Has count|format=googlepie|mainlabel=-}}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.