86 lines
3.4 KiB
Plaintext
86 lines
3.4 KiB
Plaintext
<div class="graph-container form-group-margin" id="class-pie-container" style="min-height:260px">
|
|
<div id="class-pie"></div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
var _dataForPie;
|
|
function DrawPie() {
|
|
if (!_dataForPie) {
|
|
if ($('#chkShowChart').is(":checked")) {
|
|
LoadPieData();
|
|
}
|
|
return;
|
|
}
|
|
var data = new Array();
|
|
var sum = 0;
|
|
var i;
|
|
var title;
|
|
if ($('#pieModeForecast').prop('checked')) {
|
|
for (i = 0; i < _dataForPie.length; i++) {
|
|
data.push({ label: _dataForPie[i].Label, data: _dataForPie[i].Cost });
|
|
sum += _dataForPie[i].Cost;
|
|
}
|
|
title = '$' + sum.formatNumber();
|
|
} else {
|
|
for (i = 0; i < _dataForPie.length; i++) {
|
|
data.push({ label: _dataForPie[i].Label, data: _dataForPie[i].Time });
|
|
sum += _dataForPie[i].Time;
|
|
}
|
|
title = sum + ' weeks';
|
|
}
|
|
|
|
// Init Chart
|
|
$('#class-pie-container').html('<div id="class-pie"></div>');
|
|
$('#class-pie').pixelPlot(data, {
|
|
series: {
|
|
pie: {
|
|
show: true,
|
|
radius: 1,
|
|
innerRadius: 0.5,
|
|
label: {
|
|
threshold: 0.01,
|
|
show: true,
|
|
radius: 3 / 4,
|
|
formatter: function (label, series) {
|
|
return '<div style="font-size:14px;text-align:center;padding:2px;color:white;">' + Math.round(series.percent) + '%</div>';
|
|
},
|
|
background: { opacity: 0 }
|
|
}
|
|
}
|
|
},
|
|
grid: {
|
|
hoverable: true,
|
|
clickable: true
|
|
}
|
|
}, {
|
|
height: 205
|
|
}).bind("plotclick", function (event, pos, obj) {
|
|
if (!obj) {
|
|
return;
|
|
}
|
|
if (obj.seriesIndex == null || _dataForPie.length <= obj.seriesIndex)
|
|
return;
|
|
$('#filterClassification').val(_dataForPie[obj.seriesIndex].TypeId);
|
|
if (typeof applyForecastDashboardFilter === 'function')
|
|
applyForecastDashboardFilter(!$('#pieReload').is(":checked"));
|
|
});
|
|
var center = $('<div class="pie-title">' + title + '</div>');
|
|
if (sum > 999999999)
|
|
center.css('font-size', 'smaller');
|
|
$('#class-pie').append(center);
|
|
if (typeof redrawFreezeColumn === 'function')
|
|
redrawFreezeColumn();
|
|
}
|
|
|
|
function LoadPieData() {
|
|
if ($('#chkShowChart').is(":checked") && _dataForPie == null) {
|
|
$('#class-pie-container').html('<div id="class-pie"><span class="control-label" style="margin-left: 10px;"><img src="@Url.Content("~/Content/images/load.gif")" /> loading...</span></div>');
|
|
var url = "/ForecastDashboard/GetClassPieData" + '?startDate=' + $('#filterStartDate').val() + '&endDate=' + $('#filterEndDate').val() + '&isLaborMode=' + $('#expendituresMode').prop('checked') + '&additionalParams=' + $('#' + _additionalFiltersId).val();
|
|
var request = {};
|
|
|
|
$.get(url, request, function (data) {
|
|
_dataForPie = data;
|
|
DrawPie();
|
|
});
|
|
}
|
|
}
|
|
</script> |