Thursday, 11 December 2014

Using AmCharts in Play Framework 2 with Java

In this post, I am going to show you how you can use AmCharts in Play Framework 2 using Java.

First create a new Play Framework 2 Java project and download the Javascript libraries for AmCharts. download.
After you uncompress the file, you see that there are a lot of files in that folder. You really don't need all of it. To start with, I just chose some of them and put them in the public folder in my Play Framework 2 project:

Now let's create a template file called graph.scala.html and add two empty divs. One for the graph itself and the other for the legend. Also, for the ease of presentation, we put the javascript to handle the graph drawing in this template, but outside the main: