Re: Pgadmin4 System Stats Extension Design - Mailing list pgadmin-hackers

From Sahil Harpal
Subject Re: Pgadmin4 System Stats Extension Design
Date
Msg-id CAKi=nncRPLHwHZ+53vFuF7sB87tTLYXEbD4FPVnAbt8qhLonug@mail.gmail.com
Whole thread Raw
In response to Re: Pgadmin4 System Stats Extension Design  (Aditya Toshniwal <aditya.toshniwal@enterprisedb.com>)
Responses Re: Pgadmin4 System Stats Extension Design
List pgadmin-hackers
Hi Aditya,
On Mon, 7 Aug 2023 at 11:01, Aditya Toshniwal <aditya.toshniwal@enterprisedb.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

pgadmin-hackers by date:

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