Podcast Lookup

Data Visualization with JavaScript

CyberSecurity Summary

  • July 20, 2026
  • 22 min
Episode page
About this episodeA practical guide for developers to implement effective digital graphics using various code libraries. The text emphasizes that simplicity…
A practical guide for developers to implement effective digital graphics using various code libraries. The text emphasizes that simplicity and clarity are paramount, as familiar formats like bar and line charts allow users to interpret data intuitively. By utilizing tools such as Flotr2 and D3.js, the author demonstrates how to construct interactive and static visualizations through step-by-step technical instructions. The source covers a wide range of applications, from geographic mapping and timelines to specialized structures like heat maps and word clouds. Additionally, Thomas addresses real-world development challenges, including cross-browser compatibility and debugging third-party library issues. Ultimately, the book serves as a roadmap for transforming abstract numerical sets into compelling, data-driven web applications.

You can listen and download our episodes for free on more than 10 different platforms:
https://linktr.ee/cyber_security_summary

Get the Book now from Amazon:
https://www.amazon.com/Data-Visualization-JavaScript-Stephen-Thomas-ebook/dp/B00V20IFDG?&linkCode=ll2&tag=cvthunderx-20&linkId=a8d31698ffc4b51db32b2e8332ca15a5&language=en_US&ref_=as_li_ss_tl

Discover our free courses in tech and cybersecurity, Start learning today:
https://linktr.ee/cybercode_academy

Transcript

From the publisher

This transcript comes from the podcast’s own feed, shown as the publisher wrote it.

Data Visualization with JavaScript

