///// pie chart for the instructions //////////// const ctx1 = document.getElementById('pieChartInstructions').getContext('2d'); //// \D matches a character that is not a numerical digit. So any non digit is replaced by an empty string. The result is only the digits in a string. //// The g at the end of the regular expression literal is for "global" meaning that it replaces all matches, and not just the first. const p0 = document.getElementById('opp0').innerText.replace(/\D/g, ""); const p1 = document.getElementById('opp1').innerText.replace(/\D/g, ""); const p2 = document.getElementById('opp2').innerText.replace(/\D/g, ""); var pieChart1 = new Chart(ctx1,{ type:'pie', data: { labels: ['0 active other', '1 active other', '2 active others'], tooltips: { enabled: false }, datasets: [ { data: [p0, p1, p2], backgroundColor:['#F67280', '#6C5B7B', '#355C7D'], borderWidth:1 } ], options: { rotation: 180 } } });