Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qSyFC-007xhq-5R for pgadmin-hackers@arkaria.postgresql.org; Mon, 07 Aug 2023 11:17:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qSyFA-008zcV-Nr for pgadmin-hackers@arkaria.postgresql.org; Mon, 07 Aug 2023 11:17:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qSyFA-008zcN-FQ for pgadmin-hackers@lists.postgresql.org; Mon, 07 Aug 2023 11:17:48 +0000 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qSyF4-00159h-3x for pgadmin-hackers@postgresql.org; Mon, 07 Aug 2023 11:17:48 +0000 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-55ba895d457so2511291a12.0 for ; Mon, 07 Aug 2023 04:17:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691407060; x=1692011860; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=EfUTq9BOA96+gAJt8oZZeTt8Qg/WBP8YEhdNa0VdpQw=; b=UtRZ69St5NrIc9zotudiXTxYMVXKbeJ4/Y6jxYspx3At4xL8C88uyj5a6uiLg91Mld YLmKwmvountinogOdzvRKD/7GTQ6wIMyFtAJfhLdwVpGsTGh7macqwmPyFM4TVtJsHdL zyCGKYoZ6IKNqU2p1SK3HNYAWwK9TL3zDF+pPlxDiAkdrhR3/x3SHfJDqc6rXO6zeLN/ +8+mj4FKEymAd54e7wnatCqrXY1OlSIYklzKp3Z89mDE4y2zbN2s4Ir7zd+bVqF/1OAO N349n8TOUtvp4MplzH2LtOttJISOBFzHbWJlcFidZQ5V8sj4JbhhEgM+seW6MXTOSPqR gyKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691407060; x=1692011860; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EfUTq9BOA96+gAJt8oZZeTt8Qg/WBP8YEhdNa0VdpQw=; b=gbFCEoynkkBbQAQKqtMJZb6oAwHIslcTE+HfBev7f1cqIIlYu2uETsWMOznTe9VCp8 Zaf9ZdufpR0XOrsxAxp4ZawUi/0CTIew9X+LYqpj6UBQidFwQoynC12xIt9xrNhrSBKV cyJUf4j+rRS2xqmiNRte8x+gAnbF1qctCZZy64GnTIJv+tFGHixT+h1r6xhdnkQLwjrd QTap0FHF5jwhXH6DihrHsUTIK7kqFDcYNrbdy3g7+jk7CGj94+XWV+2UGrKJwrNRH02I X0HbDuEb5OcEtpiFuspKvuW3hrIZpzu2dzpQbegKbXtjYhA+jNJH1GsSh869O6DuJ1Jd z63Q== X-Gm-Message-State: AOJu0YxDJO8PSVVo0GIBq0/360PPbFQJBaapH37bMqqDDy3YoYjt5fa1 EO3CbDHHx3e8r1BFqSeQh78sTYdOeND90Yx/0Vo= X-Google-Smtp-Source: AGHT+IFfECRF+fbdlg43EQV9MHN08foM8s2IOuYa240StUTnTqCZpWZEdhyYfLoNH6VZ+M5pMGuFLAqT74DqFmSFCNg= X-Received: by 2002:a17:90b:349:b0:267:f329:947d with SMTP id fh9-20020a17090b034900b00267f329947dmr6118949pjb.33.1691407059777; Mon, 07 Aug 2023 04:17:39 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Sahil Harpal Date: Mon, 7 Aug 2023 16:47:27 +0530 Message-ID: Subject: Re: Pgadmin4 System Stats Extension Design To: Aditya Toshniwal Cc: Khushboo Vashi , pgadmin-hackers@postgresql.org, Ashesh Vashi , Dave Page , Akshay Joshi Content-Type: multipart/alternative; boundary="000000000000f7fdc30602536410" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000f7fdc30602536410 Content-Type: text/plain; charset="UTF-8" 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 --000000000000f7fdc30602536410 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Aditya,
On Mon, = 7 Aug 2023 at 11:01, Aditya Toshniwal <aditya.toshniwal@enterprisedb.com> wrote:
3D""
Hi=C2=A0Sahil,
I would suggest changing the behaviour in StreamingCh= art 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 pi= ece of code. Basically, creating an array of 75 points, filling it with ava= ilable points and reverse. You can change it based on=C2=A0reverse=3Dtrue<= /span>=C2=A0flag. In your case, = simply reverse, not need of 75 points.
Arra= y.from(new Array(xRange).keys(= )),
...(data.datasets?.map((d)=3D>{
let ret =3D [...d.data];
ret.reverse();
= return ret;
= })??{}),
=C2=A0
I'm a little confused here. So, the code snippet above is exactl= y what's used to initialize the data currently.

The expected beh= avior is that the graph should start from the right side only. However, cur= rently, when the page loads, for a few seconds, the graphs are visible on t= he left side and then shift to the right.

I think we can skip the re= verse if we make changes in the statsReducer method.
action.counter ? =C2=A0action= .incoming[label] - action.counterData[label] : action.incoming[l= abel],
=C2=A0 =C2=A0 =C2=A0 =C2=A0 ...state[label].slice(0, X_AXIS_LENGTH-1),

Here, we are adding new da= ta 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 ne= w element to the end. This would eliminate the need to reverse the array.
I believe this reversal isn't causing any issues, but something m= ight be occurring during graph plotting. Reversing just ensures that the mo= st recent data point remains on the right within the stream.
=
Thank you,
Sahil

--000000000000f7fdc30602536410--