dev-master
9999999-dev https://github.com/okvpn/oro-graph-widgetBuild graph bases on database query
MIT
The Requires
- php >=7.0
- oro/platform ^2.3|^3.0
The Development Requires
by Tsykun Vladimir
orocrm oro platform graph widget
Build graph bases on database query
This OroPlatform bundle provider functionality to build line graph based on custom native sql query., (*1)
Install using composer following the official Composer [documentation][2]:, (*2)
composer require okvpn/graph-widget-bundle
# symfony 3 rm -r var/cache/* php bin/console oro:platform:update --force # symfony 2 rm -r app/cache/* php app/console oro:platform:update --force
Note: it's better to create a read-only database user. Dashboard widget use separate connection for database., (*3)
You can build line or multi-line plot. The data will be fetch from the columns: "x", "y", "line". Where: "x" - x-axis, "y" - y-axis and "line" - grouping column to build multi-line plot., (*7)
SELECT avg_status as y, created_at as x FROM okvpn_radar WHERE time > extract(epoch from now()) - 86400 ORDER BY id DESC LIMIT 1000;
Results of execute sql query, (*8)
x | y |
---|---|
0.005 | 2018-06-12 18:42:00 |
0.013 | 2018-06-12 18:27:00 |
0.030 | 2018-06-12 18:12:00 |
0.056 | 2018-06-12 17:57:00 |
0.081 | 2018-06-12 17:42:00 |
SELECT tmp.x, tmp.y, tmp.line FROM ( SELECT ROUND(AVG(avg_status), 3) AS y, created_at::date AS x, 'AVG' AS line FROM okvpn_radar WHERE created_at > now() - INTERVAL '50 day' AND type = 'UMMN' GROUP BY x UNION ALL ( SELECT ROUND(MAX(avg_status), 3) AS y, created_at::date AS x, 'MAX' AS line FROM okvpn_radar WHERE created_at > now() - INTERVAL '50 day' AND type = 'UMMN' GROUP BY x ) ) tmp ORDER BY tmp.x DESC;
Results of execute sql query, (*10)
x | y | line |
---|---|---|
2018-06-12 | 0.157 | AVG |
2018-06-12 | 0.484 | MAX |
2018-06-11 | 1.164 | MAX |
2018-06-11 | 0.478 | AVG |
2018-06-10 | 0.018 | MAX |
2018-06-10 | 0.004 | AVG |
You can disable update sql query using ACL permission okvpn_sql_query
., (*12)
MIT License. See LICENSE., (*14)
Build graph bases on database query
MIT
orocrm oro platform graph widget