From dc22f6e57127326ddaa9c595525fe9ee4bd11bf4 Mon Sep 17 00:00:00 2001 From: Travis Raup Date: Tue, 14 Feb 2023 21:01:20 -0500 Subject: [PATCH] chart update --- package.json | 2 + public/viewjs/metrics.js | 80 +++++++++++++++++++-------- views/layout/default.blade.php | 1 - views/stockmetricspurchases.blade.php | 14 ++++- yarn.lock | 17 ++++-- 5 files changed, 81 insertions(+), 33 deletions(-) diff --git a/package.json b/package.json index 312f77ee..9d9ce9ff 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,8 @@ "bwip-js": "^3.0.1", "canvasjs": "^1.8.3", "chart.js": "^2.8.0", + "chartjs-plugin-doughnutlabel": "^2.0.3", + "chartjs-plugin-piechart-outlabels": "^0.1.4", "datatables.net": "^1.10.22", "datatables.net-bs4": "^1.10.22", "datatables.net-colreorder": "^1.5.2", diff --git a/public/viewjs/metrics.js b/public/viewjs/metrics.js index 3dc85807..27caeb26 100644 --- a/public/viewjs/metrics.js +++ b/public/viewjs/metrics.js @@ -3,36 +3,70 @@ */ /* Charting */ -var dataPoints = []; +var labels = []; +var data = []; $("#metrics-table tbody tr").each(function () { var self = $(this); var label = self.find("td:eq(0)").attr('data-chart-label'); var value = Number(self.find("td:eq(1)").attr('data-chart-value')); - var dataPoint = { label: label, y: parseFloat((Math.round(value * 100) / 100).toFixed(2))}; - dataPoints.push(dataPoint); + labels.push(label); + data.push(parseFloat((Math.round(value * 100) / 100).toFixed(2))); }); -var options = { - exportEnabled: true, - legend:{ - horizontalAlign: "center", - verticalAlign: "bottom" - }, - data: [{ - type: "pie", - showInLegend: true, - toolTipContent: "{label}: ${y} (#percent%)", - indexLabel: "{label}", - legendText: "{label} (#percent%)", - indexLabelPlacement: "outside", - valueFormatSTringt: "#,##0.##", - dataPoints: dataPoints - }] -}; +function getRandomColor() { + var letters = '0123456789ABCDEF'.split(''); + var color = '#'; + for (var i = 0; i < 6; i++ ) { + color += letters[Math.floor(Math.random() * 16)]; + } + return color; +} + +var colors=[]; +for(let i=0;i - diff --git a/views/stockmetricspurchases.blade.php b/views/stockmetricspurchases.blade.php index 6a3f326f..6642ff50 100644 --- a/views/stockmetricspurchases.blade.php +++ b/views/stockmetricspurchases.blade.php @@ -2,7 +2,15 @@ @section('title', $__t('Stock Metrics: Purchases')) @section('activeNav', 'stockmetricspurchases') -@section('viewJsName', 'metrics') + +@once + @push('componentScripts') + + + + + @endpush +@endonce @section('content')
@@ -83,8 +91,8 @@
-
-
+
+
=1.10: - version "3.6.3" - resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.6.3.tgz#23ed2ffed8a19e048814f13391a19afcdba160e6" - integrity sha512-bZ5Sy3YzKo9Fyc8wH2iIQK4JImJ6R0GWI9kL1/k7Z91ZBNgkRXE6U0JfHIizZbort8ZunhSI3jw9I6253ahKfg== - -jquery@>=1.12.0, jquery@>=1.7, jquery@>=1.7.2, jquery@^3.6.0: +jquery@>=1.10, jquery@>=1.12.0, jquery@>=1.7, jquery@>=1.7.2, jquery@^3.6.0: version "3.6.3" resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.6.3.tgz#23ed2ffed8a19e048814f13391a19afcdba160e6" integrity sha512-bZ5Sy3YzKo9Fyc8wH2iIQK4JImJ6R0GWI9kL1/k7Z91ZBNgkRXE6U0JfHIizZbort8ZunhSI3jw9I6253ahKfg==