13 | | The plugin is at its very infancy (May 2018) so only a fraction of plotly's functionality is supported, parameter syntax may change a bit and error checking is very likely to be improveable. |
| 17 | Enter the following in your wiki page: |
| 18 | |
| 19 | {{{ |
| 20 | [[yachart(id=first; title=Action statuses; query=SELECT status, COUNT(status) FROM ticket WHERE type = 'Action' GROUP BY status)]] |
| 21 | }}} |
| 22 | |
| 23 | This will result in something like this: |
| 24 | |
| 25 | [[Image(newplot(1).png, border=2)]] |
| 26 | |
| 27 | Note the use of semicolon as the delimiter character for the macro arguments. This is chosen to avoid ambiguous commas which are common in SQL queries. |
| 28 | |
| 29 | The query must return two columns. In `line` and `bar` charts, the first column will be used as x-axis data and the second column as y-axis data. In `pie` charts, the columns will be used as labels and values, respectively. |
| 30 | |
| 31 | In the query, the macro will replace the string `$USER` with the id of the user logged in. This can be used to display "my tickets": |
| 32 | |
| 33 | [[Image(newplot(2).png, border=2)]] |
| 34 | |
| 35 | WikiProcessor syntax is supported which may make queries easier to read and write: |
| 36 | {{{ |
| 37 | {{{#!yachart |
| 38 | id=something; |
| 39 | title=something else; |
| 40 | query=SELECT status, COUNT(status) |
| 41 | FROM ticket |
| 42 | WHERE type = 'Action' |
| 43 | GROUP BY status; |
| 44 | }}} |
| 45 | }}} |
| 46 | |
| 47 | === Parameters |
| 48 | |
| 49 | {{{#!ini |
| 50 | id = dom-name # The name of the HTML DOM carrying the chart. Mandatory. Must be unique for each macro call on a wiki page |
| 51 | title = title-text # The headline shown above the chart. Default: blank. |
| 52 | chart_type = bar|line|pie # Optional; default: bar |
| 53 | query = sql-query # Mandatory |
| 54 | width = pixel-width # Optional; default: 600 pixels |
| 55 | height = pixel-height # Optional: default: 400 pixels |
| 56 | }}} |
37 | | == Usage |
38 | | |
39 | | {{{ |
40 | | [[yachart(id=first; title=Action statuses; query=SELECT status, COUNT(status) FROM ticket WHERE type = 'Action' GROUP BY status)]] |
41 | | }}} |
42 | | |
43 | | ...will result in something like this: |
44 | | |
45 | | [[Image(newplot(1).png, width=300)]] |
46 | | |
47 | | === Parameters |
48 | | |
49 | | Note the unusual use of semicolon as delimiter character - this is chosen in order to avoid escaping commas in the SQL query |
50 | | |
51 | | {{{#!ini |
52 | | id = dom-name # The name of the HTML DOM carrying the chart. Mandatory. Must be unique for each macro call on a wiki page |
53 | | title = title-text # The headline shown above the chart. Default: blank. |
54 | | chart_type = bar|line|pie # Optional; default: bar |
55 | | query = sql-query # Mandatory |
56 | | width = pixel-width # Optional; default: 600 pixels |
57 | | height = pixel-height # Optional: default: 400 pixels |
58 | | }}} |
59 | | |
60 | | The query must return two columns. In `line` and `bar` charts, the first column will be used as x-axis data and the second column as y-axis data. In `pie` charts, the columns will be used as labels and values, respectively. |
61 | | |
62 | | In the query, the macro will replace the string `$USER` with the id of the user logged in. This can be used to display "my tickets": |
63 | | |
64 | | [[Image(newplot(2).png, width=300)]] |
65 | | |
66 | | WikiProcessor syntax is supported which may make queries easier to read (and write): |
67 | | {{{ |
68 | | {{{#!yachart |
69 | | id=something; |
70 | | title=something else; |
71 | | query=SELECT |
72 | | status, |
73 | | COUNT(status) |
74 | | FROM ticket |
75 | | WHERE type = 'Action' |
76 | | GROUP BY status; |
77 | | }}} |
78 | | }}} |
79 | | |