Fix nested backtick syntax bug killing entire JS runtime — build referral chart dataset as JS object not template literal
This commit is contained in:
+34
-14
@@ -1765,27 +1765,47 @@ ${numPeople > 0 ? `
|
||||
const chartLabels = chartData.map(d => `M${d.m}`);
|
||||
const chartValues = chartData.map(d => d.cum);
|
||||
|
||||
if (chart1) { chart1.destroy(); chart1 = null; }
|
||||
if (chart2) { chart2.destroy(); chart2 = null; }
|
||||
if (chart3) { chart3.destroy(); chart3 = null; }
|
||||
|
||||
const ctx1 = document.getElementById('profitChart').getContext('2d');
|
||||
chart1 = new Chart(ctx1, {
|
||||
type: 'line',
|
||||
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,
|
||||
// Build referral dataset separately to avoid nested backtick issues
|
||||
let referralDataset = null;
|
||||
if (numPeople > 0) {
|
||||
const label = numPeople > 1 ? `Total (${numPeople} people) Cumulative Referral Earnings` : 'Your Cumulative Referral Earnings';
|
||||
const data = numPeople > 1 ? chartValues.map(v => v * numPeople) : chartValues;
|
||||
referralDataset = {
|
||||
label: label,
|
||||
data: data,
|
||||
borderColor: '#6c5ce7',
|
||||
backgroundColor: 'rgba(108,92,231,0.1)',
|
||||
fill: true,
|
||||
tension: 0.3,
|
||||
pointRadius: 3,
|
||||
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: {
|
||||
responsive: true,
|
||||
|
||||
Reference in New Issue
Block a user