MCPcopy Index your code
hub / github.com/plotly/plotly.js / selectMarkers

Function selectMarkers

src/traces/scatter/plot.js:623–663  ·  view source on GitHub ↗
(gd, idx, plotinfo, cdscatter, cdscatterAll)

Source from the content-addressed store, hash-verified

621}
622
623function selectMarkers(gd, idx, plotinfo, cdscatter, cdscatterAll) {
624 var xa = plotinfo.xaxis;
625 var ya = plotinfo.yaxis;
626 var xr = d3.extent(Lib.simpleMap(xa.range, xa.r2c));
627 var yr = d3.extent(Lib.simpleMap(ya.range, ya.r2c));
628
629 var trace = cdscatter[0].trace;
630 if(!subTypes.hasMarkers(trace)) return;
631 // if marker.maxdisplayed is used, select a maximum of
632 // mnum markers to show, from the set that are in the viewport
633 var mnum = trace.marker.maxdisplayed;
634
635 // TODO: remove some as we get away from the viewport?
636 if(mnum === 0) return;
637
638 var cd = cdscatter.filter(function(v) {
639 return v.x >= xr[0] && v.x <= xr[1] && v.y >= yr[0] && v.y <= yr[1];
640 });
641 var inc = Math.ceil(cd.length / mnum);
642 var tnum = 0;
643 cdscatterAll.forEach(function(cdj, j) {
644 var tracei = cdj[0].trace;
645 if(subTypes.hasMarkers(tracei) &&
646 tracei.marker.maxdisplayed > 0 && j < idx) {
647 tnum++;
648 }
649 });
650
651 // if multiple traces use maxdisplayed, stagger which markers we
652 // display this formula offsets successive traces by 1/3 of the
653 // increment, adding an extra small amount after each triplet so
654 // it's not quite periodic
655 var i0 = Math.round(tnum * inc / 3 + Math.floor(tnum / 3) * inc / 7.1);
656
657 // for error bars: save in cd which markers to show
658 // so we don't have to repeat this
659 cdscatter.forEach(function(v) { delete v.vis; });
660 cd.forEach(function(v, i) {
661 if(Math.round((i + i0) % inc) === 0) v.vis = true;
662 });
663}

Callers 1

plotOneFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…