Re: Pgadmin4 System Stats Extension Design

From: Sahil Harpal <sahilharpal1234(at)gmail(dot)com>
To: Aditya Toshniwal <aditya(dot)toshniwal(at)enterprisedb(dot)com>
Cc: Khushboo Vashi <khushboo(dot)vashi(at)enterprisedb(dot)com>, pgadmin-hackers(at)postgresql(dot)org, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Dave Page <dpage(at)pgadmin(dot)org>, Akshay Joshi <akshay(dot)joshi(at)enterprisedb(dot)com>
Subject: Re: Pgadmin4 System Stats Extension Design
Date: 2023-08-07 11:17:27
Message-ID: CAKi=nncRPLHwHZ+53vFuF7sB87tTLYXEbD4FPVnAbt8qhLonug@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers

Hi Aditya,
On Mon, 7 Aug 2023 at 11:01, Aditya Toshniwal <
aditya(dot)toshniwal(at)enterprisedb(dot)com> wrote:

> Hi Sahil,
> I would suggest changing the behaviour in StreamingChart so that it can be
> used at other places. If you want to reverse it then you can still do it. I
> had achieved reverse direction with the following piece of code. Basically,
> creating an array of 75 points, filling it with available points and
> reverse. You can change it based on reverse=true flag. In your case,
> simply reverse, not need of 75 points.
> Array.from(new Array(xRange).keys()),
> ...(data.datasets?.map((d)=>{
> let ret = [...d.data];
> ret.reverse();
> return ret;
> })??{}),
>

I'm a little confused here. So, the code snippet above is exactly what's
used to initialize the data currently.

The expected behavior is that the graph should start from the right side
only. However, currently, when the page loads, for a few seconds, the
graphs are visible on the left side and then shift to the right.

I think we can skip the reverse if we make changes in the statsReducer
method.
action.counter ? action.incoming[label] - action.counterData[label] :
action.incoming[label],
...state[label].slice(0, X_AXIS_LENGTH-1),

Here, we are adding new data to the beginning and selecting the first
X_AXIS_LENGTH-1 datapoints from the previous state. However, an alternative
approach would be to initially take the X_AXIS_LENGTH-1 elements from the
end of the array, then add a new element to the end. This would eliminate
the need to reverse the array.

I believe this reversal isn't causing any issues, but something might be
occurring during graph plotting. Reversing just ensures that the most
recent data point remains on the right within the stream.

Thank you,
Sahil

In response to

Responses

Browse pgadmin-hackers by date

  From Date Subject
Next Message Aditya Toshniwal 2023-08-07 11:41:50 Re: Pgadmin4 System Stats Extension Design
Previous Message Pravesh Sharma 2023-08-07 05:50:19 [pgadmin-org/pgadmin4] 27c7ea: Added all like options while creating a table. #6377