SQLpage icon indicating copy to clipboard operation
SQLpage copied to clipboard

realtime chart from apex

Open vks2 opened this issue 1 year ago • 4 comments

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

vks2 avatar Jun 14 '24 02:06 vks2

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

lovasoa avatar Jun 14 '24 09:06 lovasoa

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.

vks2 avatar Jun 14 '24 09:06 vks2

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;

lovasoa avatar Jun 14 '24 18:06 lovasoa

it works, thank you

vks2 avatar Jun 17 '24 11:06 vks2