Avaiga / taipy

Turns Data and AI algorithms into production-ready web applications in no time.
https://www.taipy.io
Apache License 2.0
15.18k stars 1.84k forks source link

BUG- Horizontal and vertical zoom do not reapply decimation #712

Closed FlorianJacta closed 7 months ago

FlorianJacta commented 1 year ago

Description The chart does not reapply decimation or have issue zooming in the chart. It is not possible to zoom in one way, and the other zoom will not repopulate the chart.

How to reproduce

from taipy.gui import Gui
from math import cos, exp
from taipy.gui.data.decimator import MinMaxDecimator

def compute_data(nb_points)->list:
    return {"x":range(nb_points), "y":[cos(i/6) * exp(-i*decay/nb_points) for i in range(nb_points)]}

decay = 0
nb_points = 10_000
decimator_instance = MinMaxDecimator(n_out=1_000, zoom=True)

data = compute_data(nb_points)

page = """
# Taipy *Demo*

The nb_points is: <|{nb_points}|>.

<|{nb_points}|selector|lov={[10_000, 20_000, 50_000, 100_000, 200_000, 500_000, 1_000_000]}|dropdown|on_change=change|>

<|{data}|chart|x=x|y=y|decimator=decimator_instance|>
"""

def change(state):
    state.data = compute_data(state.nb_points)

Gui(page).run(port=5020, use_reloader=True)

image

It is not possible to zoom in one way and the other will not repopulate the chart.

This is the expected result:

image

Expected behavior The chart should be repopulated when the user zoom vertically or horizontally on the chart.

Runtime environment Taipy GUI: develop for 3.1

FlorianJacta commented 1 year ago

In 2.3.1, it now has a bizarre behavior where the zoom doesn't correspond to what should be zoomed.

dinhlongviolin1 commented 1 year ago

With my testing on the develop branch, it is working as expected. You can re-open it if the issue still occurs.

FlorianJacta commented 9 months ago

The zoom with Decimator is still not working in the develop branch for 3.1. @dinhlongviolin1

dinhlongviolin1 commented 8 months ago

I will have a look at it again. I will let you know how that goes

dinhlongviolin1 commented 8 months ago

Hi FJ. I just debugged with the team and everything is working as it should. This might be the case of usage of the algorithm. you can try to use the threshold parameter with then MinMaxDecimator instance decimator_instance = MinMaxDecimator(n_out=1_000, zoom=True, threshold=5_000). In this case, the decimator function will only be applied if the data point of the zoom area is above 5000, giving you a realistic view of the area.

FlorianJacta commented 8 months ago

It is not working as expected.

In 3.1, after my horizontal and vertical zoom, the points are not repopulated as it should be.

Try this code:


import yfinance as yf
from taipy.gui import Gui
from taipy.gui.data.decimator import MinMaxDecimator, RDP, LTTB

df_AAPL = yf.Ticker("AAPL").history(interval="1d", period = "100Y")
df_AAPL["DATE"] = df_AAPL.index.astype('int64').astype(float)

n_out = 500
decimator_instance = MinMaxDecimator(n_out=n_out)

decimate_data_count = len(df_AAPL)

page = """
# Decimator

From a data length of <|{len(df_AAPL)}|> to <|{n_out}|>

## With decimator

<|{df_AAPL}|chart|x=DATE|y=Open|decimator=decimator_instance|>
"""

gui = Gui(page)
gui.run(port=5026, title="Decimator")

Try to zoom here: image

This is what you get:

image

Which is not correct, it should be the second image below. You can obtain this by not horizontally or vertically zooming in the chart but by zooming when the zoom is a box like this:

image

The correct zoom where points are repopulated:

image

It hope it is cleared here.

dinhlongviolin1 commented 7 months ago

Hi FJ, I did check with the yfinance demo on taipy 3.1. It works very well on my machine and the points are updated accordingly to your last image on that zoom area.

FredLL-Avaiga commented 7 months ago

works for me too in 3.2

dinhlongviolin1 commented 7 months ago

you mean 3.1 right @FredLL-Avaiga :D

FredLL-Avaiga commented 7 months ago

you mean 3.1 right @FredLL-Avaiga :D

no :-) I tested with the develop branch

dinhlongviolin1 commented 7 months ago

This issue has been fixed. One caveat/feature that I have discussed with @FlorianJacta is zooming only vertically on line charts will give you the same result as not zooming vertically. This is due to the fact that line charts behaves different from scatter charts for example and the order of the points are very important. You might misrepresent a line if you remove a point entirely without context.