Django & Plotly - Building a Github-style Heatmap

Published: 12 May 2022
on channel: BugBytes
4,955
116

In this video, we'll build a Github-style contribution heatmap using Django and Plotly.

We'll see how to build basic models to replicate Github (very simply!), and how to use Plotly's imshow function to generate heatmaps that can be rendered in Django templates.

We'll also see how to use Python and Django's datetime functionality to manipulate ORM objects and get the correct counts for a given date.

Starter code is available at: https://github.com/bugbytes-io/django...

Management command to generate data is here: https://github.com/bugbytes-io/django...

📌 𝗖𝗵𝗮𝗽𝘁𝗲𝗿𝘀:
00:00 Intro
01:07 Building Django Models
04:40 Creating SHA1 hash function
08:50 TimeStampedModel additional fields
09:28 Querying to Retrieve User Commits
10:08 Generating Fake Data
12:11 Adding URL and view
15:44 Finding the number of commits per-day
18:17 Reshaping Counts to a 2D list
21:59 Creating Plotly heat map
23:25 Changing the color scale
24:39 Customising Axis labels
28:09 Customising the Figure

☕️ 𝗕𝘂𝘆 𝗺𝗲 𝗮 𝗰𝗼𝗳𝗳𝗲𝗲:
To support the channel and encourage new videos, please consider buying me a coffee here:
https://ko-fi.com/bugbytes

𝗦𝗼𝗰𝗶𝗮𝗹 𝗠𝗲𝗱𝗶𝗮:
📖 Blog: https://www.bugbytes.io/posts/
👾 Github: https://github.com/bugbytes-io/django...
🐦 Twitter:   / bugbytesio  

📚 𝗙𝘂𝗿𝘁𝗵𝗲𝗿 𝗿𝗲𝗮𝗱𝗶𝗻𝗴 𝗮𝗻𝗱 𝗶𝗻𝗳𝗼𝗿𝗺𝗮𝘁𝗶𝗼𝗻:
Plotly Heatmaps: https://plotly.com/python/heatmaps/
Plotly Color Scales: https://plotly.com/python/builtin-col...
Python Hashlib: https://docs.python.org/3/library/has...
django-model-utils: https://django-model-utils.readthedoc...

#python #django #plotly #aggregation