Compatible with DokuWiki
The tableplot plugin uses jqPlot to plot data from a table.
Tableplot is a modification of the graphTable JQuery plugin by Rebecca Murphey. That plugin uses the Flot plotting software. I switched the plotting software to use jqPlot and integrated it with dokuwiki.
This plugin requires the following additional components that must be installed separately:
Notes:
The tableplot plugin requires the following minimum syntax.
<tableplot></tableplot>
{{keywords>table2plot}}
A simple example is provided with the tableplot code. In the example folder is the file exampleEarthquakePlot.txt. It can be included on your dokuwiki page to plot Earthquake data.
In addition you can see the plugin in action here: Glocal Focal Wiki page NJ health or Glocal Focal Wiki page US nature. The latter makes use of the jqplot ability to remove graph elements by clicking on the legend.
Both pages in the online example above use a forked version of the sql plugin to create tables for use by tableplot. However, tableplot does not require sql to be used. Using the sql plugin allows you to get data from a mysql database rather than having to enter it manually. The forked version of the sql plugin is available on GitHub at forked version of sql plugin. In the new sql plugin use the table id parameter which can then be used by tableplot.
The MySql for All tip has some support software that would allow a user to easily generate his mysql query. That query can be used in the updated sql plugin to create a table with an associated table id. The table id can be provided to the tableplot plugin for generating a graph. The tips support software when configured for your database removes the need for the wiki user to know the structure or have direct visibility into your database.
Basic syntax:
<tableplot></tableplot>
{{keywords>table2plot}}
TablePlot accepts two types of parameters. One type are used to setup the call to jqPlot and the other type are jqPlot parameters. The jqPlot parameters are contained in the parameter called plotargs. These are simply passed on to jqPlot. Documentation of the jqPlot parameters can be found at jqPlot API Documentation. This link provides the detailed syntax. Do not be discouraged by the number of parameters. Defaults work for most and many options are provided. The examples at jqPlot examples and provided in this package are a good place to start.
Note: If specifying jqPlot Renderer functions in the jqPlot paramters be aware that there could be a conflict when specified as $.jqplot.function. If errors occur specify the function as jQuery.jqplot.function.
The following table shows the parameters that can be added to the <tableplot>...</tableplot> plugin to allow users to configure their plot.
| Parameter | Value | Meaning | Default |
|---|---|---|---|
| orient | vertical,horizontal | plot orientation | vertical |
| series | columns,rows | data orientation in table | columns |
| firstSeries | number | index of the row/column containing the first series | 1 |
| lastSeries | number | index of the row/column containing the last series | last cell in the row/col |
| labels | integer | index of cell in series row/column that contains the label for the series | 0 |
| xaxis | integer | index of row/column (whatever args.series is) that contains the x values | 0 |
| dataStart | integer | index of first cell in the series containing data | 1 |
| dataEnd | integer | index of last cell in the series containing data | last cell in the row/col |
| position | before, after, replace | graph go before the table, after the table, or replace the table | after |
| width | numeric | plot width in pixels | width of the table |
| height | numeric | plot height in pixels | height of the table |
| placement | text | id to place plot at | null |
| dataTransform | text | function to run on cell contents before passing to jqPlot | null |
| labelTransform | text | function to run on cell contents before passing to jqPlot | null |
| xaxisTransform | text | function to run on cell contents before passing to jqPlot | null |
| plotArgs | {text} | arguments for jqPlot | null |
| id | text | Table Id | table1 |
All parameters must be preceded and succeeded with an ampersand symbol (&). The format of a parameter is ¶meter=value&. The & would not be repeated when specifying more than one parameter. An example would be
<tableplot>
&series=rows&firstSeries=1&height=400&width=400&id=yeardata&position=after&dataTransform=function(s) { return(Math.round(s));}
&plotArgs={title: {text: 'New Jersey Cancer Mortality Rate', fontSize: '14pt', textColor: 'skyblue'}}&
</tableplot>
})(jQuery);
var match = jQuery.noData[ elem.nodeName.toLowerCase()]; change to var match = jQuery.noData[ elem.nodeName.toString().toLowerCase() ];
.
Hi, great plugin, just something I need. I've installed it for me. Unfortunately, I beomme no graphics when I try the test page. When I look at me the HTML code of the test page, I have a feeling that everything is rendered correctly. Have you an idea of what that might be. Unfortunately I get no error message. I use the default template. TCI 16.12.2011
Hi, thanks for the feedback. If you see the table but no graph, my first guess is that it has to do with a conflict of specifying the jqplot functions with the $ like $.jqplot.CategoryAxisRenderer. Change all the $.jqplot instances in the plugin text to jQuery.jqplot (eg: jQuery.jqplot.CategoryAxisRenderer). There should be 3 of them. I will update the example to do this. Your new plugin text should be
<tableplot>&series=columns&width=400&height=400&id=Earthquakes&plotArgs={title: {text: 'Number of Earthquakes Worldwide', fontSize: '14pt', textColor: 'skyblue'}, axes: {xaxis: {renderer: jQuery.jqplot.CategoryAxisRenderer, tickRenderer: jQuery.jqplot.CanvasAxisTickRenderer ,tickOptions: {angle: -30}}}, seriesDefaults: {renderer:jQuery.jqplot.BarRenderer }}&
</tableplot>
Hi sorry that I have signed up as long as no more, but I was busy in another project. But now I have found the error. I had to change in the “action.php” file the following line, now the script works.
'src' => $basePath ."dokuwiki/lib/plugins/tableplot/table2Plot.js"); -> 'src' => $basePath ."lib/plugins/tableplot/table2Plot.js");