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

Closes #387: Only truncate 'category' type labels. #390

Merged
merged 1 commit into from
May 2, 2018
Merged

Conversation

emtwo
Copy link

@emtwo emtwo commented Apr 30, 2018

This is a follow-up from #374 which unfortunately caused #387

I'm learning that using Plotly correctly is in fact wizardry.

It turns out that ticktext overrides any nice x-axis formatting that Plotly does by default such as avoiding overlapping labels. So this patch removes the use of ticktext.

Furthermore, stringifying and/or truncating axis types such as datetime also affects the pretty Plotly formatting. Since the string truncation issue originally reported in #359 was only for the category type, I think it's safe/best to limit to that in this patch.

The test cases in #378 should apply to this patch. Additionally, here is a test case that triggers #387. It did not work with the datetime axis type and also had overlapping x-axis values when using category. Both of these should now be resolved.

WITH sample as (
    select '2017-10-01 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-10-02 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-10-03 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-10-04 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-10-05 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-10-06 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-10-07 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-10-08 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-10-09 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-10-10 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-10-11 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-10-12 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-10-13 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-10-14 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-10-15 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-10-16 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-10-17 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-10-18 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-10-19 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-10-20 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-10-21 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-10-22 00:00' as x, 'US' as type, 8215767 as foo union
    select '2017-10-23 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-10-24 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-10-25 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-10-26 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-10-27 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-10-28 00:00' as x, 'US' as type, 8215767 as foo union
    select '2017-10-29 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-10-30 00:00' as x, 'US' as type, 8215767 as foo union
    select '2017-10-31 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-11-01 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-11-02 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-11-03 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-11-04 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-11-05 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-11-06 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-11-07 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-11-08 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-11-09 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-11-10 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-11-11 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-11-12 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-11-13 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-11-14 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-11-15 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-11-16 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-11-17 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-11-18 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-11-19 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-11-20 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-11-21 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-11-22 00:00' as x, 'US' as type, 8215767 as foo union
    select '2017-11-23 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-11-24 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-11-25 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-11-26 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-11-27 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-11-28 00:00' as x, 'US' as type, 8215767 as foo union
    select '2017-11-29 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-11-30 00:00' as x, 'US' as type, 8215767 as foo union
    select '2017-12-01 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-02 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-03 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-04 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-05 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-06 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-07 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-08 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-09 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-10 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-11 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-12 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-13 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-14 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-15 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-16 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-17 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-18 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-19 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-20 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-21 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-22 00:00' as x, 'US' as type, 8215767 as foo union
    select '2017-12-23 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-24 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-25 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-26 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-27 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-28 00:00' as x, 'US' as type, 8215767 as foo union
    select '2017-12-29 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-30 00:00' as x, 'US' as type, 8215767 as foo union
    select '2017-12-31 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-32 00:00' as x, 'US' as type, 8215767 as foo union
    select '2017-12-33 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-34 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-35 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-36 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-37 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-38 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-39 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-40 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-41 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-42 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-43 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-44 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-45 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-46 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-47 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-48 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-49 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-50 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-51 00:00' as x, 'US' as type, 574047 as foo union
    select '2017-12-52 00:00' as x, 'ROW' as type, 8215767 as foo)
select * from sample

@jezdez jezdez self-requested a review May 2, 2018 14:35
@jezdez jezdez self-assigned this May 2, 2018
@jezdez
Copy link

jezdez commented May 2, 2018

@emtwo I don't know how to create a graph with what options to reproduce the bug with your test data, do you mind sharing how you set it up locally?

@emtwo
Copy link
Author

emtwo commented May 2, 2018

Sure.

Overlapping labels bug:

  1. Create and execute a new query with the text listed above
  2. Create a new visualization where the x-axis is the x column and the y-axis is the foo column
  3. Go to the X Axis tab and ensure that Scale is set to Category
  4. Note the overlapping x-axis labels.

Date formatting bug:

  1. Repeat steps 1-2 above
  2. Go to the X Axis tab and ensure that Scale is set to Datetime
  3. Note that this does not convert the x-axis labels into pretty datetime formatting as it should.

@jezdez
Copy link

jezdez commented May 2, 2018

For the record, theses are the graphs how they look like in both of the cases @emtwo mentioned in the previous comment:

screen-shot-2018-05-02-20-58-37

screen-shot-2018-05-02-20-58-53

And here with the patch applied:

screen-shot-2018-05-02-22-14-24

screen-shot-2018-05-02-20-59-19

Copy link

@jezdez jezdez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, was able to reproduce and it fixed those two cases of misbehaving labels.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants