Is there a standard text mode tool to render heatmaps for arbitrary numeric data?
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
For the curiosity's sake I created a script to visualize Git history week/hour-of-day basis timestamps in order to collect some stats. The following script
#!/bin/bash
# Declare the global heatmap hashmap
declare -A HEATMAP
# Composes a key in a form of a <WEEKDAY:1><HOUR:02>
function key
local WEEKDAY="$1"
local HOUR="$2"
echo -n "$WEEKDAY"
if [[ "$HOUR" -lt 10 ]]; then
echo -n '0'
fi
echo "$HOUR"
# Generate a sequence of weekdays (Mon-Sat,Sun)
function generate_weekdays
seq 1 6
seq 0 0
# Generate a sequence of hours in day (00-23)
function generate_hours
seq 0 23
# Initialize and fill the heatmap with zeroes
for WEEKDAY in $(generate_weekdays); do
for HOUR in $(generate_hours); do
HEATMAP[$(key "$WEEKDAY" "$HOUR")]=0
done
done
# Read the stats into the heatmap
MAX_PEAK=1
while read WEEKDAY_HOUR; do
HEATMAP["$WEEKDAY_HOUR"]=$(($HEATMAP["$WEEKDAY_HOUR"] + 1))
if [[ $HEATMAP["$WEEKDAY_HOUR"] -gt "$MAX_PEAK" ]]; then
MAX_PEAK=$HEATMAP["$WEEKDAY_HOUR"]
fi
done < <(git rev-list --date=format:'%w%H' --pretty='format:%ad' $@ | awk 'NR % 2 == 0')
# Render the heatmap
RATIO=0
for WEEKDAY in $(generate_weekdays); do
for HOUR in $(generate_hours); do
RATIO=$((100 * $HEATMAP[$(key "$WEEKDAY" "$HOUR")] / $MAX_PEAK))
if [[ "$RATIO" -eq 0 ]]; then echo -ne 'e[38;5;236m'
elif [[ "$RATIO" -lt 10 ]]; then echo -ne 'e[38;5;107m'
elif [[ "$RATIO" -lt 20 ]]; then echo -ne 'e[38;5;22m'
elif [[ "$RATIO" -lt 30 ]]; then echo -ne 'e[38;5;28m'
elif [[ "$RATIO" -lt 40 ]]; then echo -ne 'e[38;5;70m'
elif [[ "$RATIO" -lt 50 ]]; then echo -ne 'e[38;5;190m'
elif [[ "$RATIO" -lt 60 ]]; then echo -ne 'e[38;5;226m'
elif [[ "$RATIO" -lt 70 ]]; then echo -ne 'e[38;5;220m'
elif [[ "$RATIO" -lt 80 ]]; then echo -ne 'e[38;5;214m'
elif [[ "$RATIO" -lt 90 ]]; then echo -ne 'e[38;5;208m'
elif [[ "$RATIO" -lt 100 ]]; then echo -ne 'e[38;5;160m'
elif [[ "$RATIO" -eq 100 ]]; then echo -ne 'e[38;5;196m'; fi
echo -n '*'
echo -ne 'e[0m'
done
echo
done
invoked as ./git-heatmap --all
produces a sample output as depicted below (not at a Linux machine currently, running on Windows/MinGW with the Fixedsys font, I prefer squares, u2BC0
, to asterisks, but Fixedsys cannot render the squares that I find much nicer):
Since the script does three jobs:
- consumes Git weekday/hour-of-day timestamps output,
- calculates the stats,
- and renders the heatmap
... I'm wondering is there something like a standard tool that calculates/renders something similar to the heatmap above? My script processes the following sample data supplied by Git:
100
101
420
517
...
where the first digit designates a weekday, and the second and the third digits designate a day hour. Thanks.
git data
New contributor
add a comment |Â
up vote
0
down vote
favorite
For the curiosity's sake I created a script to visualize Git history week/hour-of-day basis timestamps in order to collect some stats. The following script
#!/bin/bash
# Declare the global heatmap hashmap
declare -A HEATMAP
# Composes a key in a form of a <WEEKDAY:1><HOUR:02>
function key
local WEEKDAY="$1"
local HOUR="$2"
echo -n "$WEEKDAY"
if [[ "$HOUR" -lt 10 ]]; then
echo -n '0'
fi
echo "$HOUR"
# Generate a sequence of weekdays (Mon-Sat,Sun)
function generate_weekdays
seq 1 6
seq 0 0
# Generate a sequence of hours in day (00-23)
function generate_hours
seq 0 23
# Initialize and fill the heatmap with zeroes
for WEEKDAY in $(generate_weekdays); do
for HOUR in $(generate_hours); do
HEATMAP[$(key "$WEEKDAY" "$HOUR")]=0
done
done
# Read the stats into the heatmap
MAX_PEAK=1
while read WEEKDAY_HOUR; do
HEATMAP["$WEEKDAY_HOUR"]=$(($HEATMAP["$WEEKDAY_HOUR"] + 1))
if [[ $HEATMAP["$WEEKDAY_HOUR"] -gt "$MAX_PEAK" ]]; then
MAX_PEAK=$HEATMAP["$WEEKDAY_HOUR"]
fi
done < <(git rev-list --date=format:'%w%H' --pretty='format:%ad' $@ | awk 'NR % 2 == 0')
# Render the heatmap
RATIO=0
for WEEKDAY in $(generate_weekdays); do
for HOUR in $(generate_hours); do
RATIO=$((100 * $HEATMAP[$(key "$WEEKDAY" "$HOUR")] / $MAX_PEAK))
if [[ "$RATIO" -eq 0 ]]; then echo -ne 'e[38;5;236m'
elif [[ "$RATIO" -lt 10 ]]; then echo -ne 'e[38;5;107m'
elif [[ "$RATIO" -lt 20 ]]; then echo -ne 'e[38;5;22m'
elif [[ "$RATIO" -lt 30 ]]; then echo -ne 'e[38;5;28m'
elif [[ "$RATIO" -lt 40 ]]; then echo -ne 'e[38;5;70m'
elif [[ "$RATIO" -lt 50 ]]; then echo -ne 'e[38;5;190m'
elif [[ "$RATIO" -lt 60 ]]; then echo -ne 'e[38;5;226m'
elif [[ "$RATIO" -lt 70 ]]; then echo -ne 'e[38;5;220m'
elif [[ "$RATIO" -lt 80 ]]; then echo -ne 'e[38;5;214m'
elif [[ "$RATIO" -lt 90 ]]; then echo -ne 'e[38;5;208m'
elif [[ "$RATIO" -lt 100 ]]; then echo -ne 'e[38;5;160m'
elif [[ "$RATIO" -eq 100 ]]; then echo -ne 'e[38;5;196m'; fi
echo -n '*'
echo -ne 'e[0m'
done
echo
done
invoked as ./git-heatmap --all
produces a sample output as depicted below (not at a Linux machine currently, running on Windows/MinGW with the Fixedsys font, I prefer squares, u2BC0
, to asterisks, but Fixedsys cannot render the squares that I find much nicer):
Since the script does three jobs:
- consumes Git weekday/hour-of-day timestamps output,
- calculates the stats,
- and renders the heatmap
... I'm wondering is there something like a standard tool that calculates/renders something similar to the heatmap above? My script processes the following sample data supplied by Git:
100
101
420
517
...
where the first digit designates a weekday, and the second and the third digits designate a day hour. Thanks.
git data
New contributor
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
For the curiosity's sake I created a script to visualize Git history week/hour-of-day basis timestamps in order to collect some stats. The following script
#!/bin/bash
# Declare the global heatmap hashmap
declare -A HEATMAP
# Composes a key in a form of a <WEEKDAY:1><HOUR:02>
function key
local WEEKDAY="$1"
local HOUR="$2"
echo -n "$WEEKDAY"
if [[ "$HOUR" -lt 10 ]]; then
echo -n '0'
fi
echo "$HOUR"
# Generate a sequence of weekdays (Mon-Sat,Sun)
function generate_weekdays
seq 1 6
seq 0 0
# Generate a sequence of hours in day (00-23)
function generate_hours
seq 0 23
# Initialize and fill the heatmap with zeroes
for WEEKDAY in $(generate_weekdays); do
for HOUR in $(generate_hours); do
HEATMAP[$(key "$WEEKDAY" "$HOUR")]=0
done
done
# Read the stats into the heatmap
MAX_PEAK=1
while read WEEKDAY_HOUR; do
HEATMAP["$WEEKDAY_HOUR"]=$(($HEATMAP["$WEEKDAY_HOUR"] + 1))
if [[ $HEATMAP["$WEEKDAY_HOUR"] -gt "$MAX_PEAK" ]]; then
MAX_PEAK=$HEATMAP["$WEEKDAY_HOUR"]
fi
done < <(git rev-list --date=format:'%w%H' --pretty='format:%ad' $@ | awk 'NR % 2 == 0')
# Render the heatmap
RATIO=0
for WEEKDAY in $(generate_weekdays); do
for HOUR in $(generate_hours); do
RATIO=$((100 * $HEATMAP[$(key "$WEEKDAY" "$HOUR")] / $MAX_PEAK))
if [[ "$RATIO" -eq 0 ]]; then echo -ne 'e[38;5;236m'
elif [[ "$RATIO" -lt 10 ]]; then echo -ne 'e[38;5;107m'
elif [[ "$RATIO" -lt 20 ]]; then echo -ne 'e[38;5;22m'
elif [[ "$RATIO" -lt 30 ]]; then echo -ne 'e[38;5;28m'
elif [[ "$RATIO" -lt 40 ]]; then echo -ne 'e[38;5;70m'
elif [[ "$RATIO" -lt 50 ]]; then echo -ne 'e[38;5;190m'
elif [[ "$RATIO" -lt 60 ]]; then echo -ne 'e[38;5;226m'
elif [[ "$RATIO" -lt 70 ]]; then echo -ne 'e[38;5;220m'
elif [[ "$RATIO" -lt 80 ]]; then echo -ne 'e[38;5;214m'
elif [[ "$RATIO" -lt 90 ]]; then echo -ne 'e[38;5;208m'
elif [[ "$RATIO" -lt 100 ]]; then echo -ne 'e[38;5;160m'
elif [[ "$RATIO" -eq 100 ]]; then echo -ne 'e[38;5;196m'; fi
echo -n '*'
echo -ne 'e[0m'
done
echo
done
invoked as ./git-heatmap --all
produces a sample output as depicted below (not at a Linux machine currently, running on Windows/MinGW with the Fixedsys font, I prefer squares, u2BC0
, to asterisks, but Fixedsys cannot render the squares that I find much nicer):
Since the script does three jobs:
- consumes Git weekday/hour-of-day timestamps output,
- calculates the stats,
- and renders the heatmap
... I'm wondering is there something like a standard tool that calculates/renders something similar to the heatmap above? My script processes the following sample data supplied by Git:
100
101
420
517
...
where the first digit designates a weekday, and the second and the third digits designate a day hour. Thanks.
git data
New contributor
For the curiosity's sake I created a script to visualize Git history week/hour-of-day basis timestamps in order to collect some stats. The following script
#!/bin/bash
# Declare the global heatmap hashmap
declare -A HEATMAP
# Composes a key in a form of a <WEEKDAY:1><HOUR:02>
function key
local WEEKDAY="$1"
local HOUR="$2"
echo -n "$WEEKDAY"
if [[ "$HOUR" -lt 10 ]]; then
echo -n '0'
fi
echo "$HOUR"
# Generate a sequence of weekdays (Mon-Sat,Sun)
function generate_weekdays
seq 1 6
seq 0 0
# Generate a sequence of hours in day (00-23)
function generate_hours
seq 0 23
# Initialize and fill the heatmap with zeroes
for WEEKDAY in $(generate_weekdays); do
for HOUR in $(generate_hours); do
HEATMAP[$(key "$WEEKDAY" "$HOUR")]=0
done
done
# Read the stats into the heatmap
MAX_PEAK=1
while read WEEKDAY_HOUR; do
HEATMAP["$WEEKDAY_HOUR"]=$(($HEATMAP["$WEEKDAY_HOUR"] + 1))
if [[ $HEATMAP["$WEEKDAY_HOUR"] -gt "$MAX_PEAK" ]]; then
MAX_PEAK=$HEATMAP["$WEEKDAY_HOUR"]
fi
done < <(git rev-list --date=format:'%w%H' --pretty='format:%ad' $@ | awk 'NR % 2 == 0')
# Render the heatmap
RATIO=0
for WEEKDAY in $(generate_weekdays); do
for HOUR in $(generate_hours); do
RATIO=$((100 * $HEATMAP[$(key "$WEEKDAY" "$HOUR")] / $MAX_PEAK))
if [[ "$RATIO" -eq 0 ]]; then echo -ne 'e[38;5;236m'
elif [[ "$RATIO" -lt 10 ]]; then echo -ne 'e[38;5;107m'
elif [[ "$RATIO" -lt 20 ]]; then echo -ne 'e[38;5;22m'
elif [[ "$RATIO" -lt 30 ]]; then echo -ne 'e[38;5;28m'
elif [[ "$RATIO" -lt 40 ]]; then echo -ne 'e[38;5;70m'
elif [[ "$RATIO" -lt 50 ]]; then echo -ne 'e[38;5;190m'
elif [[ "$RATIO" -lt 60 ]]; then echo -ne 'e[38;5;226m'
elif [[ "$RATIO" -lt 70 ]]; then echo -ne 'e[38;5;220m'
elif [[ "$RATIO" -lt 80 ]]; then echo -ne 'e[38;5;214m'
elif [[ "$RATIO" -lt 90 ]]; then echo -ne 'e[38;5;208m'
elif [[ "$RATIO" -lt 100 ]]; then echo -ne 'e[38;5;160m'
elif [[ "$RATIO" -eq 100 ]]; then echo -ne 'e[38;5;196m'; fi
echo -n '*'
echo -ne 'e[0m'
done
echo
done
invoked as ./git-heatmap --all
produces a sample output as depicted below (not at a Linux machine currently, running on Windows/MinGW with the Fixedsys font, I prefer squares, u2BC0
, to asterisks, but Fixedsys cannot render the squares that I find much nicer):
Since the script does three jobs:
- consumes Git weekday/hour-of-day timestamps output,
- calculates the stats,
- and renders the heatmap
... I'm wondering is there something like a standard tool that calculates/renders something similar to the heatmap above? My script processes the following sample data supplied by Git:
100
101
420
517
...
where the first digit designates a weekday, and the second and the third digits designate a day hour. Thanks.
git data
git data
New contributor
New contributor
New contributor
asked 1 min ago
lsh
1
1
New contributor
New contributor
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
lsh is a new contributor. Be nice, and check out our Code of Conduct.
lsh is a new contributor. Be nice, and check out our Code of Conduct.
lsh is a new contributor. Be nice, and check out our Code of Conduct.
lsh is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f480010%2fis-there-a-standard-text-mode-tool-to-render-heatmaps-for-arbitrary-numeric-data%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password