Fix nested backtick syntax bug killing entire JS runtime — build referral chart dataset as JS object not template literal

This commit is contained in:
Marty Bostick
2026-07-29 22:21:49 +00:00
parent 85854fcbd8
commit ec908668e8
+34 -14
View File
@@ -1765,27 +1765,47 @@ ${numPeople > 0 ? `
const chartLabels = chartData.map(d => `M${d.m}`); const chartLabels = chartData.map(d => `M${d.m}`);
const chartValues = chartData.map(d => d.cum); const chartValues = chartData.map(d => d.cum);
if (chart1) { chart1.destroy(); chart1 = null; } // Build referral dataset separately to avoid nested backtick issues
if (chart2) { chart2.destroy(); chart2 = null; } let referralDataset = null;
if (chart3) { chart3.destroy(); chart3 = null; } if (numPeople > 0) {
const label = numPeople > 1 ? `Total (${numPeople} people) Cumulative Referral Earnings` : 'Your Cumulative Referral Earnings';
const ctx1 = document.getElementById('profitChart').getContext('2d'); const data = numPeople > 1 ? chartValues.map(v => v * numPeople) : chartValues;
chart1 = new Chart(ctx1, { referralDataset = {
type: 'line', label: label,
data: { data: data,
labels: chartLabels,
datasets: [
${numPeople > 0 ? `{
label: `${numPeople > 1 ? `Total (${numPeople} people)` : 'Your'} Cumulative Referral Earnings`,
data: numPeople > 1 ? chartValues.map(v => v * numPeople) : chartValues,
borderColor: '#6c5ce7', borderColor: '#6c5ce7',
backgroundColor: 'rgba(108,92,231,0.1)', backgroundColor: 'rgba(108,92,231,0.1)',
fill: true, fill: true,
tension: 0.3, tension: 0.3,
pointRadius: 3, pointRadius: 3,
pointHoverRadius: 5, pointHoverRadius: 5,
},` : ''} };
}
if (chart1) { chart1.destroy(); chart1 = null; }
if (chart2) { chart2.destroy(); chart2 = null; }
if (chart3) { chart3.destroy(); chart3 = null; }
const datasets = [
{ {
label: 'Their Cumulative Profit',
data: chartProfitData.map(d => d.cum),
borderColor: '#00d2ff',
backgroundColor: 'rgba(0,210,255,0.1)',
fill: true,
tension: 0.3,
pointRadius: 3,
pointHoverRadius: 5,
},
referralDataset,
].filter(Boolean);
const ctx1 = document.getElementById('profitChart').getContext('2d');
chart1 = new Chart(ctx1, {
type: 'line',
data: {
labels: chartLabels,
datasets: datasets,
}, },
options: { options: {
responsive: true, responsive: true,