00:00—
  1. Speaker 1

    Imagine you just pulled up to a gas station. You put the nozzle in your car, you squeeze the handle, and you pump twenty gallons of fuel. But like there's this massive leak in the hose. Oh no, yeah, so out of those twenty gallons, nineteen point nine gallons just drip directly onto the concrete highway.

  2. Speaker 2

    That's terrible, right, you.

  3. Speaker 1

    Only actually get a few drops into your engine. I mean that sounds completely.

  4. Speaker 2

    Absurd, right, it really does. But you know that is exactly what is happening to our information right now.

  5. Speaker 1

    Exactly.

  6. Speaker 2

    We hear constantly about how much data we are generating as a society, but the reality of how little we actually use is staggering.

  7. Speaker 1

    It's crazy. One widely cited estimate suggests that ninety nine point five percent of the data our systems collect just goes to waste.

  8. Speaker 2

    Wow.

  9. Speaker 1

    Yeah, it just sits on servers, completely ignored. And the reason for that massive waste is what we are tackling in today's.

  10. Speaker 2

    Deep dive, which is such an important topic.

  11. Speaker 1

    It is our mission today is short cutting your path to becoming a master of visual communication, because raw data, by its very nature, is just an abstract headache for the human brain.

  12. Speaker 2

    Right, Our brains aren't built for raw spreadsheets, No.

  13. Speaker 1

    They aren't. So we are pulling some incredible insights today from a book by Stephen A. Thomas called Data Visualization with JavaScript.

  14. Speaker 2

    And you know what I love about this specific book is that it doesn't just treat charts like magic tricks, right. It acknowledges that effective visualizations are really the only way to transform those abstract, raw numbers into a shape that the human brain can actually process, yeah, making it digestible exactly. When a chart is built perfectly, you free the viewer like they don't have to decisive the math, they just get it. Yeah, they can just focus entirely on the store that the data is trying to tell. But you cannot build that kind of seamless experience unless you understand the mechanics happening under the hood, Which means.

  15. Speaker 1

    We aren't just going to sit here and talk about, you know, what makes a good chart on a theory medical level.

  16. Speaker 2

    No, we're getting into the weeds.

  17. Speaker 1

    We really are. We are actually going to look at how they are built. We're going to explore the underlying logic of open source tools, specifically focusing on a JavaScript library called flat ru two.

  18. Speaker 2

    It's a great tool.

  19. Speaker 1

    It is we are getting into the nuts and bolts of how a computer draws a story. But before we can start building complex, dazzling interactive graphics, we have to master the absolute workhorse, the foundation, right, and I'm talking about the simple bar chart.

  20. Speaker 2

    It really is the foundation of everything. I mean, you have seen thousands of bar charts in your life, which means there is zero learning curve for the viewer.

  21. Speaker 1

    Yeah, totally intuitive.

  22. Speaker 2

    The convention is so baked into our psychology that you just absorb the information. But actually building one from scratch reveals some really fascinating mechanics about how computers and humans, well, they disagree on what makes sense?

  23. Speaker 1

    Yes, and the book walks us through a brilliant example of this. Okay, let's unpack this. Let's do We look at the English Mere League wins for the soccer team Manchester City. This is from two thousand and six to twenty twelve, and the data points show their performance shifting pretty dramatically. They started thirteen wins in two thousand and six, they drop to eleven wins in two thousand and seven, and eventually they climb all the way up to twenty eight wins by twenty twelve.

  24. Speaker 2

    Quite a jump.

  25. Speaker 1

    Yeah. Now, to get this data onto a web page using that flow year two library, you can't just type the numbers onto the screen. You have to use an HTML canvas.

  26. Speaker 2

    Element right, And for anyone who hasn't built a web page, think of an HTML canvas exactly like it sounds. It is a literal, blank, invisible rectangle that the browser sets aside on your screen, like a literal canvas exactly. It doesn't process texts like a normal web page. It's a dedicated sandbox specifically for a JavaScript library. To draw raw pixels.

  27. Speaker 1

    And to tell the library what to draw in that sandbox, you have to feed it nested to raise a data so you package the year and the wins together as coordinates.

  28. Speaker 2

    Sounds straightforward enough.

  29. Speaker 1

    It does, But here's the catch. If you just feed those coordinates in and let the library use its default mathematical settings, you run into a massive problem. The default algorithm automatically calculates the vertical axis the y axis based purely on your lowest and highest data points, so it zooms in. Yes, because Manchester City's lowest number of wins was eleven, the bottom of the chart starts.

  30. Speaker 2

    At eleven, which is an issue.

  31. Speaker 1

    Well, wait a minute, let me push back on this for a second.

  32. Speaker 2

    Okay, go ahead.

  33. Speaker 1

    If I am a computer programmer, I might argue that the computer is doing exactly what it should if the data only exists between the numbers eleven and twenty eight. Isn't starting the axis at eleven mathematically the most precise way to show that specific variance? Technically, yes, right, So why are we overwriting the computer when its math is technically correct?

  34. Speaker 2

    That is the perfect question because it highlights the fundamental difference between mathematical precision and human visual processing.

  35. Speaker 1

    Okay, how so.

  36. Speaker 2

    Well the math is correct visually, it is a total disaster. When we look at a bar chart, our brains don't just read the numbers on the side. We process the proportion of the shapes. Oh, I see, We inherently believe that if one bar is twice as tall as another, the underlying value must be twice as large.

  37. Speaker 1

    That makes total sense. It's like cropping a photograph so tightly that you lose all the background context.

  38. Speaker 2

    That's a perfect analogy. So if the bottom of your chart is set to eleven, the bar for the year two thousand and seven, where they won exactly eleven games, completely disappears.

  39. Speaker 1

    Oh wow, because it's at the absolute bottom exactly.

  40. Speaker 2

    It has zero height. It's just a flat line on the floor of the chart. To anyone quickly glancing at it, it visually implies that Manchester City won absolutely zero games that year.

  41. Speaker 1

    Right. Think about the last stock chart you looked at on your phone. Did you actually check where the y axis started? Probably not, because if it didn't start at zero, you might have panicked over a visual drop that was actually minuscule. In reality, it's a huge blind spot.

  42. Speaker 2

    Exactly. You end up manipulating the viewers perception of reality, even if you did it completely by accident.

  43. Speaker 1

    Yeah, the visual.

  44. Speaker 2

    Distance between eleven wins and twenty eight wins looks like a catastrophic chasm if eleven is.

  45. Speaker 1

    The floor, right, But when you go into the code and manually force the y axis minimum to zero, the eleven wind bar suddenly has weight.

  46. Speaker 2

    It changes everything the viewer sees.

  47. Speaker 1

    The true proportional difference. It was a bad year, sure, but it wasn't a total failure.

  48. Speaker 2

    And while you are in the code fixing the axis, you also have to fix the computer's assumptions about the numbers themselves.

  49. Speaker 1

    Oh right.

  50. Speaker 2

    Because the computer algorithm assumes all data could potentially be fractions, it helpfully adds decimal points to the labels. On the side.

  51. Speaker 1

    You cannot have fifteen point zero soccer.

  52. Speaker 2

    Wins exactly, so you pass a quick option in the code. It's tick decimals zero. It cleans up the labels.

  53. Speaker 1

    It really proves that the code might be mathematically sound, but you constantly have to manually adjust it for human reality.

  54. Speaker 2

    It is a constant translation between machine logic and human intuition.

  55. Speaker 1

    Okay, so forcing a zero baseline fixes a static bar chart, but that really only works for discrete, separated moments in time. What if we're tracking something massive and continuous, like say climate change over fifty years.

  56. Speaker 2

    That gets tricky.

  57. Speaker 1

    Yeah, a bar chart with fifty individual pillars would just look like a crowded fence.

  58. Speaker 2

    The trend gets lost. How does the code handle decades of continuous movement? That is where you have to transition to line charts. They really excel at revealing the overall narrative in massive data sets without bogging the viewers bring down in the individual year by year data.

  59. Speaker 1

    Points, and the book uses this incredible data set from NOAA, the National Oceanic and Atmospheric Administration. It's a great example. It spans over fifty years tracking the carbon dioxide concentration in the atmosphere from Manola, Hawaii alongside the global surface temperature deviations for that exact same time period.

  60. Speaker 2

    Which presents a notoriously difficult challenge for a developer. You are trying to plot two very critical but very different, currently measured metrics on the exact same piece of digital paper.

  61. Speaker 1

    Here's where it gets really interesting. We are talking about putting two completely different scales on the same.

  62. Speaker 2

    Chart, the double access dilemmas exactly.

  63. Speaker 1

    You have CO two, which is measured in parts per million. Those are large absolute numbers in the three hundreds and four hundreds, right, and then you have temperature deviations which are measured in tiny fractions of a single degree celsi's numbers like zero point zero seven or point one.

  64. Speaker 2

    Two, So completely different scales.

  65. Speaker 1

    If you just overlay them, the grid lines clash, the values don't align, and the viewer just gives up. But beyond the formatting, the whole concept of a deviation metric is confusing. It really is the temperature values aren't absolute temperatures, they are deviations from the twentieth century historical average. So how on earth does a developer make that historical average clear to the end user without just slapping a giant paragraph of explanatory text onto the screen.

  66. Speaker 2

    What's fascinating here is one of my favorite techniques in the book. The author uses a brilliant yet incredibly simple coding trick.

  67. Speaker 1

    I love this part.

  68. Speaker 2

    To represent that twentieth century average baseline, the coder literally injects a completely fake dummy data set into the JavaScript array.

  69. Speaker 1

    Wait fake data.

  70. Speaker 2

    Yes, for every single year from nineteen fifteen nine to twenty twelve, they add a corresponding data point of exactly zero.

  71. Speaker 1

    Oh, it's like drawing a firm line in the sand, so you can accurately measure exactly how far the tide is coming in.

  72. Speaker 2

    That's a great way to think about it. And they don't just leave it looking like a normal line of data. What do they do in the code? They style this specific zero line to be only one pixel wide. They color it a dark, subtle gray, and they completely disable its drop shadow, so it blends in exactly. By changing those visual properties, it stops looking like a data set to the human eye and starts looking like a piece of the charts structural framework.

  73. Speaker 1

    It creates an instant visual anchor. You don't have to read an explanation. Your brain immediately understands that anything above that gray line is warmer than the historical average, and anything below it is cooler. It's so intuitive, And the author does one more subtle thing in the code that I found so clever. When you have multiple lines, you obviously need a legend so the user knows what they're looking.

  74. Speaker 2

    At, right a key.

  75. Speaker 1

    By default, the computer will just list the legend items in whatever random order you fed the arrays into the code.

  76. Speaker 2

    Which again is the computer just doing what it's told, but completely ignoring human logic.

  77. Speaker 1

    Right. But if you intentionally swamp the order of the data series in your code, specifically putting the temperature deviation data right next to that dummy baseline zero data, they get grouped together visually in the little legend box.

  78. Speaker 2

    Oh that's smart.

  79. Speaker 1

    It intuitively links the concept of the temperature with the baseline for the viewer before their eyes even move over to analyze the graph itself. To tiny psychological match.

  80. Speaker 2

    It proves that building these things isn't just about plotting points. You are designing a cognitive experience. You are quietly guiding the user's eye to make the right connections.

  81. Speaker 1

    So we've solved tracking things over continuous time. But what if time isn't the factor at all? Okay, what if you want to take a snapshot of the world right now and figure out if two entirely different variables actually cause each other, or at least correlate.

  82. Speaker 2

    That is the perfect scenario for a scatter chart. You aren't looking at trends over time. You are looking for relationships between disparate things.

  83. Speaker 1

    The Deep Dive moves into this fascinating twenty ten OECD data set. It compares healthcare spending as a percentage of a country's GDP against the average life expectancy of its citizens.

  84. Speaker 2

    A classic comparison.

  85. Speaker 1

    Yeah, the fundamental question is does spending a higher percentage of your national wealth on healthcare actually equal a longer life for your people?

  86. Speaker 2

    It is a very complex question. You are plotting dozens of individual countries as floating dots based on those two independent variables.

  87. Speaker 1

    But once again, if you just hand this raw data to the flat er two library, the default output is pretty claustrophobic, very crammed. The library tries to maximize the space, so the points get crammed right against the very edges of the chart box. The dot for the country with the lowest spending physically touches the left wall, and the highest bending touches the right wall.

  88. Speaker 2

    That's hard to read.

  89. Speaker 1

    It just like framing a beautiful painting but letting the picture frame cover up the outer two inches of the canvas. Your eyes need margins to comfortably process the words, and data points need margins to be compared accurately.

  90. Speaker 2

    And while visualization libraries almost always have an autoscale feature that tries to fix this mathematically, they often fall short of what the human eye actually needs.

  91. Speaker 1

    So it's the fix.

  92. Speaker 2

    A skilled visualizer will look at that cramped box and manually override the defaults. You explicitly tell the code set the x axis minimum to five and the maximum to twenty. You intentionally pad the axes to give the data breathing room.

  93. Speaker 1

    It separates the cluster of information from the boundaries of the chart, but the breathing room isn't the only thing the user needs. The x axis represents a percentage, bending as a percentage GDP. But the raw data in the array, it's just the integers five, ten, fifteen, extrail numbers. Yeah. If you leave it like that, the user has to look at the number fifteen, scan their eyes over to the access title, read percentage of GDP, and then remind themselves right that number fifteen means fifteen percent.

  94. Speaker 2

    Which sounds incredibly minor, but in the world of data consumption, that is cognitive friction. It slows down comprehension, and as.

  95. Speaker 1

    A developer, you have the power to just remove that friction. Flutoo allows you to write a custom formatting function for the axis labels. That's really handy.

  96. Speaker 2

    So instead of just accepting the default integers, you write a tiny piece of logic that intercepts the label right before the browser draws it on the canvas, and simply a pens a percentage signed to it. Oh nice. The user just sees fifteen percent and instantly understands the value, and you really want them to understand it quickly, because the payoff of this specific data set is amazing. When you step back and look at the scatterplot, you don't see a perfect diagonal line going up.

  97. Speaker 1

    No, you don't, and that is exactly why you need a scatterplot instead of a bar chart. If you just average the data out into bars, you would miss the reality. You miss the whole point exactly. The scatter reveals a messy cluster. It visually proves that simply spending more money on healthcare does not guarantee a linear, straight line increase in life expectancy.

  98. Speaker 2

    Right, they are country spending less that are achieving longer life stands.

  99. Speaker 1

    The spread is the story.

  100. Speaker 2

    It's brilliant. But speaking of cognitive friction, well, we have to talk about the most controversial chart in the entire corporate world, and frankly.

  101. Speaker 1

    The messy reality of the code that builds them. I am talking, of course, about the notorious pie chart.

  102. Speaker 2

    The chart that data scientists absolutely love to hate.

  103. Speaker 1

    Okay, I have to play devil's advocate here. Wait, everyone loves a colorful pie chart. They're in literally every boardroom presentation and every quarterly report ever made. Why do developers usually hate them?

  104. Speaker 2

    Well, if we connect this to the bigger picture, it comes down to a fundamental biological flaw in how the human brain processes geometry. Really biology, Yeah, we are actually terrible at judging the relative size of areas. We are very good at comparing lengths, like the height of vertical bars in a bar chart.

  105. Speaker 1

    Sure, and that's easy.

  106. Speaker 2

    If one bar is just a few pixels taller than another, your eye catches it instantly. But when you take a circle, slice it into five or six irregularly sized wedges, and then ask the human eye to rank them.

  107. Speaker 1

    By size to a guessing game.

  108. Speaker 2

    We fail miserably. Unless the difference is drastic. We just cannot accurately compare those non rectangular areas. If you're comparing multiple values against each other, a bar chart is almost always better.

  109. Speaker 1

    Okay, fair enough, But the book actually defends them in one very specific scenario.

  110. Speaker 2

    Yes it does. They are highly effective for one task emphasizing a single fraction against a hole.

  111. Speaker 1

    Ooh.

  112. Speaker 2

    If you only have two slices and you want to show the sheer proportion of one piece relative to everything else, it is incredibly powerful.

  113. Speaker 1

    The example in the book is striking. It uses World Bank data from two thousand and eight to visualize extreme global poverty.

  114. Speaker 2

    It's a sobering visual, it really is.

  115. Speaker 1

    It highlights that twenty two point four percent of the world's population was living on less than a dollar and twenty five cents a day. Wow. When you put that single red wedge of twenty two point four percent against a solid, massive circle representing the rest of humanity, you don't need to compare multiple variables. The impact is visceral and instant.

  116. Speaker 2

    In that context, the pie chart strips away everything extraneous and forces you to confront that single massive proportion.

  117. Speaker 1

    But actually getting that pie chart to render brings us to my absolute favorite part of this deep dive. It is the reality versus ideal world philosophy of the book, which is so relatable because we tend to think of computer programming as this pristine, perfect science where everything is logical. But the reality is that even great widely used open source cools have hilarious, messy corps.

  118. Speaker 2

    Software is written by humans, and humans use tape and glue to hold things together.

  119. Speaker 1

    Exactly so the author details this known deliberate and the Flatschow Library. When the library is trying to calculate how big to draw the charts, the size the text, the width of labels, everything, it has to physically create dummy HTML elements in the background of your web browser to measure them.

  120. Speaker 2

    It has to generate them to size them up right.

  121. Speaker 1

    But obviously it doesn't want the user to see these weird dummy text elements popping up on the web page while it does the mask.

  122. Speaker 2

    They need to exist on the page to be measured, but they need to be invisible to the user.

  123. Speaker 1

    So what does this all mean? How do the developers hide them? Well, every web page is structured using something called the DOM, the document object model, the blueprint. It's basically the blueprint of the page, and you style that blueprint using CSS. The developers of this library wrote a CSS rule using absolute positioning. They told these dummy text elements to be placed exactly ten thousand pixels above the top of the.

  124. Speaker 2

    User's screen using a negative value.

  125. Speaker 1

    Yes, they use a top margin of negative ten thousand picks on.

  126. Speaker 2

    The logic being just throw it so far off the screen that no one will ever see it out of sight, out of mind exactly.

  127. Speaker 1

    But here is the catch. CSS absolute positioning is tricking. It is like telling someone go stand one hundred feet north, but north of what the center of the earth, the room you were currently standing in.

  128. Speaker 2

    It's relative.

  129. Speaker 1

    That is what happens to the browser. Sometimes, depending on how your specific web page is built, that negative ten thousand pixels is calculated relative to a container inside your page, not the absolute top of the browser.

  130. Speaker 2

    Window, which becomes a massive problem if the user's document is extremely long.

  131. Speaker 1

    Yes, if you are building a massive, long, scrolling dashboard full of charts, that negative ten thousand pisel trick completely backfires. The browser's positioning gets confused.

  132. Speaker 2

    Oh, I can picture it now.

  133. Speaker 1

    Suddenly the user is scrolling down your beautiful dashboard and they start seeing random pieces of invisible chart text scattering like confetti across your website.

  134. Speaker 2

    It is the perfect encapsulation of how coding in the real world actually works. You can have the most elegant data structures, but you are still at the mercy of a web browser misinterpreting a CSS hack from a third party library.

  135. Speaker 1

    And I absolutely love the book's practical takeaway for this. The author basically says, Look, you could theoretically go into the open source library, dig through thousands of lines of source code and rewrite their positioning logic to be perfect. Or you can just be a pragmatic developer.

  136. Speaker 2

    Sometimes you just need a quick fix.

  137. Speaker 1

    He suggests just writing a single line of jQuery to find and hide the library's messy invisible.

  138. Speaker 2

    Elements for those unfamiliar. jQuery is just a shortcut language for web developers. It allows you to quickly find elements on a web page after it has loaded and manipulate them.

  139. Speaker 1

    Right so, the author says, just write a quick jQuery script that targets the specific class name of those messy invisible elements, the dot, float, dummy div class and just brutally forces them to hide once the chart is done drawing.

  140. Speaker 2

    It's a band aid, but sometimes the best solution is the pragmatic one. It saves you hours of de and it gets the visualization working for the user, which is the ultimate goal.

  141. Speaker 1

    It is such a wonderfully messy reality check. Yeah, which actually brings us to the most important question for you, the listener. We've spent this time talking about arrays, HTML canvases, y axis minimums, and CSS bugs. Why does knowing the JavaScript logic behind these charts actually matter to you?

  142. Speaker 2

    It matters deeply because visual communication is a language, and right now in the modern world, data is being spoken at you constantly all day long.

  143. Speaker 1

    Exactly think about it. Whether you are actively trying to program a dashboard at your job, prepping a slide deck for a board meeting, or simply just sitting on your couch trying to consume your daily news on your phone without being misled.

  144. Speaker 2

    It's everywhere.

  145. Speaker 1

    Understanding how axes are manipulated, why data points, meat, breathing room, and when a pie chart is actually useful makes you a vastly sharper, more critical consumer of information.

  146. Speaker 2

    You stop just looking at the geometric shapes and you start seeing the underlying structure.

  147. Speaker 1

    You start to recognize the choices the creator made, and.

  148. Speaker 2

    Even more importantly, you start to recognize the choices they decided not to make.

  149. Speaker 1

    Absolutely. Yeah, so we want to leave you with this thought. Tom all over today. Now that you know exactly how easily a chart's entire narrative can be radically altered just by tweaking the minimum value of a y axis in the code, or switching from comparative bars to an unreadable pie slice.

  150. Speaker 2

    Yeah, think about that.

  151. Speaker 1

    How much the data you scrolled past today was intentionally designed to manipulate your perception rather than actually inform you