Extension:Semantic Result Formats/googlebar and googlepie formats

From MediaWiki.org

Jump to: navigation, search

The result formats googlebar and googlepie, both part of the Semantic Result Formats extension, create a bar chart and a pie chart, respectively, based on property values, using the Google Charts API.

Contents

[edit] Examples

googlebar:

  {{#ask:
    [[Category:City]] [[located in::Germany]]
    |?population
    |format=googlebar
  }}

googlepie:

  {{#ask:
    [[Category:City]] [[located in::Germany]]
    |?population
    |format=googlebar
  }}

See the North America page on semanticweb.org for a live example.

[edit] Privacy notice

You must not forget that every time a user comes to a page with a Google chart, Google gets a ping. And you also send all your data to Google in order to render it. Don't forget also that these printers do not work offline, if you have a local wiki.

[edit] Usage

You use the same queries as usual, but make sure to add a printout statement with a property that is of type Number. All printouts of properties of type number will be taken for the visualization. The only further parameters (for now) are height and width (if not given, mostly sensible values are assumed).

You may want a pie chart to not show property values directly, but rather the popularity of different values of a property across the entire wiki; i.e. a numerical distribution. This is fairly easy to do; see here for how.

[edit] Future work

It would be good to allow users to choose colours and to add more info, and to use more of the chart types that Google offers. It would be even cooler if someone could find an open-source library that can create these charts itself, so that the data does not have to be sent to Google, and so that we can expand it more easily. If you want to take over development here, feel free to do so! Just send an email to the smw-devel list before you do so.