After the logic used to calculate trend data, the next most difficult task is defining JavaScript code used to make AJAX requests for trend data. This is accomplished in the /path/to/repo/www/chapter_09/templates directory. The template filename is trend.html. Inside this template file, we add a <div> tag, where the JavaScript-generated chart resides. For the purpose of this example, we will use Chartist.js, an extremely simple-to-use JavaScript responsive chart generator that has no dependencies.
chartist.js is the brainchild of Gion Kunz from Zurich, Switzerland. The source code is provided under a Massachusetts Institute of Technology (MIT) license, which is business-friendly and has no strings attached. Chartist.js should not be confused with Chart.js, which is another open source JavaScript library for generating charts. For more information on chartist.js, refer to https://gionkunz.github.io/chartist-js/.
First, we need to define an...