Pie, Bar, and Book Nerd Bliss

Day 45 of 100 Days Coding Challenge: Python

I’m still tinkering with my book log program—not just because it’s part of my Python learning project, but because, let’s be honest, I want this thing to actually work. I mean, really work. As in “track-my-life’s-reading-habits-and-give-me-pretty-charts” work. Reading is sacred in my world, and keeping a log isn’t just a nerdy pastime—it’s a habit that brings me joy, perspective, and a little control over my chaos.

Today’s feature? I added a toggle so users (okay, me) can switch between a pie chart showing total genre distribution and a bar chart showing monthly genre patterns. Why? Because I read more Gothic and fantasy novels in October, and it’s satisfying to see that mood shift visualized. Also, toggles are cool. They make me feel like I’ve built a dashboard, not just a Python script.

Today’s Motivation / Challenge

Ever feel like you’ve built something, and it’s almost useful… but not quite delightful yet? That was me. So, today’s mission was simple: add a little UX sparkle. Let the user choose how to view their genre stats—like a buffet for data nerds. Pie or bar? Whichever suits the literary mood.

Purpose of the Code (Object)

This code adds a flexible summary feature to a book tracking app. It lets users choose between a pie chart showing the overall breakdown of genres they’ve read or a bar chart showing how many pages they read per genre by month. It’s a compact, practical way to visualize your reading habits—and yes, it’s way more fun than a spreadsheet.

AI Prompt:

“Add an option to toggle between a pie chart and a bar chart when viewing genre summaries in a Python book log app.”

Functions & Features

  • Add a book and track its genre, author, page count, and completion date
  • Import books from a CSV file
  • View a genre summary chart as either a pie or bar graph
  • Filter chart data by genre or month
  • See trends in pages read by month and genre

Requirements / Setup

pip install pandas matplotlib  

Minimal Code Sample

def show_genre_summary_chart():

    print(“Choose chart type:”)

    print(“1. Pie Chart (Overall Genre Distribution)”)

    print(“2. Bar Chart (Pages per Genre by Month)”)

    choice = input(“Enter 1 or 2: “).strip()

    if choice == “1”:

        plot_genre_pie_chart()

    elif choice == “2”:

        plot_progress()

    else:

        print(“Invalid choice.”)

This function lets the user decide how they want their genre stats served: sliced (pie) or stacked (bar).

Book Tracker

Notes / Lessons Learned

I’m getting much smoother with activating my virtual environment. Looking back, I can’t believe I fumbled so much with cd errors and typos just last week. Progress!

Today, even the smallest update required a little code renovation. First, I added a new function (show_genre_summary_chart) above the main() block. Then I gave the user a choice:

print(“Choose chart type:”)

print(“1. Pie Chart (Overall Genre Distribution)”)

print(“2. Bar Chart (Pages per Genre by Month)”)

Finally, I updated the main menu to replace the old genre graph option with this smarter version. It works like a charm.

Honestly, I’ve used so many apps over the years without fully appreciating what went into them. Now that I’ve written code that sort of behaves nicely, I’m grateful to all the developers who did this before the age of AI. I’ve got help, but they? They had raw logic, coffee, and probably a lot of bugs.

Optional Ideas for Expansion

  • Add a date filter for the pie chart (e.g., genre distribution by year or season)
  • Let users export the pie/bar charts as PNG files for their own book reports
  • Display top 3 most-read genres alongside the charts

Leave a Reply

Your email address will not be published. Required fields are marked *