influxdata / influxdata/ui

stepAfter/stepBefore Interpolation incorrectly represents linear growth

Open
#6,827 0 comments 0 reactions 0 assignees View on GitHub
kind/bug team/ui
Dominant language
TypeScript
Stars
117
Forks
51
Avg merge
2d 15h
Merged PRs (30d)
4

Description

## About the bug

When selecting `stepBefore` or `stepAfter` as the interpolation type, line charts can sometimes fail to track growth in a series that is growing (almost) linearly.

For example, here's the smooth interpolation of the repro data (provided below)

![image](https://github.com/influxdata/ui/assets/88340935/fce09341-45a3-48b4-8672-ffb18cc5c570)

If we switch the interpolation to `stepAfter`, we can see that the line is quite some way from the points (and rises at a much slower rate)

![image](https://github.com/influxdata/ui/assets/88340935/c3132c35-59ff-4aa6-9dea-0a49d318c487)

**Steps to reproduce:**
List the minimal actions needed to reproduce the behavior.

1. Create a bucket in Serverless with infinite retention
2. Load the repro LP in - [data.lp.txt](https://github.com/influxdata/ui/files/13189459/data.lp.txt)
3. Go to data explorer
4. Choose your bucket
5. Run the following query
```
SELECT val, time
from test_measure
WHERE time >= timestamp '2023-10-27T00:00:00Z' and time < timestamp '2023-10-27T23:59:48Z'
```
6. Hit customize and switch `Interpolation` to `stepAfter`

Note: the same behaviour can be achieved in TSM (though it obviously requires a Flux query).

There's nothing particularly special about the data used for the repro - it was generated specifically to try and repro a report of this issue:
```python
#!/usr/bin/env python3
#
#
import random

start_date = 1698361200
end_date = 1698447540
max_val = 220

def gen_lp(ts, val):
print(f"test_measure val={val} {ts}000000000")

# Initialise
ts = start_date
val = 20

while ts < end_date:
gen_lp(ts, val)

# Now increase the value and timestamp by a random amount
val += random.uniform(0, 2)
ts += random.randint(1,5)
```

## About your environment

**Environment info:**

Cloud 2 + Serverless

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in the data explorer by loading the repro from data.lp.txt, running the provided query, and switching Interpolation to stepAfter; also check stepBefore. Trace the chart interpolation entry point from there. Done means stepAfter and stepBefore represent the growth of the plotted points without the observed lag, while existing interpolation behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
data-visualization, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.