# Class: LayoutRegistry

## LayoutRegistry()

Helper for working with predefined layouts

This is part of the public interface with LocusZoom and a major way that users interact to configure plots.

Each layout object that is added or retrieved here is a deep copy and totally independent from any other object

## Constructor

#### new LayoutRegistry()

Source:
  - registry/layouts.js, line 15

### Extends

- module:registry/base:RegistryBase

### Methods

#### (static) merge(custom_layout, default_layout) → {object}

A helper method used for merging two objects. If a key is present in both, takes the value from the first object. Values from `default_layout` will be cleanly copied over, ensuring no references or shared state.

Frequently used for preparing custom layouts. Both objects should be JSON-serializable.

##### Parameters:

Name | Type | Description
--- | --- | ---
`custom_layout` | object | An object containing configuration parameters that override or add to defaults
`default_layout` | object | An object containing default settings.

Source:
  - helpers/layouts.js, line 69

##### Returns:

The custom layout is modified in place and also returned from this method.

Type
  object

#### (static) mutate_attrs(layout, selector, value_or_callable) → {Array}

Modify any and all attributes at the specified path in the object

##### Parameters:

Name | Type | Description
--- | --- | ---
`layout` | object | The layout object to be mutated
`selector` | string | The JSONPath-compliant selector string specifying which field(s) to change. The callback will be applied to ALL matching selectors (see Interactivity guide for syntax and limitations)
`value_or_callable` | * | function | The new value, or a function that receives the old value and returns a new one

Source:
  - helpers/layouts.js, line 239

##### Returns:

Type
  Array

#### (static) query_attrs(layout, selector) → {Array}

Query any and all attributes at the specified path in the object. This is mostly only useful for debugging, to verify that a particular selector matches the intended field.

##### Parameters:

Name | Type | Description
--- | --- | ---
`layout` | object | The layout object to be mutated
`selector` | string | The JSONPath-compliant selector string specifying which values to return. (see Interactivity guide for limits)

Source:
  - helpers/layouts.js, line 255

##### Returns:

Type
  Array

#### (static) renameField(layout, old_name, new_name, warn_transformsopt)

A utility helper for customizing one part of a pre-made layout. Whenever a primitive value is found (eg string), replaces exact match

This method works by comparing whether strings are a match. As a result, the "old" and "new" names must match whatever namespacing is used in the input layout. Note: this utility can replace values with filters, but will not do so by default.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`layout` | object |  |  | The layout object to be transformed.
`old_name` | string |  |  | The old field name that will be replaced
`new_name` | string |  |  | The new field name that will be substituted in
`warn_transforms` | boolean | <optional> | true | Sometimes, a field name is used with transforms appended, eg `label|htmlescape`. In some cases a rename could change the meaning of the field, and by default this method will print a warning to the console, encouraging the developer to check the relevant usages. This warning can be silenced via an optional function argument.

Source:
  - helpers/layouts.js, line 193

#### add(type, name, item, override) → {*}

Add a type of layout to the registry

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`type` | String |  | The type of layout to add (plot, panel, data_layer, toolbar, toolbar_widgets, or tooltip)
`name` | String |  | The name of the layout object to add
`item` | Object |  | The layout object describing parameters
`override` | boolean | false | Whether to replace an existing item by that name

Source:
  - registry/layouts.js, line 50

##### Returns:

Type
  *

#### list(typeopt) → {Array.<String>|Object}

List all available types of layout (eg toolbar, panel, etc). If a specific type name is provided, list the layouts for that type of element ("just predefined panels").

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`type` | String | <optional> | The type of layout (eg toolbar, panel, etc)

Source:
  - registry/layouts.js, line 79

##### Returns:

Type
  Array.<String> | Object