Plot conditional control over marks?

This there a way to have to plots conditional?

I have a check box the returns a flag but I can’t work out how to get the marks conditional.

The statement I have:

marks: [
    Plot.ruleY([120]), Plot.ruleX([-80]),
    Plot.link(data.lines, {x1: "x1", y1: "y1", x2: "x2", y2: "y2", stroke: "rgba(0,0,0,.03)"}),
    Plot.dot(data.head, dotOptions),
   ]

I tried:

Plot.link(() => (check=='yes')?data.lines:null, {x1: "x1", y1: "y1", x2: "x2", y2: "y2", stroke: "rgba(0,0,0,.03)"}),
// and
Plot.link(data.lines, () => (check=='yes')?{x1: "x1", y1: "y1", x2: "x2", y2: "y2", stroke: "rgba(0,0,0,.03)"},{}),

But no luck.

you could try two things: one, have as data:

Plot.link((check==‘yes’) ? data.lines : , options)

the second, to remove the mark altogether:

check==‘yes’ ? Plot.link(data.lines, options) :

let me know if this works for you

1 Like

Thanks, I was not checking my array correctly as checkboxes uses arrays, so I needed to do

(check.includes('Yes'))?data.lines:[],options

Perhaps you want to use Inputs.toggle instead, since it returns a Boolean?

1 Like

I always forget this one too.

I had more that one condition so used checkboxes here.