# Limiting data by brush with Vega-Lite API

**URL:** <https://talk.observablehq.com/t/limiting-data-by-brush-with-vega-lite-api/3207>\
**Category:** Help\
**Created:** [May 1, 2020, 7:35pm UTC](https://talk.observablehq.com/t/limiting-data-by-brush-with-vega-lite-api/3207 "2020-05-01T19:35:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kpm-at-hfi](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/kpm-at-hfi/32/4155_2.png) [@kpm-at-hfi](https://talk.observablehq.com/u/kpm-at-hfi)\
**Post date:** [May 1, 2020, 7:35pm UTC](https://talk.observablehq.com/t/limiting-data-by-brush-with-vega-lite-api/3207/1 "2020-05-01T19:35:25Z")

</div>

[Here’s an example on Observable](https://observablehq.com/@kpm-at-hfi/limiting-data-by-brush) that I’ve roughly gleaned from the _Navigation: Overview + Detail_ example on [UW Interactive Data Lab’s _Interaction_](https://observablehq.com/@uwdata/interaction?collection=@uwdata/visualization-curriculum) page.

This works fine, but I’d like to add the feature of having the data flowing into the `display` chart “limited” or “cropped” by the `brush` selection such that the legend on the right would only list entries for what’s in the `display` chart.

Any thoughts on how I might do that? I have tried various things, but none have worked. I think that if I better understood how to transpose between Vega-Lite API and Vega-Lite JSON, I might be able to self-serve from the more robust Vega-Lite docs.

---

<div class="post-metadata">

**Author:** ![kpm-at-hfi](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/kpm-at-hfi/32/4155_2.png) [@kpm-at-hfi](https://talk.observablehq.com/u/kpm-at-hfi)\
**Post date:** [May 7, 2020, 3:54pm UTC](https://talk.observablehq.com/t/limiting-data-by-brush-with-vega-lite-api/3207/2 "2020-05-07T15:54:08Z")

</div>

Solved… essentially, the solution was `.transform(vl.filter(brush))` but I have [an explanation and some wonderings on JSON vs API on the notebook](https://observablehq.com/@kpm-at-hfi/limiting-data-by-brush).
