瀏覽代碼

Add chart variables (#6107)

AlexC 3 年之前
父節點
當前提交
c848c95d4f
共有 1 個文件被更改,包括 23 次插入0 次删除
  1. 23 0
      core/dashboard/index.php

+ 23 - 0
core/dashboard/index.php

@@ -96,6 +96,29 @@
 //include chart.js
 	echo "<script src='/resources/chartjs/chart.min.js'></script>";
 
+//chart variables
+	?>
+	<script>
+		var chart_font_family = 'Arial';
+		var chart_font_size = '30';
+		var chart_font_color = '#444';
+		var chart_cutout = '75%';
+
+		const chart_counter = {
+			id: 'chart_counter',
+			beforeDraw(chart, args, options){
+				const {ctx, chartArea: {top, right, bottom, left, width, height} } = chart;
+				ctx.font = chart_font_size + 'px ' + chart_font_family;
+				ctx.textBaseline = 'middle';
+				ctx.textAlign = 'center';
+				ctx.fillStyle = chart_font_color;
+				ctx.fillText(options.chart_text, width / 2, top + (height / 2));
+				ctx.save();
+			}
+		};
+	</script>
+	<?php
+
 //start the content
 	/*
 	echo "<table cellpadding='0' cellspacing='0' border='0' width='100%'>\n";