Avaiga / taipy-doc

Holds the documentation set for Taipy, not including the code documentation obviously.
https://docs.taipy.io/
Apache License 2.0
17 stars 24 forks source link

[🐛 BUG] decimator does not work outside of the documented example #1174

Open AlexandreSajus opened 1 month ago

AlexandreSajus commented 1 month ago

What went wrong? 🤔

The decimator does work fine with the documented code sample:

image

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

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

NOP = 10
decimator_instance = LTTB(n_out=NOP)

with tgb.Page() as page:
    tgb.chart("{df_AAPL}", x="DATE", y="Open", decimator="decimator_instance")

Gui(page).run(title="Decimator")

But it does not work with a simple DataFrame. In the following example, the data is not being decimated. The only thing I changed is that I converted df_AAPL to a simple dataframe:

image

from taipy.gui import Gui
import taipy.gui.builder as tgb
from taipy.gui.data.decimator import MinMaxDecimator, RDP, LTTB

import pandas as pd
import numpy as np

df_AAPL = pd.DataFrame(
    {
        "DATE": pd.date_range("2021-01-01", periods=1000, freq="D"),
        "Open": np.random.rand(1000),
    }
)
df_AAPL["DATE"] = df_AAPL.index.astype("int64").astype(float)

NOP = 10
decimator_instance = LTTB(n_out=NOP)

with tgb.Page() as page:
    tgb.chart("{df_AAPL}", x="DATE", y="Open", decimator="decimator_instance")

Gui(page).run(title="Decimator")

Expected Behavior

The decimator should work when inputting a dataframe. If it fails, it should warn the user as to why

Runtime Environment

Windows 11

Browsers

Chrome

OS

Windows

Version of Taipy

4.0.0.dev2

Acceptance Criteria

Code of Conduct

dinhlongviolin1 commented 1 month ago

This is a problem with the decimator config. If the view port can still contain the data (width of the chart), the decimator will not be applied by default. Either change the threshold decimator_instance = LTTB(n_out=NOP, threshold=500) or increase the number of points to a larger number like 2000 or 5000.

AlexandreSajus commented 1 month ago

I'm sorry. I think we need to keep this ticket open until we make a change in the product or the docs. The decimator is not usable in its current state because of this issue. A user came to me explaining that he could not figure out how to use it.