# Global

##

### Methods

#### clone(data) → {*}

The "just-clone" library only really works for objects and arrays. If given a string, it would mess things up quite a lot.

##### Parameters:

Name | Type | Description
--- | --- | ---
`data` | object |

Source:
  - data/undercomplicate/util.js, line 12

##### Returns:

Type
  *

#### getLinkedData(shared_options, entities, dependencies, consolidateopt) → {Promise.<Array.<Object>>}

Perform a request for data from a set of providers, taking into account dependencies between requests. This can be a mix of network requests or other actions (like join tasks), provided that the provider be some object that implements a method `instance.getData`

Each data layer in LocusZoom will translate the internal configuration into a format used by this function. This function is never called directly in custom user code. In locuszoom, Requester Handles You

TODO Future: It would be great to add a warning if the final element in the DAG does not reference all dependencies. This is a limitation of the current toposort library we use.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`shared_options` | object |  |  | Options passed globally to all requests. In LocusZoom, this is often a copy of "plot.state"
`entities` | Map |  |  | A lookup of named entities that implement the method `instance.getData -> Promise`
`dependencies` | Array.<String> |  |  | A description of how to fetch entities, and what they depend on, like `['assoc', 'ld(assoc)']`. Order will be determined by a DAG and the last item in the DAG is all that is returned.
`consolidate` | boolean | <optional> | true | Whether to return all results (almost never used), or just the last item in the resolved DAG. This can be a pitfall in common usage: if you forget a "join/consolidate" task, the last result may appear to be missing some data.

Source:
  - data/undercomplicate/requests.js, line 43

##### Returns:

Type
  Promise.<Array.<Object>>

### Type Definitions

#### eventCallback(eventData)

##### Parameters:

Name | Type | Description
--- | --- | ---
`eventData` | object | A description of the event ###### Properties
Name | Type | Description
--- | --- | ---
`sourceID` | String | null | The unique identifier (eg plot or parent name) of the element that triggered the event. Will be automatically filled in if not explicitly provided.
`context` | Object | null | Any additional information to be passed to the callback, eg the data associated with a clicked plot element

Source:
  - components/plot.js, line 332

#### externalDataCallback(new_data, plot)

A user-defined callback function that can receive (and potentially act on) new plot data.

##### Parameters:

Name | Type | Description
--- | --- | ---
`new_data` | Object | The body resulting from a data request. This represents the same information that would be passed to a data layer making an equivalent request.
`plot` | Object | A reference to the plot object. This can be useful for listeners that react to the structure of the data, instead of just displaying something.

Source:
  - components/plot.js, line 624

#### externalErrorCallback(err)

A user-defined callback function that can respond to errors received during a previous operation

##### Parameters:

Name | Type | Description
--- | --- | ---
`err` |  | A representation of the error that occurred

Source:
  - components/plot.js, line 633

### Events

#### any_lz_event

Fields common to every event emitted by LocusZoom. This is not an actual event that should ever be used directly; see list below.

Note: plot-level listeners can be defined for this event, but you should almost never do this. Use the most specific event name to describe the thing you are interested in.

Listening to 'any_lz_event' is only for advanced usages, such as proxying (repeating) LZ behavior to a piece of wrapper code. One example is converting all LocusZoom events to vue.js events.

##### Type:

- object

##### Properties:

Name | Type | Description
--- | --- | ---
`sourceID` | string | The fully qualified ID of the entity that originated the event, eg `lz-plot.association`
`target` | Plot | Panel | A reference to the plot or panel instance that originated the event.
`data` | object | null | Additional data provided. (see event-specific documentation)

Source:
  - components/plot.js, line 33

#### data_from_layer

One particular data layer has completed a request for data. This event is primarily used internally by the `subscribeToData` function, and the syntax may change in the future.

##### Properties:

