Making a chart component with Angular directives
Angular directives allow us to extend the HTML syntax in a very powerful way—by adding new attributes and elements. This allows us to create components that feel native: from date and time pickers to data grids, charts, and visualizations.
Such components can then be reused without adding initialization code to our controllers. We simply tell the component what model it should bind to and it will automatically update its appearance to reflect any changes in the model.
In this recipe, we're going to make a chart directive using Flot to draw our chart. In the process, we will learn about some of the many powerful features of Angular directives.
Getting ready
We need to download Flot from http://www.flotcharts.org/ and extract the ZIP archive into our recipe directory, creating a sub-directory called flot
.
How to do it...
Let's write the code.
Create a file named
index.html
. It will include all the necessary scripts and a view that displays a chart...