<h3 class="text-center" style="margin:30px 0px 30px;">Рентабельность сделок</h3>

<div class="chart-container" style="position: relative; height:40vh; width:100%; margin-bottom:20px;">
	<canvas id="ChartProfit"></canvas>
</div>
<script>
var ctx = document.getElementById("ChartProfit").getContext('2d');
var ChartProfit = new Chart(ctx, {
	type: 'line',
	data: {
		labels: ["<?php echo date("Y",strtotime("- 4 years")); ?>", "<?php echo date("Y",strtotime("- 3 years")); ?>", "<?php echo date("Y",strtotime("- 2 years")); ?>", "<?php echo date("Y",strtotime("- 1 years")); ?>", "<?php echo date("Y"); ?>"],
		datasets: [{
			label: 'Рентабельность %',
			data: [ 
				<?php echo profit_year('deal', 'ac', '4'); ?>,
				<?php echo profit_year('deal', 'ac', '3'); ?>,
				<?php echo profit_year('deal', 'ac', '2'); ?>,
				<?php echo profit_year('deal', 'ac', '1'); ?>,
				<?php echo profit_year('deal', 'ac', '0'); ?>
				],
			backgroundColor: [ 'rgba(89,149,219, 0.25)' ],
			borderColor: 'rgba(89,149,219, 1.0)',
			borderWidth: 2,
			tension: 0,
			pointStyle: 'circle',
			pointRadius: 3,
			pointBackgroundColor: '#337ab7'
		},{
			label: 'Расходы %',
			data: [ 
				-<?php echo profit_year('cost', 'ac', '4'); ?>,
				-<?php echo profit_year('cost', 'ac', '3'); ?>,
				-<?php echo profit_year('cost', 'ac', '2'); ?>,
				-<?php echo profit_year('cost', 'ac', '1'); ?>,
				-<?php echo profit_year('cost', 'ac', '0'); ?>
				],
			backgroundColor: [ 'rgba(219, 90, 89, 0.25)' ],
			borderColor: 'rgba(219, 90, 89, 1.0)',
			borderWidth: 2,
			tension: 0,
			pointStyle: 'circle',
			pointRadius: 3,
			pointBackgroundColor: 'rgba(219, 90, 89, 1.0)'
		}],
	},
	options: {
		scales: {
			yAxes: [{
				ticks: {
					beginAtZero:true
				}
			}]
		},
		responsive: true,
		maintainAspectRatio: false,
		legend: {
			position: 'bottom'
		}
	}
});
</script>
<h4 class="text-center" style="margin:30px 0px 10px;">Рентабельность за текущий год составила <?php echo profit_year('deal', 'ac', '0'); ?>%</h3>
<h4 class="text-center" style="margin:10px 0px 30px;">( за все время - <?php if($StatPrice > 0){echo round($StatProfit / $StatPrice * 100 , 1);} else {echo '0';} ?>% )</h3>