/********************************************* * Copyright (c) 2014 AnsibleWorks, Inc. */ /** * @ngdoc function * @name widgets.function:HostPieChart * @description * HostPieChart.js * * file for the host status pie chart * */ angular.module('HostPieChartWidget', ['RestServices', 'Utilities']) .factory('HostPieChart', ['$rootScope', '$compile', //'Rest', 'GetBasePath', 'ProcessErrors', 'Wait', function ($rootScope, $compile){ //, Rest, GetBasePath, ProcessErrors) { return function (params) { var scope = params.scope, target = params.target, dashboard = params.dashboard, html, element, data, canvas, context, winHeight, available_height, host_pie_chart; // html = "
' + Math.floor(y.replace(',','')) + ' Hosts ' + '
'; }) .color(['#60D66F', '#ff5850']); host_pie_chart.pie.pieLabelsOutside(true).labelType("percent"); d3.select(".host-pie-chart svg") .datum(data) .attr('width', width) .attr('height', height) .transition().duration(350) .call(host_pie_chart) .style({ "font-family": 'Open Sans', "font-style": "normal", "font-weight":400, "src": "url(/static/fonts/OpenSans-Regular.ttf)" }); // nv.utils.windowResize(host_pie_chart.update); scope.$emit('WidgetLoaded'); return host_pie_chart; }); } else{ winHeight = $(window).height(); available_height = winHeight - $('#main-menu-container .navbar').outerHeight() - $('#count-container').outerHeight() - 120; $('.graph-container:eq(1)').height(available_height/2); $('.host-pie-chart svg').replaceWith(''); canvas = document.getElementById("circlecanvas"); context = canvas.getContext("2d"); context.arc(55, 55, 50, 0, Math.PI * 2, false); context.lineWidth = 1; context.strokeStyle = '#1778c3'; context.stroke(); context.font = "12px Open Sans"; context.fillText("No Host data",18,55); scope.$emit('WidgetLoaded'); } }; } ]);