insight-ui-excc
Version:
An open-source frontend for the Insight API compatible with Exchangecoin. The Insight API provides you with a convenient, powerful and simple way to query and broadcast data on the Exchangecoin network and build your own services with it.
45 lines (37 loc) • 1.05 kB
JavaScript
'use strict';
angular.module('insight.charts').controller('ChartsController',
function($scope, $rootScope, $routeParams, $location, Chart, Charts) {
$scope.loading = false;
$scope.list = function() {
Charts.get({
}, function(res) {
$scope.charts = res.charts;
});
if ($routeParams.chartType) {
$scope.chart();
}
};
$scope.chart = function() {
$scope.loading = true;
Chart.get({
chartType: $routeParams.chartType
}, function(chart) {
$scope.loading = false;
$scope.chartType = $routeParams.chartType;
$scope.chartName = chart.name;
$scope.chart = c3.generate(chart);
}, function(e) {
if (e.status === 400) {
$rootScope.flashMessage = 'Invalid chart: ' + $routeParams.chartType;
}
else if (e.status === 503) {
$rootScope.flashMessage = 'Backend Error. ' + e.data;
}
else {
$rootScope.flashMessage = 'Chart Not Found';
}
$location.path('/');
});
};
$scope.params = $routeParams;
});