Skip to main content
100%

Adding Interaction to My Bar Chart

✓ Published0🌍 Public
PPatrick-Houlihan
Last edited Oct 7, 2021
Created on Oct 7, 2021

This bar chart visualizes the percentage of at bats ending in a hit by pitch for 2017 MLB players with at least 10 HBPs, sorted from highest to lowest rate. Color intensity encodes each player’s total at bats relative to peers, with a legend showing the scale from 276 to 622 at bats. The chart uses D3 v5 with SVG rendering, employing `scaleLinear`, `scaleBand`, and `scaleOrdinal` for scales, `d3.interpolateOrRd` for the color ramp, and `d3.schemeOrRd` for the legend. Mouseover and mouseout events change bar fill and stroke, with a tooltip displaying raw HBP counts. Data comes from a GitHub gist CSV file.

AI-generated description

What This Shows

This bar chart shows the percentages of at bats during the 2017 MLB season that ended in a hit by pitch

What Does it Mean?

Color

The intensity of the color indicates the amount of at bats played relative to their peers, maximum at bats for this dataset is 622, minimum for the selected hitters is 276 at bats.

Name

The name of the player followed by their team. For players with multiple teams, TOT is shown

X Axis

This shows the percentage of at bats in which the hitter was hit by a pitch

Who is interesting here?

Anthony Rizzo has a high number of at bats relative to his peers for his HBP percentage, indicating that he may be more of a target to hit due to stance or personality towards pitchers or a multitude of other reasons.

Tyler Flowers, this guy just gets hit way more than his peers, a full %, OUCH

The Chicago Cubs featured 3 players with over ten HBP's

Dataset

The dataset can be found here

Amended 10/1/21

Improvements

In this iteration of the bar chart, a chromatic color scale is used, the players that get hit at a high rate over few plate appearances are now shown as more intense colors, and a legend is provided for understanding of the amount of At Bats each player has.

Citation : Code for Legend adapted from this

MIT Licensed

Similar vizzes