Name | Type | Description
--- | --- | ---
`data` | object | ###### Properties
Name | Type | Description
--- | --- | ---
`layer` | String | The fully qualified ID of the layer emitting this event
`content` | Array.<Object> | The data used to draw this layer: an array where each element represents one row/ datum element. It reflects all namespaces and data operations used by that layer.

Source:
  - components/plot.js, line 69
See:
  - event:any_lz_event

##### Listeners of This Event:

- Plot#subscribeToData

#### data_rendered

A request for new data has completed, and all data has been rendered in the plot.

Source:
  - components/plot.js, line 63
See:
  - event:any_lz_event

##### Listeners of This Event:

- Panel#addBasicLoader
- Plot#subscribeToData

#### data_requested

A request for new or cached data was initiated. This can be used for, eg, showing data loading indicators.

Source:
  - components/plot.js, line 57
See:
  - event:any_lz_event

##### Listeners of This Event:

- Panel#addBasicLoader

#### element_clicked

Indicates whether an element was clicked. (regardless of the behavior associated with clicking)

Source:
  - components/plot.js, line 117
See:
  - event:element_selection for a more specific and more frequently useful event
  - event:any_lz_event

#### element_selection

Indicate whether the element was selected (or unselected)

##### Properties:

Name | Type | Description
--- | --- | ---
`data` | object | An object with keys { element, active }, representing the datum bound to the element and the selection status (boolean)

Source:
  - components/plot.js, line 108
See:
  - event:element_clicked if you are interested in tracking clicks that result in other behaviors, like links
  - event:any_lz_event

#### layout_changed

An action occurred that changed, or could change, the layout. Many rerendering operations can fire this event and it is somewhat generic: it includes resize, highlight, and rerender on new data. Caution: Direct layout mutations might not be captured by this event. It is deprecated due to its limited utility.

Deprecated:
  - Yes
Source:
  - components/plot.js, line 80
See:
  - event:any_lz_event

#### match_requested

Indicate whether a match was requested from within a data layer.

##### Properties:

Name | Type | Description
--- | --- | ---
`data` | object | An object of `{value, active}` representing the scalar value to be matched and whether a match is being initiated or canceled

Source:
  - components/plot.js, line 124
See:
  - event:any_lz_event

##### Listeners of This Event:

- Plot#applyState

#### panel_removed

A panel was removed from the plot. Commonly initiated by the "remove panel" toolbar widget.

##### Properties:

Name | Type | Description
--- | --- | ---
`data` | string | The id of the panel that was removed (eg 'genes')

Source:
  - components/plot.js, line 50
See:
  - event:any_lz_event

#### region_changed

The plot region has changed. Reports the actual coordinates of the plot after the zoom event. If plot.applyState is called with an invalid region (eg zooming in or out too far), this reports the actual final coordinates, not what was requested. The actual coordinates are subject to region min/max, etc.

##### Properties:

Name | Type | Description
--- | --- | ---
`data` | object | The {chr, start, end} coordinates of the requested region.

Source:
  - components/plot.js, line 99
See:
  - event:any_lz_event

#### set_ldrefvar

A new LD reference variant has been selected (usually by clicking within a GWAS scatter plot) This event only fires for manually selected variants. It does not fire if the LD reference variant is automatically selected (eg by choosing the most significant hit in the region)

##### Properties:

Name | Type | Description
--- | --- | ---
`data` | object | { ldrefvar } The variant identifier of the LD reference variant

Source:
  - components/data_layer/scatter.js, line 420
See:
  - event:any_lz_event

#### state_changed

The user has requested any state changes, eg via `plot.applyState`. This reports the original requested values even if they are overridden by plot logic. Only triggered when a state change causes a re-render.

##### Properties:

Name | Type | Description
--- | --- | ---
`data` | object | The set of all state changes requested

Source:
  - components/plot.js, line 90
See:
  - event:any_lz_event
  - event:region_changed for a related event that provides more accurate information in some cases

##### Listeners of This Event:

- module:ext/lz-dynamic-urls~plotUpdatesUrl