lovasoa / SQLpage

SQL-only webapp builder, empowering data analysts to build websites and applications quickly
https://sql.ophir.dev
MIT License
880 stars 62 forks source link

realtime chart from apex #404

Open vks2 opened 2 weeks ago

vks2 commented 2 weeks ago

Hi! Any chance to implement this? https://apexcharts.com/javascript-chart-demos/line-charts/realtime/ thanks much

lovasoa commented 2 weeks ago

Hi ! Yes, that would be possible! Can you tell us more about your use case ?

vks2 commented 2 weeks ago

thnx for your short reply. i want to pick a Remote Content Demo and adopt it to make it constatnly fetching new data without re-rendering the whole page. i played with shell refresh in 3 sec, but it refreshes everything despite of embed param (as described here https://github.com/lovasoa/SQLpage/pull/175). and here you said that we may use LISTEN/NOTIFY in similar scenario. https://github.com/lovasoa/SQLpage/discussions/312 having a very major postgresql background it seems very interesting to me, but we do not have enough human resources to dig in js-rendering issues (and i haven't found any working code about it). finally i found that pattern, that uses an infinite loop https://github.com/lovasoa/SQLpage/blob/v0.22.0/examples/corporate-conundrum/wait.sql but it's too time consuming to adopt my scenario. Anyways i need to silently refresh page when new data is fetched (ideally every 30 secs) and i have a full control of backend postgres (it's a major datawarehouse). the final aim is to show to costumer that we are a dataprovider with fresh accurate and modern data securely working with our endpoints api. PS we also may use js.fetch data from our remote endpoint too.

lovasoa commented 2 weeks ago

I get what you want ! Let's keep this issue open until it's implemented.

In the meantime, you can use the card component with 'iframe' as embed_mode, and set use the shell refresh in the embedded page:

https://replit.com/@pimaj62145/SQLPage-live-refresh#index.sql

SELECT 'card' AS component, 1 as columns;

select 'plot.sql' as embed, 'iframe' as embed_mode, 'height: 400px' as style;

and in plot.sql

select 'shell' as component, 1 as refresh;

select 'chart' as component, 'y = f(x)' as title;
select x, y from fakedata;
vks2 commented 2 weeks ago

it works, thank you