(function (till) {
	'use strict';

	/**
	 * @type {!Object}
	 */
	till.index = {};

	/**
	 * @constructor
	 */
	till.index.Controller = function () {
		/**
		 * @type {!till.common.Service}
		 * @private
		 */
		this.service_ = new till.common.Service();

		this.run_();
	};

	/**
	 * @private
	 */
	till.index.Controller.prototype.run_ = function () {
		var form = document.querySelector('form');
		form.addEventListener('submit', this.onSubmit_.bind(this));
	};

	/**
	 * @param {!Object.<string, string>} params
	 * @param {string} $0
	 * @param {string} $1
	 * @param {string} $2
	 * @param {string} $3
	 * @private
	 */
	till.index.Controller.prototype.bindParams_ = function(params, $0, $1, $2, $3) {
		params[$1] = $3;
	};

	/**
	 * @param {string} csv
	 * @return {!Array.<!Array.<string>>}
	 * @private
	 */
	till.index.Controller.prototype.csvToArray_ = function (csv) {
		var pattern = new RegExp(('(\\,|\\r?\\n|\\r|^)(?:\"([^\"]*(?:\"\"[^\"]*)*)\"|([^\"\\,\\r\\n]*))'), 'gi');
		var result = [[]];
		var matches = null;
		while (matches = pattern.exec(csv)) {
			var match = matches[1];
			if (match.length && match != ',') {
				result.push([]);
			}

			var value = matches[2] ? matches[2].replace(new RegExp('\"\"', 'g'), '\"') : matches[3];
			result[result.length - 1].push(value);
		}

		return result;
	};

	/**
	 * @param {number} status
	 * @param {string} statusText
	 * @param {string} responseText
	 * @private
	 */
	till.index.Controller.prototype.handleListAutos_ = function(status, statusText, responseText) {
		var rows = this.csvToArray_(responseText);
		this.renderPriceByYearChart_(rows);
		this.renderPriceByMileageChart_(rows);
	};

	/**
	 * @param {Event} e
	 * @private
	 */
	till.index.Controller.prototype.onSubmit_ = function (e) {
		e.preventDefault();
		var city = e.target.city.value;
		var query = e.target.query.value;
		this.service_.listAutos(this.handleListAutos_.bind(this), city, query);
	};

	/**
	 * @param {string} id
	 * @param {string} csv
	 * @private
	 */
	till.index.Controller.prototype.renderChart_ = function(id, csv) {
		var chart = document.getElementById(id);
		var opts = {
			'drawPoints': true,
			'strokeWidth': 0.0
		};

		new Dygraph(chart, csv, opts);
	};

	/**
	 * @param {!Array.<!Array.<string>>} rows
	 * @private
	 */
	till.index.Controller.prototype.renderPriceByYearChart_ = function(rows) {
		var csv = '';
		for (var i = 0, j = rows.length; i < j; ++i) {
			csv += rows[i][2] + ',' + rows[i][1] + '\n';
		}

		this.renderChart_('chart-price-by-year', csv);
	};

	/**
	 * @param {!Array.<!Array.<string>>} rows
	 * @private
	 */
	till.index.Controller.prototype.renderPriceByMileageChart_ = function(rows) {
		var csv = '';
		for (var i = 0, j = rows.length; i < j; ++i) {
			csv += rows[i][0] + ',' + rows[i][1] + '\n';
		}

		this.renderChart_('chart-price-by-mileage', csv);
	};
}(window.till));

@@ -673,16 +673,17 @@
 function
+ 
 (params,
@@ -721,24 +721,368 @@
  = $3;%0A%09%7D;%0A%0A
+%09/**%0A%09 * @private%0A%09 */%0A%09till.index.Controller.prototype.clearCharts_ = function () %7B%0A%09%09var divs = document.getElementsByTagName('div');%0A%09%09for (var i = 0, j = divs.length; i %3C j; ++i) %7B%0A%09%09%09var div = divs%5Bi%5D;%0A%09%09%09if (div.id && div.id.indexOf('chart-') == 0) %7B%0A%09%09%09%09while (div.firstChild) %7B%0A%09%09%09%09%09div.removeChild(div.firstChild);%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D;%0A%0A
 %09/**%0A%09 * @pa
@@ -2130,16 +2130,40 @@
 ault();%0A
+%09%09this.clearCharts_();%0A%0A
 %09%09var ci

Clear the charts when a new one is being loaded