# Class: BaseWidget

## LocusZoom_Widgets~BaseWidget(parent)

A widget is an empty div rendered on a toolbar that can display custom html of user interface elements.

## Constructor

#### new BaseWidget(parent)

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`layout.position` | 'left' | 'right' | <optional> | 'left' | Whether to float the widget left or right.
`layout.group_position` | 'start' | 'middle' | 'end' | <optional> |  | Buttons can optionally be gathered into a visually distinctive group whose elements are closer together. If a button is identified as the start or end of a group, it will be drawn with rounded corners and an extra margin of spacing from any button not part of the group. For example, the region_nav_plot toolbar is a defined as a group.
`layout.color` | 'gray' | 'red' | 'orange' | 'yellow' | 'green' | 'blue' | 'purple' | <optional> | 'gray' | Color scheme for the widget. Applies to buttons and menus.
`layout.style` |  | <optional> |  | CSS styles that will be applied to the widget
`parent` | Toolbar |  |  | The toolbar that contains this widget

Source:
  - components/toolbar/widgets.js, line 19

### Members

#### button :null|Button

If this is an interactive widget, it will contain a button or menu instance that handles the interactivity. There is a 1-to-1 relationship of toolbar widget to button

##### Type:

- null | Button

Source:
  - components/toolbar/widgets.js, line 70

#### layout :Object

##### Type:

- Object

Source:
  - components/toolbar/widgets.js, line 33

#### parent :Toolbar|*

##### Type:

- Toolbar | *

Source:
  - components/toolbar/widgets.js, line 39

#### parent_panel :Panel|null

Some widgets are attached to a panel, rather than directly to a plot

##### Type:

- Panel | null

Source:
  - components/toolbar/widgets.js, line 44

#### parent_plot :Plot

##### Type:

- Plot

Source:
  - components/toolbar/widgets.js, line 46

#### parent_svg :Plot|Panel

This is a reference to either the panel or the plot, depending on what the toolbar is tied to. Useful when absolutely positioning toolbar widgets relative to their SVG anchor.

##### Type:

- Plot | Panel

Source:
  - components/toolbar/widgets.js, line 52

#### (protected) persist :Boolean

If any single widget is marked persistent, it will bubble up to prevent automatic hide behavior on a widget's parent toolbar. Check via `shouldPersist`

##### Type:

- Boolean

Source:
  - components/toolbar/widgets.js, line 77

#### selector :d3.selection

##### Type:

- d3.selection

Source:
  - components/toolbar/widgets.js, line 64

### Methods

#### destroy(forceopt) → {Toolbar}

Completely remove widget and button. (may be overridden by persistence settings)

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`force` | Boolean | <optional> | false | If true, will ignore persistence settings and always destroy the toolbar

Source:
  - components/toolbar/widgets.js, line 159

##### Returns:

Type
  Toolbar

#### hide() → {BaseWidget}

Toggle visibility to hidden, unless marked as persistent

Source:
  - components/toolbar/widgets.js, line 143

##### Returns:

Type
  BaseWidget

#### position() → {BaseWidget}

Place the widget correctly in the plot

Source:
  - components/toolbar/widgets.js, line 121

##### Returns:

Type
  BaseWidget

#### shouldPersist() → {boolean}

Determine whether the widget should persist (will bubble up to parent toolbar)

Source:
  - components/toolbar/widgets.js, line 132

##### Returns:

Type
  boolean

#### show()

Perform all rendering of widget, including toggling visibility to true. Will initialize and create SVG element if necessary, as well as updating with new data and performing layout actions.

Source:
  - components/toolbar/widgets.js, line 87

#### update()

Update the toolbar widget with any new data or plot state as appropriate. This method performs all necessary rendering steps.

Source:
  - components/toolbar/widgets.js, line 114