-
-
Notifications
You must be signed in to change notification settings - Fork 111
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
Set OHLC x-axis tooltip to datetime format #1493
Open
Azaya89
wants to merge
5
commits into
holoviz:main
Choose a base branch
from
Azaya89:OHLC-1487
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c1cded3
added bokeh datetime formatting for x-axis tooltip
Azaya89 48d3ff4
added tests
Azaya89 fc10a83
added check for datetime x-axis
Azaya89 46e53d0
added tests for non-datetime x-axis
Azaya89 6102f5f
modify type checking to use pandas
Azaya89 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -32,3 +32,39 @@ def test_ohlc_hover_cols_all(): | |||||
tooltips = segments.opts.get('plot').kwargs['tools'][0].tooltips | ||||||
assert len(tooltips) == len(df.columns) + 1 | ||||||
assert tooltips[-1] == ('Volume', '@Volume') | ||||||
|
||||||
|
||||||
def test_ohlc_date_tooltip_format(): | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another test could be added with a DataFrame whose date column isn't the index. |
||||||
plot = df.hvplot.ohlc(y=ohlc_cols) | ||||||
segments = plot.Segments.I | ||||||
hover_tool = segments.opts.get('plot').kwargs['tools'][0] | ||||||
tooltips = hover_tool.tooltips | ||||||
x_label, x_tooltip = tooltips[0] | ||||||
assert '{%F}' in x_tooltip | ||||||
formatter_key = '@' + x_label | ||||||
formatter = hover_tool.formatters | ||||||
assert formatter.get(formatter_key) == 'datetime' | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
|
||||||
def test_ohlc_non_datetime_x_axis(): | ||||||
df = pd.DataFrame( | ||||||
{ | ||||||
'Open': [100.00, 101.25, 102.75], | ||||||
'High': [104.10, 105.50, 110.00], | ||||||
'Low': [94.00, 97.10, 99.20], | ||||||
'Close': [101.15, 99.70, 109.50], | ||||||
'Volume': [10012, 5000, 18000], | ||||||
}, | ||||||
index=[1, 2, 3], | ||||||
) | ||||||
|
||||||
ohlc_cols = ['Open', 'High', 'Low', 'Close'] | ||||||
|
||||||
plot = df.hvplot.ohlc(y=ohlc_cols) | ||||||
segments = plot.Segments.I | ||||||
hover_tool = segments.opts.get('plot').kwargs['tools'][0] | ||||||
tooltips = hover_tool.tooltips | ||||||
x_label, x_tooltip = tooltips[0] | ||||||
assert '{%F}' not in x_tooltip | ||||||
formatter_key = '@' + x_label | ||||||
assert formatter_key not in hover_tool.formatters |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two comments on
%F
:DateFormatter
.%F
is a strftime format code Equivalent to %Y-%m-%d (the ISO 8601 date format). Could you add a little comment like%F: strftime code for %Y-%m-%d
?%F %T
, equivalent to%Y-%m-%d %H:%M:%S
?