plugin:tablecalc
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
plugin:tablecalc [2018-04-11 10:41] – [ChangeLog] stalker | plugin:tablecalc [2024-01-21 20:13] (current) – [III] fix typo Aleksandr | ||
---|---|---|---|
Line 6: | Line 6: | ||
email : stalker@narezka.org | email : stalker@narezka.org | ||
type : syntax | type : syntax | ||
- | lastupdate : 2017-02-09 | + | lastupdate : 2020-08-27 |
- | compatible : Lemming, Anteater, Rincewind, Hrun, Detritus, Elenor of Tsort, Frusterick Manners | + | compatible : Lemming, Anteater, Rincewind, Hrun, Detritus, Elenor of Tsort, Frusterick Manners, Greebo, Hogfather, Igor, Jack Jackrum |
depends | depends | ||
conflicts | conflicts | ||
Line 14: | Line 14: | ||
downloadurl: | downloadurl: | ||
+ | bugtracker : | ||
+ | sourcerepo : | ||
+ | donationurl: | ||
+ | |||
+ | screenshot_img: | ||
---- | ---- | ||
===== Overview ===== | ===== Overview ===== | ||
- | Sometimes one may need to do simple calculations in DokuWiki table. The idea was taken from [[plugin:tablemath]] plugin, but conception changed a little bit. With the help of this plugin you would be able to insert Excel styles formulas into the table | + | |
+ | Sometimes one may need to do simple calculations in DokuWiki table. The idea was taken from [[plugin:Tablemath]] Plugin, but conception changed a little bit. With the help of this plugin you would be able to insert | ||
===== Download and Installation ===== | ===== Download and Installation ===== | ||
- | Download | + | Search |
* [[http:// | * [[http:// | ||
- | |||
===== Syntax ===== | ===== Syntax ===== | ||
- | To perform a calculation you need to insert XL-style formula into work sheet. Any expression must be started with '' | + | To perform a calculation you need to insert XL-style formula into work sheet. Any expression must be started with '' |
< | < | ||
r0c4 | r0c4 | ||
</ | </ | ||
- | Please note, that row ('' | + | |
+ | :!: Please note, that row ('' | ||
+ | |||
+ | ^ | ||
+ | ^ 0 | r0c0 | r0c1 | r0c2 | | ||
+ | ^ 1 | r1c0 | r1c1 | r1c2 | | ||
+ | ^ 2 | r2c0 | r2c1 | r2c2 | | ||
+ | |||
+ | Row and column prefixes can be swapped. The following is equal of the above: | ||
< | < | ||
c4r0 | c4r0 | ||
Line 65: | Line 78: | ||
The following functions are implemented: | The following functions are implemented: | ||
- | '' | + | ^ Func ^ Description |
- | + | | average(range) | |
- | ^ Func | + | | cell(column,row) | Returns |
- | | cell(x, | + | | check(condition,true,false) | Executes '' |
- | | row() | Returns current row | | + | | col() | Returns current column |
- | | col() | Returns current column | + | | compare(a,b,operation) |
- | | range(x1, | + | | count(range) |
- | | sum(range) | + | | countif(range,b,operation) |
- | | count(range) | + | | label(string) | Binds label to the table | |
- | | round(number; | + | | max(range) |
- | | label(string) | + | | min(range) |
- | | average(range) | + | | range(column1, |
- | | min(range) | + | | round(number, |
- | | max(range) | Returns minimum value within specified range | | + | | row() | Returns current row | |
- | | check(condition;true;false) | + | | sum(range) |
- | | compare(a;b;operation) | + | | calc() |
- | | countif(range;b;operation) | + | |
- | | calc() | + | |
Though you can use colon as delimiter in functions semi-colon is preferred and recommended. | Though you can use colon as delimiter in functions semi-colon is preferred and recommended. | ||
- | |||
===== Operators ===== | ===== Operators ===== | ||
Line 92: | Line 102: | ||
^ Operator | ^ Operator | ||
- | | + | Addition and unary plus | | + | | + | Addition and unary plus | |
- | | - | Subtraction and unary negative | | + | | - | Subtraction and unary negative |
- | | * | Multiplication | | + | | * | Multiplication |
- | | / | Division | | + | | %%**%% |
- | | % | Modulus (division remainder) | | + | | / | Division |
- | | & | Logical AND | | + | | % | Modulus (division remainder) |
- | | %%<< | + | | & | Logical AND | |
- | | %%>> | + | | %%<< |
+ | | %%>> | ||
+ | |||
+ | ===== Examples ===== | ||
- | =====Examples===== | ||
==== I ==== | ==== I ==== | ||
Line 110: | Line 122: | ||
| 1 | 2 | 3 | 11.7 | | | 1 | 2 | 3 | 11.7 | | ||
+ | |||
==== II ==== | ==== II ==== | ||
+ | |||
< | < | ||
| 1 | 2 | | | 1 | 2 | | ||
Line 121: | Line 135: | ||
| 3 | 4 | | | 3 | 4 | | ||
| 10 || | | 10 || | ||
- | |||
==== III ==== | ==== III ==== | ||
+ | |||
< | < | ||
| 1 | 2 | 3 | 4 | | | 1 | 2 | 3 | 4 | | ||
| 5 | 6 | 7 | 8 | | | 5 | 6 | 7 | 8 | | ||
- | | **~~=sum(r0c0: | + | | **~~=sum(r0c0: |
</ | </ | ||
Line 137: | Line 151: | ||
==== IV ==== | ==== IV ==== | ||
+ | |||
< | < | ||
|1| | |1| | ||
Line 169: | Line 184: | ||
==== V ==== | ==== V ==== | ||
+ | |||
< | < | ||
|1| | |1| | ||
Line 195: | Line 211: | ||
|11| | |11| | ||
|5.5| | |5.5| | ||
+ | |||
==== VI ==== | ==== VI ==== | ||
+ | |||
< | < | ||
| ~~=label(ex6_1)~~1 | 2 | | | ~~=label(ex6_1)~~1 | 2 | | ||
Line 209: | Line 227: | ||
Sum: **10** | Sum: **10** | ||
+ | |||
==== VII ==== | ==== VII ==== | ||
+ | |||
< | < | ||
| **~~=label(ex7_1)~~11** | ~~=sum(ex7_2.c0r0: | | **~~=label(ex7_1)~~11** | ~~=sum(ex7_2.c0r0: | ||
Line 229: | Line 249: | ||
Sum: **48** | Sum: **48** | ||
+ | |||
==== VIII ==== | ==== VIII ==== | ||
+ | |||
< | < | ||
| **~~=min(c0r1: | | **~~=min(c0r1: | ||
Line 245: | Line 267: | ||
==== IX ==== | ==== IX ==== | ||
+ | |||
< | < | ||
| 1 | ~~=check(cell(0, | | 1 | ~~=check(cell(0, | ||
Line 253: | Line 276: | ||
</ | </ | ||
- | | 1 | True | | + | | 1 | True |
- | | 0 | False | | + | | 0 | False | |
- | | x | False | | + | | x | False | |
- | | | False | | + | | | False | |
- | | | False | | + | | | False | |
==== X ==== | ==== X ==== | ||
+ | |||
< | < | ||
| 1 | 2 | 1=2 | ~~=check(compare(cell(0, | | 1 | 2 | 1=2 | ~~=check(compare(cell(0, | ||
Line 280: | Line 304: | ||
| 11 | 11 | 11≤11 | True | | | 11 | 11 | 11≤11 | True | | ||
| 12 | 12 | 12≠12 | False | | | 12 | 12 | 12≠12 | False | | ||
+ | |||
==== XI ==== | ==== XI ==== | ||
- | ^ Operator | + | ^ Operator |
- | | + | %%~~= 3 + 2 ~~%% | 5 | | + | | + | %%~~= 3 + 2 ~~%% |
- | | - | %%~~= 3 - 2 ~~%% | 1 | | + | | - | %%~~= 3 - 2 ~~%% |
- | | * | %%~~= 3 * 2 ~~%% | 6 | | + | | * | %%~~= 3 * 2 ~~%% |
- | | / | %%~~= 6 / 2 ~~%% | 3 | | + | | %%**%% |
- | | % | %%~~= 7 % 2 ~~%% | 1 | | + | | / | %%~~= 6 / 2 ~~%% |
- | | unary + | %%~~= +2 ~~%% | + | | % | %%~~= 7 % 2 ~~%% |
- | | unary - | %%~~= -2 ~~%% | + | | unary + | %%~~= +2 ~~%% | 2 | |
- | | & | %%~~= 3 & 2 ~~%% | 2 | | + | | unary - | %%~~= -2 ~~%% | -2 | |
- | | %%<< | + | | & | %%~~= 3 & 2 ~~%% |
- | | %%>> | + | | %%<< |
+ | | %%>> | ||
==== XII ==== | ==== XII ==== | ||
Line 300: | Line 327: | ||
|~~=r0c1+5~~|6| | |~~=r0c1+5~~|6| | ||
</ | </ | ||
+ | |||
| 11 | 6 | | | 11 | 6 | | ||
+ | |||
==== XIII ==== | ==== XIII ==== | ||
+ | |||
< | < | ||
| ~~=label(ex13_1)~~apples | 32 | | | ~~=label(ex13_1)~~apples | 32 | | ||
Line 318: | Line 348: | ||
Apples: 2 | Apples: 2 | ||
+ | |||
+ | |||
===== ChangeLog ===== | ===== ChangeLog ===== | ||
- | __11.04.2017__ | ||
- | | + | __26.08.2020__ |
- | * Added plugin.info.txt | + | * Fixed Hogfather compatibility issues |
- | * Fixed cross references between tables | + | |
+ | |||
+ | __11.04.2018__ | ||
+ | |||
+ | | ||
+ | * Added plugin.info.txt | ||
+ | * Fixed cross references between tables | ||
__05.07.2017__ | __05.07.2017__ | ||
Line 331: | Line 368: | ||
__09.02.2017__ | __09.02.2017__ | ||
- | | + | |
__31.01.2017__ | __31.01.2017__ | ||
- | | + | |
- | * Plugin execution code was significantly revisioned and corrected | + | * Plugin execution code was significantly revisioned and corrected |
__14.04.2010__ | __14.04.2010__ | ||
- | | + | |
- | * Added cross-table resolver and forward calculations | + | * Added cross-table resolver and forward calculations |
- | * Added min(),max() and average() functions | + | * Added min(),max() and average() functions |
- | * Added ability to use semi-colon as a function parameters separator | + | * Added ability to use semi-colon as a function parameters separator |
- | * Added compare functions | + | * Added compare functions |
- | * Added string escaping (#) | + | * Added string escaping (#) |
- | * Fixed javascript/ | + | * Fixed javascript/ |
- | * Fixed invalid HTML ID's usage | + | * Fixed invalid HTML ID's usage |
__07.09.2009__ | __07.09.2009__ | ||
- | | + | |
===== Discussion ===== | ===== Discussion ===== | ||
Line 470: | Line 507: | ||
--- [[fidokomik@gmail.com|fidokomik]] // | --- [[fidokomik@gmail.com|fidokomik]] // | ||
==== Bug report ==== | ==== Bug report ==== | ||
- | === Plugin creates no output === | + | |
+ | === + Doesn' | ||
+ | When using + to reference a cell the + doesn' | ||
+ | < | ||
+ | ~~=cell(col(), | ||
+ | </ | ||
+ | Will give nothing back, but using a - will work | ||
+ | < | ||
+ | ~~=cell(col(), | ||
+ | </ | ||
+ | |||
+ | --- [[user> | ||
+ | |||
+ | == Plugin creates no output === | ||
None of the formulas outputs results for me (on Anteater). Any known conflicts with other plug-ins? | None of the formulas outputs results for me (on Anteater). Any known conflicts with other plug-ins? | ||
--- [[user> | --- [[user> | ||
Line 576: | Line 626: | ||
--- // | --- // | ||
+ | >> Above was fixed, but similar bug now appears in Chrome etc. browsers, but not Firefox etc. browsers. | ||
+ | --- [[user> | ||
+ | ==== Looping ==== | ||
+ | Unfortunately the new version loops on my page, which is more complex than the example I give above. | ||
+ | |||
+ | ==== Decimals ==== | ||
+ | |||
+ | > | ||
+ | > | ||
+ | >Also, what about delimiters in general? Large numbers like 1000000 are easily readable as 1.000.000, | ||
+ | --- [[user> | ||
+ | |||
+ | > The following code in your [[devel: | ||
+ | > | ||
+ | > <code php> | ||
+ | setTimeout(function() { | ||
+ | | ||
+ | var $calc_decimal = jQuery(this).text().split(' | ||
+ | jQuery(this).text($calc_decimal); | ||
+ | }); | ||
+ | }, 100); | ||
+ | } </ | ||
+ | > | ||
+ | > ・ at least ONE cell of ANY table on the page needs to be set up with tablecalc syntax: ~~= ... ~~ | ||
+ | > ・ then ALL dots in ALL tables on the page are converted to commas on pageload (only for visual display) | ||
+ | > ・ in page edit mode (or edittable) decimal delimiters are still to be filled in as dots " | ||
+ | > --- [[user> | ||
+ | |||
+ | ==== Incompatibility with Chrome and Brave? ==== | ||
+ | |||
+ | I have been using TableCalc for months now and haven' | ||
+ | |||
+ | https:// | ||
+ | http:// | ||
+ | --- [[user> | ||
+ | |||
+ | > There appears to be a javascript problem in Chrome/ | ||
+ | > | ||
+ | > See an example at https:// | ||
+ | > | ||
+ | > This is the Tablecalc issue that I run into most frequently; I suspect the above is similarly related to the way that Chrome etc. handle the javascript created by Tablecalc pages. | ||
+ | > --- [[user> | ||
+ | |||
+ | > | ||
+ | >PHP can only show you results on the page when Javascript is ready with calculation. Since this is a javascript plugin, some timeout has to be adjusted. The more math work is given to tablecalc, the more timeout it needs to complete the task before the page can be loaded by PHP using those results. Look for this line of code in **/ | ||
+ | > | ||
+ | > <code php> | ||
+ | >Save your file, close and restart your browser and navigate back to the wiki page. Now, it will work in Edge, Chrome, Firefox and IE11. (Tested with DokuWiki-on-a-stick, | ||
+ | > | ||
+ | >EDIT: At least part of the above problem seems to be related to using non-existing cells which was discouraged here before. (Probably, because it gives tablecalc just too much mathwork it cannot handle.) I found the following useful for autosum of all of the cells above the current cell (assuming you have exactly one header row): | ||
+ | >< | ||
+ | >--- [[user> | ||
+ | |||
+ | ==== Feature requests ==== | ||
+ | |||
+ | > | ||
+ | > | ||
+ | > | ||
+ | >--- [[user> |
plugin/tablecalc.1523436081.txt.gz · Last modified: 2018-04-11 10:41 by stalker