Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can access the current transformation matrix of a panel via the <code>transform</code> parameter. So, in the following example:</p> <pre><code>var vis = new pv.Panel() .width(200) .height(200); var panel = vis.add(pv.Panel) .event("mousewheel", pv.Behavior.zoom(1)) .fillStyle('#ccc'); var dot = panel.add(pv.Dot) .data([[25,25],[25,75],[75,25],[75,75]]) .top(function(d) d[0]) .left(function(d) d[1]) .size(30) .fillStyle('#999'); vis.render(); </code></pre> <p>If you load this example, then zoom around a bit, you can access the current transformation matrix like this:</p> <pre><code>var t = panel.transform(), tk = t.k, // scale factor, applied before x/y tx = t.x, // x-offset ty = t.y; // y-offset </code></pre> <p>You should be able to determine whether a child mark (e.g., in this example, <code>dot</code>) is in the visible area by applying the transformation matrix to its <code>top</code> and <code>left</code> parameters and then checking to see whether they're within the panel's original bounding box (0,0,200,200). For the <code>dot</code> above, you could check like this:</p> <pre><code>function(d) { var t = panel.transform(), // assuming the current dot instance is accessible as "this" x = (this.left() + t.x) * t.k, // apply transform to dot x position y = (this.top() + t.y) * t.k; // apply transform to dot y position // check bounding box. Note that this is a little simplistic - // I'm just checking dot center, not edges return x &gt; panel.left() &amp;&amp; x &lt; (panel.left() + panel.width()) &amp;&amp; y &gt; panel.top() &amp;&amp; y &lt; (panel.top() + panel.height()); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload