Sparklines are small line charts that are used to augment the value of some other content by giving a visual trend of a specific metric. One of the easy examples of applications that use sparklines is Google Analytics.
As you can see in the previous screenshot, the sparklines on the left give you a clearer background about the numbers on the right. So as of today, you had 13,935 visits but those varied in a specific pattern in the previous month.
The following are the steps required to build sparklines:
Since sparklines are a pretty simple graph, we only have two classes for this recipe. In the main class, we generate the data and instantiate the
Sparkline
class. All of the drawing is done insideSparkline.as
.We will only use the
graphics
function of theSprite
class to draw the line and the axes:graphics.lineStyle(1, 0x0000ff); graphics.moveTo...