Skip to main content
Public

Share visualization

Loading preview…

Fork of Reusable Electric Bar Chart Using d3.stack

vizhub.com

Shared links may look like this on X, LinkedIn, Slack, and Discord.

Before sharing, review the publishing checklist.

Choose how to deliver this visualization

LinkedIn caption

LinkedIn may not keep text supplied by the share sheet. Copy the caption and paste it into the post if needed. You can tag the VizHub company page when posting.

More options

Embed on a websiteCopy iframe embed code
Download & exportPNG, HTML, source ZIP

Fork of Reusable Electric Bar Chart Using d3.stack

0
Vvoid-LSTM
Last edited May 21, 2022
Created on May 21, 2022

This stacked bar chart visualizes two years of personal electricity consumption across three accounts, with each bar representing a month’s total kWh usage broken down by bill year. An interactive menu switches between accounts. Built with d3.stack, d3.scaleBand, and d3.scaleLinear, it renders SVG bars with tooltips showing per-year and total consumption, plus a linked legend. Data is loaded from a CSV via d3.csv, and the chart is implemented as a reusable function.

AI-generated description

A bar chart visualization of my personal electricity consumption dataset. I live in a three family structure and occupy two floors. There is also a common account that supplies the front and back hall lighting as well as the basement and exterrior outlets. It covers a period of two years.

I forked https://vizhub.com/RED98310/a3ea8fbec4b64423a7797a418de4af57?edit=files and stated with that code. I also looked at Most basic stacked barplot in d3.js for how to render the stacked barchart.

I made the following changes from the one last week

  1. Changed the code to use d3.stack. There was a bug in the previous week bar chart since it wasn't showing account number 2222222222.
  2. Changed the y axis label to be along the axis and vertical instead of horizontal and at the top to make room for the title.
  3. Changed the colors to green and blue. I thought they were less jarring.
  4. Cleaned up the code by grouping calculation of data with the code that added it to the visualization.
  5. Added a title to the accounts legend per feedback on slack.
  6. Moved styling to style sheet
  7. Added tool tip showing the bar consumption and total consumption across accounts.
  8. Pulled in dependencies via package.json

Next steps

  1. Wrap the bar graph around a circle that is a 12 month period.

Unfortunately, I deleted the graph that I started with as part of cleaning up my profile then realized I should have kept it and forked from it per the instructions of the assignmnet. I believe I have captured all the changes.

version 1.3

Comments

Sign in to join the discussion.

MIT Licensed