O'Reilly logo

HTML5 Canvas Cookbook by Eric Rowell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Plotting data points with a line chart

If you've ever taken a science class, you're probably familiar with generating line charts based on a set of data for your experiments. Line charts are probably one of the most useful data visualizations when communicating data trends. In this recipe, we'll create a configurable Line Chart class which takes in an array of data elements and plots each point while connecting the points with line segments.

Plotting data points with a line chart

How to do it...

Follow these steps to create a Line Chart class that can automatically position and size a line chart from an array of data:

  1. Define the constructor for the LineChart class that draws the x and y ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required