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

Allow displaying plot axis via intl-formatted strings. #1613

Closed
Nayananga opened this issue Sep 5, 2022 · 9 comments
Closed

Allow displaying plot axis via intl-formatted strings. #1613

Nayananga opened this issue Sep 5, 2022 · 9 comments
Labels
feature Feature request plot Related to plotting

Comments

@Nayananga
Copy link
Contributor

Nayananga commented Sep 5, 2022

Wave SDK Version, OS

0.21.1, macOS 12.5.1

Actual behavior

A chart unable to show different times within a day

Screenshot 2022-09-05 at 18 24 51

Expected behavior

Users need to show data on different dates or different times within a day or both scenarios at the same time (23:55 today to 00:04 tomorrow)

Steps To Reproduce

Minimal code (inspired by this code here #1472 (comment))

from h2o_wave import main, app, Q, ui, data


@app('/')
async def serve(q: Q):
    q.page['ex1'] = ui.plot_card(
        box='1 1 4 3',
        title='Different Dates',
        data=data('low high price', 3, rows=[
            ("2022-01-01", "2022-02-01", 100),
            ("2022-02-01", "2022-03-01", 150),
            ("2022-03-01", "2022-03-31", 200),
        ]),
        plot=ui.plot([ui.mark(
            type='interval',
            y='=price', y_min=0,
            x1='=low', x2='=high', x_scale="time"
        )])
    )

    q.page['ex2'] = ui.plot_card(
        box='1 4 4 3',
        title='Same day Different times (24 hr clock)',
        data=data('low high price', 3, rows=[
            ("2022-02-01 00:00", "2022-02-01 00:05", 100),
            ("2022-02-01 00:05", "2022-02-01 11:59", 150),
            ("2022-02-01 11:59", "2022-02-01 23:59", 200),
        ]),
        plot=ui.plot([ui.mark(
            type='interval',
            y='=price', y_min=0,
            x1='=low', x2='=high', x_scale="time"
        )])
    )

    q.page['ex3'] = ui.plot_card(
        box='1 7 4 3',
        title='Same day Different times (12 hr clock)',
        data=data('low high price', 3, rows=[
            ("2022-02-01 00:00 AM", "2022-02-01 00:05 AM", 100),
            ("2022-02-01 00:05 AM", "2022-02-01 11:59 AM", 150),
            ("2022-02-01 11:59 AM", "2022-02-01 11:59 PM", 200),
        ]),
        plot=ui.plot([ui.mark(
            type='interval',
            y='=price', y_min=0,
            x1='=low', x2='=high', x_scale="time"
        )])
    )
    q.page['ex4'] = ui.plot_card(
        box='1 10 4 3',
        title='Two days Different times (12 hr clock)',
        data=data('low high price', 3, rows=[
            ("2022-02-01 06:00 PM", "2022-02-02 06:00 AM", 100),
            ("2022-02-02 06:00 AM", "2022-02-02 06:00 PM", 150),
            ("2022-02-02 06:00 PM", "2022-02-03 06:00 AM", 200),
        ]),
        plot=ui.plot([ui.mark(
            type='interval',
            y='=price', y_min=0,
            x1='=low', x2='=high', x_scale="time"
        )])
    )

    await q.page.save()
@Nayananga
Copy link
Contributor Author

cc @dulajra @shereezhang

@mturoci mturoci added the plot Related to plotting label Sep 8, 2022
@mturoci
Copy link
Collaborator

mturoci commented Sep 9, 2022

I would say not allowing both dates and times is by design. The reasoning is simple: Axis labels would take a lot of space, thus this could work only for a few data points. In general, it's better to have either only dates or only time axis.

@lo5 please correct me if I am wrong since you are the original author here.

@shihan007
Copy link

shihan007 commented Sep 12, 2022

@mturoci This is a must needed feature for monitoring. To be able view chart from different times and dates. Which we already have in grafana. Can we have this feature for charts?
cc: @lo5 @shereezhang @Nayananga

@shihan007
Copy link

Expected behaviour - if user select days, x axis will display days and if user select time like last 5 minutes or 12 hr x axis will display time
cc: @Nayananga @shereezhang

@Nayananga
Copy link
Contributor Author

I would say not allowing both dates and times is by design. The reasoning is simple: Axis labels would take a lot of space, thus this could work only for a few data points. In general, it's better to have either only dates or only time axis.

@lo5 please correct me if I am wrong since you are the original author here.

@mturoci x_scale="time" does not accept time-only values, but if we provide time as plain strings it will only plot those values as strings so we cannot present the time gaps properly, How would you suggest showing time values?

@mturoci
Copy link
Collaborator

mturoci commented Sep 12, 2022

if we provide time as plain strings it will only plot those values as strings so we cannot present the time gaps properly

can you elaborate?

Another option could be displaying time as "floats" (e.g. 10:30 => 10.30) and using x_scale='interval'.

@lo5 any ideas?

@Nayananga
Copy link
Contributor Author

Another option could be displaying time as "floats" (e.g. 10:30 => 10.30) and using x_scale='interval'.

CC: @ShehanIshanka

@shereezhang
Copy link

Some inspiration from Grafana:

  1. IF total time duration <= 5 min, display HH:MM:SS
  2. IF 5 min < total time duration <= 24 hours, display HH:MM
  3. IF 24 hours < total time duration <= 7 days, display Month/Day HH:MM
  4. IF 7 days < total time duration, display Month/Day

right now, we can do 1,2,4, but not 3 because it needs both the date and time.
@mturoci it would be nice to have both DATE & TIME possible as one label is a situation like below... eg. 4 day range - so if we only displayed dates, there would be duplicates for each date, but is there is only time, it's hard for the user to figure out which day each time is for in a 96 hr time range
image

@Nayananga ill create the ticket for this when we decide whether # 3 is possible!

@Nayananga
Copy link
Contributor Author

Some inspiration from Grafana:

  1. IF total time duration <= 5 min, display HH:MM:SS
  2. IF 5 min < total time duration <= 24 hours, display HH:MM
  3. IF 24 hours < total time duration <= 7 days, display Month/Day HH:MM
  4. IF 7 days < total time duration, display Month/Day

right now, we can do 1,2,4, but not 3 because it needs both the date and time. @mturoci it would be nice to have both DATE & TIME possible as one label is a situation like below... eg. 4 day range - so if we only displayed dates, there would be duplicates for each date, but is there is only time, it's hard for the user to figure out which day each time is for in a 96 hr time range image

@Nayananga ill create the ticket for this when we decide whether # 3 is possible!

Thank you for the detailed explanation @shereezhang, Let me add a little bit more context to the issue,

@mturoci This is bit tricky to explain, let me attach two examples,

This is when I provide time as a string (even with dates)
Screenshot 2022-09-13 at 22 40 04

This is when I provide time with x_scale="time"
Screenshot 2022-09-13 at 22 40 15

As you can see, the second image gives more insights about the distribution with regards to time but the first image just plots data points evenly spaced, So when I want to show only time, x_scale="time" does not work, so I can't set that property. Then I have to provide time as a string value (something like "23:59") Then WAVE just plots those data points as it is without knowing the importance of time property, So I end up with a plot like in image 1. Hope I made it clear, If not let's just stick with @shereezhang 's comment

@mturoci mturoci added feature Feature request and removed bug Bug in code labels Sep 19, 2022
@mturoci mturoci changed the title Wave plots unable to show 2 points within the same day on x axis Allow displaying plot axis via intl-formatted strings. Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature request plot Related to plotting
Projects
None yet
Development

No branches or pull requests

4 participants