Created
December 29, 2021 03:19
Revisions
-
cupOJoseph created this gist
Dec 29, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ ChartJS Pie ----------- A [Pen](https://codepen.io/jschiarizzi/pen/LYzQPQb) by [Joseph Schiarizzi](https://codepen.io/jschiarizzi) on [CodePen](https://codepen.io). [License](https://codepen.io/jschiarizzi/pen/LYzQPQb/license). This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ <div id="canvas-holder"> <canvas id="chart-area"></canvas> </div> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,57 @@ var randomScalingFactor = function() { return Math.round(Math.random() * 100); }; var config = { type: 'pie', data: { datasets: [{ data: [ 53, 20, 15, 8, 4, ], backgroundColor: [ '#8EB5F0', '#3A79AB', '#3265D3', '#3D4273', '#598BFE', ], label: 'Contratos' }], labels: [ 'DAO Treasury [Reserve]', 'Mainnet Airdrop', 'Member Airdrop', 'DAO Treasury [Liquidity Incentives]', 'DAO Treasury [Artist Rewards]' ] }, options: { responsive: true, maintainAspectRatio: false, legend: { fullWidth: false, onClick(e, {index}) { alert(index); } }, layout: { padding: 0 } } }; var chart; window.onload = function() { var ctx = document.getElementById('chart-area').getContext('2d'); chart = new Chart(ctx, config); chart.canvas.parentNode.style.width = '100vw'; chart.canvas.parentNode.style.height = '100vw'; window.myPie = chart; }; This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.js"></script> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ #canvas-holder canvas { width: 50vw !important; height: 50vw !important; }