okvpn / graph-widget-bundle
Build graph bases on database query
Installs: 403
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=7.0
- oro/platform: ^2.3|^3.0
Requires (Dev)
- phpunit/phpunit: ^5.7
This package is auto-updated.
Last update: 2024-11-29 05:32:52 UTC
README
This OroPlatform bundle provider functionality to build line graph based on custom native sql query.
Install
Install using composer following the official Composer documentation:
- Install via composer:
composer require okvpn/graph-widget-bundle
- Run oro platform update
# 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
Configure
- Create database integration.
Note: it's better to create a read-only database user. Dashboard widget use separate connection for database.
- Add widget to dashboard.
- Update widget configuration
SQL Format
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.
Example of line plot.
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
Example of multi-line plot.
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
Permissions
You can disable update sql query using ACL permission okvpn_sql_query
.
License
MIT License. See LICENSE.