MCPcopy Create free account
hub / github.com/microsoft/SandDance / markBoundary

Function markBoundary

docs/app/js/sanddance-app.js:139119–139148  ·  view source on GitHub ↗

* Factory function for function for getting base mark boundary, depending * on mark and group type. When mark type is undefined, line or area: boundary * is the coordinate of each data point. When base mark is grouped line, * boundary is either at the beginning or end of the line depending on the

(marktype, grouptype, lineAnchor, markIndex)

Source from the content-addressed store, hash-verified

139117 * boundary is either at the beginning or end of the line depending on the
139118 * value of lineAnchor. Otherwise, use bounds of base mark.
139119 */ function markBoundary(marktype, grouptype, lineAnchor, markIndex) {
139120 const xy = (d)=>[
139121 d.x,
139122 d.x,
139123 d.x,
139124 d.y,
139125 d.y,
139126 d.y
139127 ];
139128 if (!marktype) return xy; // no reactive geometry
139129 else if (marktype === "line" || marktype === "area") return (d)=>xy(d.datum);
139130 else if (grouptype === "line") return (d)=>{
139131 const items = d.datum.items[markIndex].items;
139132 return xy(items.length ? items[lineAnchor === "start" ? 0 : items.length - 1] : {
139133 x: NaN,
139134 y: NaN
139135 });
139136 };
139137 else return (d)=>{
139138 const b = d.datum.bounds;
139139 return [
139140 b.x1,
139141 (b.x1 + b.x2) / 2,
139142 b.x2,
139143 b.y1,
139144 (b.y1 + b.y2) / 2,
139145 b.y2
139146 ];
139147 };
139148}
139149const Output = [
139150 "x",
139151 "y",

Callers 1

labelLayoutFunction · 0.70

Calls 1

xyFunction · 0.70

Tested by

no test coverage detected