> For the complete documentation index, see [llms.txt](https://antv.gitbook.io/f2/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://antv.gitbook.io/f2/api/chart/wip-scrollbar.md).

# ScrollBar

![](/files/-LJrh2sza9pk3jSS8QwZ)

ScrollBar is a plugin for pan and pinch interaction, it will show the current data range.

### How to Register ScrollBar Plugin

```javascript
const F2 = require('@antv/f2/lib/index');
const ScrollBar = require('@antv/f2/lib/plugin/scroll-bar');

// register ScrollBar
F2.Chart.plugins.register(ScrollBar); 

// another way for register ScrollBar
const chart = new F2.Chart({
  id: 'canvas',
  plugins: ScrollBar
});
```

After register the ScrollBar, the method \`chart.scrollBar()\` can be called.

```javascript
chart.scrollBar({
  // some configuration
});
```

### Configuration

| Name     | Type   | Default     | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| -------- | ------ | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `mode`   | String | 'x'         | The direction of the scroll bar, optional value includes 'x', 'y', 'xy'.                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `xStyle` | Object | `see below` | <p>The style for scroll bar in  x direction:  </p><ul><li><code>backgroundColor</code>: the background color for scroll bar</li><li><code>fillerColor</code>: the color for range bar</li><li><code>size</code>:  the size of scroll bar</li><li><code>lineCap</code>: determines how the end points in a line are drawn</li><li><code>offsetX</code>: the offset value of scroll bar in x-axis direction</li><li><code>offsetY</code>: the offset value of scroll bar in y-axis direction</li></ul> |
| `yStyle` | Obect  | see below   | <p>The style for scroll bar in y direction: </p><ul><li><code>backgroundColor</code>: the background color for scroll bar</li><li><code>fillerColor</code>: the color for range bar</li><li><code>size</code>: the size of scroll bar</li><li><code>lineCap</code>: determines how the end points in a line are drawn</li><li><code>offsetX</code>: the offset value of scroll bar in x-axis direction</li><li><code>offsetY</code>: the offset value of scroll bar in y-axis direction</li></ul>    |

* `xStyle` default value:

```javascript
{
    backgroundColor: 'rgba(202, 215, 239, .2)',
    fillerColor: 'rgba(202, 215, 239, .5)',
    size: 4,
    lineCap: 'round',
    offsetX: 0,
    offsetY: 8
}
```

* `yStyle` default value:

```javascript
{
    backgroundColor: 'rgba(202, 215, 239, .2)',
    fillerColor: 'rgba(202, 215, 239, .5)',
    size: 4,
    lineCap: 'round',
    offsetX: 8,
    offsetY: 0
}
```

Example:

* [pan for line chart](https://antv.alipay.com/zh-cn/f2/3.x/demo/interaction/pan-for-line-chart.html)
