download-csv-js
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
download-csv-js [2022/05/10 11:57] – emozolyak | download-csv-js [2022/05/12 08:26] – [Button release script] emozolyak | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Example of graph data download with JS for dashbaord | + | ====== Example of graph data download with JS for dashboard |
The standard method of exporting data from graphs to XLS, HTML, CSV files has the resolution of the selected view on the respective graph, not all data - due to performance issues. | The standard method of exporting data from graphs to XLS, HTML, CSV files has the resolution of the selected view on the respective graph, not all data - due to performance issues. | ||
Line 8: | Line 8: | ||
===== Dashboard layout ===== | ===== Dashboard layout ===== | ||
There are 4 control elements on the dashboard you must provide: | There are 4 control elements on the dashboard you must provide: | ||
+ | {{ :: | ||
-Start time date picker | -Start time date picker | ||
-End time date picker | -End time date picker | ||
Line 13: | Line 14: | ||
-Dictionary element for selecting one of the many graphs you may have. E.g. if you have graphs with IDs of 1, 2, 3... you have to create a dictionary of 1, 2, 3.... and bind it with the register that will be used for the element on the dashboard. | -Dictionary element for selecting one of the many graphs you may have. E.g. if you have graphs with IDs of 1, 2, 3... you have to create a dictionary of 1, 2, 3.... and bind it with the register that will be used for the element on the dashboard. | ||
+ | ===== Script ===== | ||
+ | Put the following script into the ' | ||
+ | {{ : | ||
- | {{ :: | + | ==== Script text ==== |
<code javascript> | <code javascript> | ||
Line 141: | Line 144: | ||
} | } | ||
+ | </ | ||
+ | |||
+ | ==== Button release script ==== | ||
+ | |||
+ | Because the dashboard expects the register change be greater than 0, we have to reset this register after each use. | ||
+ | The following script can do that: | ||
+ | <code lua> | ||
+ | BUTTON_REG_ID = 9 | ||
+ | |||
+ | function main (userId) | ||
+ | | ||
+ | local cur_value = R(BUTTON_REG_ID) | ||
+ | | ||
+ | if (not resetDemand and cur_value > 0) then | ||
+ | resetDemand = true // postpone reset for one scan for JS to detect change | ||
+ | return | ||
+ | end | ||
+ | | ||
+ | if (resetDemand) then | ||
+ | reset(BUTTON_REG_ID) | ||
+ | resetDemand = false | ||
+ | end | ||
+ | | ||
+ | end | ||
+ | |||
+ | function reset(reg) | ||
+ | local cur_value = R(reg) | ||
+ | if cur_value and cur_value ~= 0 then | ||
+ | W(reg, 0) | ||
+ | end | ||
+ | end | ||
</ | </ | ||
download-csv-js.txt · Last modified: 2023/10/15 18:07 by emozolyak