-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from ncusi/visualization - headers and authors…
… grid Visualization: Add "type.<line kind> [%]", main plot header, and authors grid
- Loading branch information
Showing
8 changed files
with
513 additions
and
74 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import hashlib | ||
from urllib.parse import urlencode | ||
|
||
import panel as pn | ||
|
||
|
||
@pn.cache | ||
def gravatar_url(email: str, size: int = 16) -> str: | ||
# https://docs.gravatar.com/api/avatars/python/ | ||
|
||
# Set default parameters | ||
# ... | ||
|
||
# Encode the email to lowercase and then to bytes | ||
email_encoded = email.lower().encode('utf-8') | ||
|
||
# Generate the SHA256 hash of the email | ||
email_hash = hashlib.sha256(email_encoded).hexdigest() | ||
|
||
# https://docs.gravatar.com/api/avatars/images/ | ||
# Construct the URL with encoded query parameters | ||
query_params = urlencode({'s': str(size)}) # NOTE: will be needed for 'd' parameter | ||
url = f"https://www.gravatar.com/avatar/{email_hash}?{query_params}" | ||
|
||
return url |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"""Provide human-readable value, together with machine-readable HTML metadata/microdata""" | ||
import os | ||
|
||
import pandas as pd | ||
|
||
|
||
def html_date_humane(date: pd.Timestamp) -> str: | ||
date_format = '%d %a %Y' | ||
if os.name == 'nt': | ||
date_format = '%#d %a %Y' | ||
elif os.name == 'posix': | ||
date_format = '%-d %a %Y' | ||
|
||
return f'<time datetime="{date.isoformat()}">{date.strftime(date_format)}</time>' | ||
|
||
|
||
def html_int_humane(val: int) -> str: | ||
thousands_sep = " " # Unicode thin space (breakable in HTML),   | ||
|
||
res = f'{val:,}' | ||
if thousands_sep != ",": | ||
res = res.replace(",", thousands_sep) | ||
|
||
return f'<data value="{val}" style="white-space: nowrap;">{res}</data>' |
Oops, something went wrong.