Specifying x2 attribute for ruleY mark of barY Plot

This notebook illustrates the issue: barY Plot with x2 option of ruleY / Mario Delgado | Observable

When the x2 attribute is added to a ruleY marker (in an attempt to terminate it at a specific bar marker) the complete ruleY marker is not displayed.

Use the toggle to assign the x2 attribute and visualize the problem.

If you don’t give x1 nor x2 then the rule will span the whole chart. If you give x2, you’re saying where to stop, but not where to start. If you also specify x1, then it works:

x1: addX2 ? () => "E" : undefined,x2: addX2 ? letter : undefined,

1 Like

So, it behaves differently than the ruleX mark where it is sufficient to only specify the y2 attribute and the y1 attribute is automatically assigned.

Any thoughts on making the rule marks intersect when the ruleY is initiated from the right axis?:

it behaves differently than the ruleX mark

I think that the nuance is not ruleX vs ruleY, but the fact that the scale for x is ordinal (for a continuous scale, we can attribute a default x1 = 0).

making the rule marks intersect

the x scale is a band scale (because we’re drawing bars), so it has a bandwidth; you can eliminate it by adding

insetLeft: 9.5

It could be nice for this particular use case to have a mark option to ignore the bandwidth (or collapse it to zero).

1 Like