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 the X and Y tick format to be customized #6370

Merged
merged 1 commit into from
Aug 16, 2023

Conversation

eradman
Copy link
Collaborator

@eradman eradman commented Aug 15, 2023

Allow the format of each axis to be customzied using a D3 format string

Numbers: https://d3-wiki.readthedocs.io/zh_CN/master/Formatting/
Date/Time: https://d3-wiki.readthedocs.io/zh_CN/master/Time-Formatting/

What type of PR is this?

  • Feature

Description

The database will save these in visualizations.options

    "xAxis": {
        "type": "-",
        "labels": {
            "enabled": true
        },
        "tickFormat": "%B %d"
    },
    "yAxis": [
        {
            "type": "linear",
            "tickFormat": "s"
        },
        {
            "type": "linear",
            "opposite": true,
            "tickFormat": ""
        }
    ],

Specifying a D3 format

How is this tested?

  • Unit tests (pytest, jest)
  • E2E Tests (Cypress)
  • Manually

Related Tickets & Documents

#3215

Separate documentation needs to be added since there is no numbro/moment.js equivalent translation to D3 syntax.
Plotly does not allow a custom function to be defined for axis formatting.

Mobile & Desktop Screenshots/Recordings (if there are UI changes)

Old Behavior

tick_format_x_orig

New Axis Formatting using

Y: s
X: %B %d

tick_format_x_new

Dockerfile Outdated Show resolved Hide resolved
@justinclift
Copy link
Member

@gabrieldutra Do you have time & interest to look over this PR? 😄

@codecov
Copy link

codecov bot commented Aug 15, 2023

Codecov Report

Merging #6370 (f4648e4) into master (f8934b8) will increase coverage by 0.00%.
Report is 1 commits behind head on master.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #6370   +/-   ##
=======================================
  Coverage   60.78%   60.78%           
=======================================
  Files         153      153           
  Lines       12527    12529    +2     
  Branches     1701     1701           
=======================================
+ Hits         7614     7616    +2     
  Misses       4687     4687           
  Partials      226      226           

see 1 file with indirect coverage changes

@eradman
Copy link
Collaborator Author

eradman commented Aug 15, 2023

CC @litao3rd

@gaecoli
Copy link
Member

gaecoli commented Aug 16, 2023

Looks good!

@gaecoli
Copy link
Member

gaecoli commented Aug 16, 2023

You can even preset some parameters as an example, but it's great if you don't support it.

Like this:
image

eradman added a commit to eradman/redash-website that referenced this pull request Aug 16, 2023
eradman added a commit to eradman/redash-website that referenced this pull request Aug 16, 2023
@eradman
Copy link
Collaborator Author

eradman commented Aug 16, 2023

You can even preset some parameters as an example, but it's great if you don't support it.

I'm not going to add that to this change, but this is a good idea to keep in mind as an incremental improvement.

@justinclift
Copy link
Member

Cool. Seems like everything with this PR is happy. Is it ready to merge now, or are you still tweaking it a bit? 😄

@eradman
Copy link
Collaborator Author

eradman commented Aug 16, 2023

This is ready to go. Merging

@eradman eradman merged commit 0f88a23 into getredash:master Aug 16, 2023
12 checks passed
@eradman eradman deleted the tick-format branch August 16, 2023 16:11
justinclift pushed a commit to getredash/website that referenced this pull request Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants