Template:Graph

From 2009.igem.org

(Difference between revisions)
(Some more explanation on how to use graphs.)
m (Just test3)
Line 8: Line 8:
#:<pre>
#:<pre>
#:{
#:{
-
#:datasource: '/*data source url*/'
+
#:datasource: '/*data source url*/',
-
#:width: /*width, including a unit, e.g. 8cm*/,
+
#:width: '/*width, including a unit, e.g. 8cm*/',
-
#:height: /*height, including a unit, e.g. 8cm*/,
+
#:height: '/*height, including a unit, e.g. 5cm*/',
#:series: [
#:series: [
#:  /* comma-separated list of data series to display, e.g. for just one data series: */
#:  /* comma-separated list of data series to display, e.g. for just one data series: */
Line 19: Line 19:
#:}
#:}
#:</pre>
#:</pre>
-
# Use <pre>{{graph|/*Wiki graph page name*/}}</pre> to use the graph in any Wiki page.
+
# Use <pre>{{graph|/*Wiki graph page name*/}}</pre> to use the graph in any Wiki page (note that any Wiki page using a graph must also use <pre>{{GraphHeader}}</pre> once).
As an example [{{fullurl:Team:Groningen/Graphs/Test}}?action=edit Team:Groningen/Graphs/Test] can be rendered using:
As an example [{{fullurl:Team:Groningen/Graphs/Test}}?action=edit Team:Groningen/Graphs/Test] can be rendered using:
Line 27: Line 27:
Which looks like this:
Which looks like this:
-
{{graph|Team:Groningen/Graphs/Test}}
+
<!--{{graph|Team:Groningen/Graphs/Test}}-->
-
Please note that any page using this template should also include [[Template:GraphHeader]] (once), this need not be at the beginning of the document.
+
{{graph|Team:Groningen/Graphs/Test3}}
 +
 
 +
'''Please note''' that any page using this template should also include [[Template:GraphHeader]] (once), this need not be at the beginning of the document.
{{GraphHeader}}</noinclude>
{{GraphHeader}}</noinclude>

Revision as of 16:47, 24 June 2009

This template lets any user of the Wiki include a graph in a Wiki page much like he/she can include an image. The graph is defined using [http://www.json.org/ JSON] that describes the graph directly using the properties supported by the [http://docs.dojocampus.org/dojox/charting charting library] in the [http://www.dojotoolkit.org/ Dojo Toolkit]. It also includes a datasource that should point to a (publicly accessible) [http://docs.google.com/ Google Docs] spreadsheet.

Steps to get a graph onto the Wiki:

  1. Go to [http://docs.google.com/ Google Docs] and create a spreadsheet, which you fill with data to put in the graph (the data series should be organized in columns).
  2. Publish the spreadsheet by clicking on Share in the top-right corner (while the spreadsheet is still open) and then "Publish as a webpage". In this dialog, make sure you check "Automatically republish when changes are made" if you want the graphs to always use the latest data and then click "Start publishing". Now copy the URL in the text box in the lower half of the screen (without the "&output=html" bit), this is the data source!
  3. Create a Wiki page with the following text (replacing all the bits between '/*' and '*/' with whatever is appropriate in your case:
    {
    datasource: '/*data source url*/',
    width: '/*width, including a unit, e.g. 8cm*/',
    height: '/*height, including a unit, e.g. 5cm*/',
    series: [
    /* comma-separated list of data series to display, e.g. for just one data series: */
    {x: /*x column*/, y: /*y column*/ }
    ],
    {{defaultAxes|xtitle=/*time (s)*/|ytitle=/*concentration (µM)*/}},
    {{defaultPlot}}
    }
  4. Use
    {{graph|/*Wiki graph page name*/}}
    to use the graph in any Wiki page (note that any Wiki page using a graph must also use
    {{GraphHeader}}
    once).

As an example [http://2009.igem.org/Team:Groningen/Graphs/Test?action=edit Team:Groningen/Graphs/Test] can be rendered using:

{{graph|Team:Groningen/Graphs/Test}}

Which looks like this:


Loading graph...

Please note that any page using this template should also include Template:GraphHeader (once), this need not be at the beginning of the document.