I am currently experiencing an issue with angular-charts in my application. Initially, I created a line chart that displayed perfectly. However, when I added a second chart (pie), the first chart stopped showing on the front end unless I hovered over it or resized the window.
Despite not having any hover events set, this display problem persists and I am unsure of the underlying cause.
Below is an excerpt from my controller:
app.controller('dashboardController', ['$scope', '$http', 'Page', 'authenticationService', function ($scope, $http, Page, authenticationService) {
// Code for setting up the page
Page.setTitle('Dashboard');
Page.setSubTitle('Transport Overview');
$scope.$emit('pageLoading');
$http({
url: '/api/dashboard/',
method: 'GET',
headers: authenticationService.getAuthToken(),
}).success(function (data) {
$scope.dashboard = data;
$scope.dashboard.revenuePerDayLabels = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
$scope.dashboard.weeklyJobIncome = [data.weeklyJobIncome];
$scope.dashboard.weekVehicleRevenueLabels = [];
$scope.dashboard.weekVehicleRevenueData = [];
angular.forEach($scope.dashboard.weekVehicleRevenue, function (item) {
$scope.dashboard.weekVehicleRevenueLabels.push(item.registrationNumber);
$scope.dashboard.weekVehicleRevenueData.push(item.vehicleRevenue);
});
$scope.$emit('pageLoaded');
}).error(function () {
$scope.$emit('pageLoaded');
});
}]);
The corresponding HTML code:
Line Chart
<canvas id="line" class="chart chart-line"
chart-data="dashboard.weeklyJobIncome"
chart-labels="dashboard.revenuePerDayLabels"
chart-series="series">
</canvas>
Pie Chart
<canvas id="doughnut" class="chart chart-pie"
chart-data="dashboard.weekVehicleRevenueData"
chart-labels="dashboard.weekVehicleRevenueLabels">
</canvas>