On Mon, Aug 7, 2023 at 4:47 PM Sahil Harpal <sahilharpal1...@gmail.com> wrote:
> Hi Aditya, > On Mon, 7 Aug 2023 at 11:01, Aditya Toshniwal < > aditya.toshni...@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. > OK I thought you wanted the graph to go from left to right. Yeah, I have seen that glitch a few times (but rare). I think you can ignore it for now, we can look into it once we get time. It is not a priority. The reason data reversing and stuff is maintained in StreaminChart is - Pass the data points and StreamingChart will appear from right to left. Don't want the source to take efforts to reverse and fill. > > Thank you, > Sahil > > -- Thanks, Aditya Toshniwal pgAdmin Hacker | Sr. Software Architect | *enterprisedb.com* <https://www.enterprisedb.com/> "Don't Complain about Heat, Plant a TREE"