function makeLegend(variable) {
let legendData = [];
if (variable === "gluten") {
legendData = [
{ label: "I do not eat gluten because it makes me feel bad", color: "#66c2a5" },
{ label: "No", color: "#fc8d62" },
{ label: "I was diagnosed with celiac disease", color: "#8da0cb" },
{ label: "I was diagnosed with gluten allergy (anti-gluten IgG), but not celiac disease", color: "#e78ac3" }
];
} else if (variable === "lactose") {
legendData = [
{ label: "true", color: "#1f78b4" },
{ label: "false", color: "#a6cee3" }
];
} else if (variable === "multivitamin") {
legendData = [
{ label: "true", color: "#1f78b4" },
{ label: "false", color: "#a6cee3" }
];
}
return html`
<div style="margin-top: 10px; margin-bottom: 20px;">
<h5>Legend for ${variable.charAt(0).toUpperCase() + variable.slice(1)}</h5>
<svg width="150" height="${legendData.length * 20}">
${legendData.map((entry, index) => svg`
<rect x="0" y="${index * 20}" width="15" height="15" fill="${entry.color}" />
<text x="20" y="${(index * 20) + 12}" font-size="12">${entry.label}</text>
`)}
</svg>
</div>
`;
}