# Class: intervals

## LocusZoom_DataLayers~intervals()

(extension) Implements a data layer that will render interval annotation tracks (intervals must provide start and end values) Each interval (such as from a BED file) will be rendered as a rectangle. All spans can be rendered on the same row, or each (auto-detected) category can be rendered as one row per category.

This layer is intended to work with a variety of datasets with special requirements. As such, it has a lot of configuration options devoted to identifying how to fill in missing information (such as color)

## Constructor

#### new intervals()

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`layout.start_field` | string | <optional> | 'start' | The field that defines interval start position
`layout.end_field` | string | <optional> | 'end' | The field that defines interval end position
`layout.track_label_field` | string | <optional> | 'state_name' | Used to label items on the y-axis
`layout.track_split_field` | string | <optional> | 'state_id' | Used to define categories on the y-axis. It is usually most convenient to use the same value for state_field and label_field (eg 1:1 correspondence).
`layout.track_split_order` | * | 'DESC' | <optional> | 'DESC' | When in split tracks mode, should categories be shown in the order given, or descending order
`layout.track_split_legend_to_y_axis` | number | <optional> | 2 |
`layout.split_tracks` | boolean | <optional> | true | Whether to show tracks as merged (one row) or split (many rows) on initial render.
`layout.track_height` | number | <optional> | 15 | The height of each interval rectangle, in px
`layout.track_vertical_spacing` | number | <optional> | 3 |
`layout.bounding_box_padding` | number | <optional> | 2 |
`layout.always_hide_legend` | boolean | <optional> | false | Normally the legend is shown in merged mode and hidden in split mode. For datasets with a very large number of categories, it may make sense to hide the legend at all times.
`layout.color` | string | Array.<module:LocusZoom_DataLayers~ScalableParameter> | <optional> | '#B8B8B8' | The color of each datum rectangle
`layout.fill_opacity` | number | Array.<module:LocusZoom_DataLayers~ScalableParameter> | <optional> | 1 |
`layout.tooltip_positioning` | string | <optional> | 'vertical' |

Source:
  - ext/lz-intervals-track.js, line 171
See:
  - module:LocusZoom_DataLayers~BaseDataLayer
  - module:ext/lz-intervals-track for required extension and installation instructions

### Methods

#### _arrangeTracksLinear()

Split data into rows using a simple greedy algorithm such that no two items overlap (share same interval) Assumes that the data are sorted so item1.start always <= item2.start.

This function can also simply return all data on a single row. This functionality may become configurable in the future but for now reflects a lack of clarity in the requirements/spec. The code to split overlapping items is present but may not see direct use.

Source:
  - ext/lz-intervals-track.js, line 234

#### getElementStatusNodeId() → {String}

When we are in "split tracks mode", it's convenient to wrap all individual annotations with a shared highlight box that wraps everything on that row.

This is done automatically by the "setElementStatus" code, if this function returns a non-null value

To define shared highlighting on the track split field define the status node id override to generate an ID common to the track when we're actively splitting data out to separate tracks

Source:
  - ext/lz-intervals-track.js, line 313

##### Returns:

Type
  String