am5.ready(function() {
	var timespanEl = $('.activePeersChartDashboardWidget #timeSpan');
	var interfacesEl = $(".activePeersChartDashboardWidget #interfaces");
	var trafficChart = new DateXYChart("activePeersChart", {
		timeUnit: ChartUtils.daysToTimeUnit(timespanEl.val())
	});

	trafficChart.add(new JsonColumnSeries(() =>
		"/app/api/usage/all/vpn," +
			ChartUtils.daysToResolution(timespanEl.val()) + "," +
			interfacesEl.val() +
			",active/" + timespanEl.val(), "Peers"));

	timespanEl.change(() => { 
		trafficChart.setOptions({
			timeUnit: ChartUtils.daysToTimeUnit(timespanEl.val())
		});
		trafficChart.reload(); 
	});

	interfacesEl.change(() => trafficChart.reload());

	$('.activePeersChartDashboardWidget .refresh-graph').off('click').on('click', () => {
		trafficChart.reload();
		return false;
	});
});

