compiled = {
let {
fx,
fy,
x: {value: xValue, zero: xZero},
y: {value: yValue, zero: yZero},
color: {value: colorValue},
size: {value: sizeValue},
markImpl,
markOptions,
transformImpl,
transformOptions,
colorMode
} = evalImpl;
if (typeof xValue === "string") markOptions.x = xValue;
else if (xValue) markOptions.x.value = xValue;
if (typeof yValue === "string") markOptions.y = yValue;
else if (yValue) markOptions.y.value = yValue;
if (typeof colorValue === "string") markOptions[colorMode] = colorValue;
else if (colorValue) markOptions[colorMode].value = colorValue;
if (typeof sizeValue === "string") markOptions.size = sizeValue;
else if (sizeValue) markOptions.size.value = sizeValue;
const markOptionsString = transformImpl
? `Plot.${transformImpl.name}(${JSON.stringify(transformOptions)}, ${JSON.stringify(markOptions)})`
: JSON.stringify(markOptions);
const frame = fx != null || fy != null ? `Plot.frame({strokeOpacity: 0.1})` : null;
const rules = [xZero ? `Plot.ruleX([0])` : null, yZero ? `Plot.ruleY([0])` : null];
const mark = `Plot.${markImpl.name}(data, ${markOptionsString})`;
return `Plot.plot({
marks: [
${(colorMode === "stroke" ? [frame, ...rules, mark] : [frame, mark, ...rules])
.filter((mark) => mark)
.join(",\n ")}
]
})`;
}