Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stepped Line Chart for Time Series? #9737

Closed
hc128168 opened this issue May 5, 2020 · 5 comments
Closed

Stepped Line Chart for Time Series? #9737

hc128168 opened this issue May 5, 2020 · 5 comments
Labels
enhancement:request Enhancement request submitted by anyone from the community inactive Inactive for >= 30 days

Comments

@hc128168
Copy link

hc128168 commented May 5, 2020

Hi,

I wonder whether Superset offers a stepped line chart (I have been googled for quite some times but couldn't find any).

It is like something like this.

Useful cases:

  • Showing the bid and the ask price of stock price over time in 1 single chart.
  • Showing multiple time series in one chart.

Currently, I have a database schema like this:
symbol varhcar(16);
is_bid boolean;
price double;
time timestamp(6);

And then I use "time series - line chart" as the visualization type, "sum(price)" as metrics, and group by "symbol" and "is_bid".

Then the chart will have many broken lines because not every timestamp for each set of symbol and is_bid exists for another set of symbol and is_bid. Concrete example:
DB row 1: symbol = AAPL, time = 9:00:00AM, is_bid = TRUE, price = 140.00
DB row 2: symbol = AAPL, time = 9:00:01AM, is_bid = FALSE, price = 140.05
DB row 3: symbol = AAPL, time = 9:00:03AM, is_bid = TRUE, price = 140.01
DB row 4: symbol = AAPL, time = 9:00:05AM, is_bid = FALSE, price = 140.06

Then the line for AAPL's bid price will be broken between 9:00:00 and 9:00:03 because there is no entry in the DB for time = 9:00:01AM.

One solution is to have a script to get all the unique timestamps, and then populate additional rows per symbol per is_bid based on the previous value of the corresponding set of symbol and is_bid (as "step before interpolation" makes sense in this case), creating a giant table and additional work for all stepped line charts.

Hence, it would be great that superset supports (or already supported) step line chart.

Thanks.

@hc128168 hc128168 added the enhancement:request Enhancement request submitted by anyone from the community label May 5, 2020
@eugeniamz
Copy link

I think that you can do it with advance analytics, using the Panda.resample.
The way that would work is

1- you create one chart with the real values as you did.
2- then duplicate that chart and use the advance analytics, panda.resample, rule should be 1D, the method , bfill or ffill or even max of the day.
3- Merge the 2 charts in a new chart. I did a video to explain that to someone else
https://www.youtube.com/watch?v=GwnkbhAMQTk&t=24s

If you share a sample dataset, I can try to resolve it and send you the specific details.

@hc128168
Copy link
Author

hc128168 commented May 5, 2020

Thanks for sharing the tip Eugenia!

I briefly watched your video, and I think the use case is slightly difference. Your case is to have two different charts showing on the same chart. Both charts use the same set of data but one has a transformation.

My case is a bit different that I have multiple lines group by symbol (and is_bid...but we can drop this field to simplify), and I just want to transform all lines with forward fill (ffill).

My timestamps have millisecond precision and so the rule should be 1ms?

I just tried to set rule = 1s and fill method = ffill, and re-ran the query. It makes no difference to my chart.

Thanks!

@eugeniamz
Copy link

can you share some dataset ? or maybe we can get into zoom session and explore, my email is eugenia@preset.io

@stale
Copy link

stale bot commented Jul 4, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.

@stale stale bot added the inactive Inactive for >= 30 days label Jul 4, 2020
@stale stale bot closed this as completed Jul 11, 2020
@pjpringle
Copy link

Looks like a useful feature to support stock price data. Any plans for interpolated step charts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement:request Enhancement request submitted by anyone from the community inactive Inactive for >= 30 days
Projects
None yet
Development

No branches or pull requests

3 participants