Class pv.Layout.Horizon
Extends
pv.Layout.
Implements a horizon layout, which is a variation of a single-series
area chart where the area is folded into multiple bands. Color is used to
encode band, allowing the size of the chart to be reduced significantly
without impeding readability. This layout algorithm is based on the work of
J. Heer, N. Kong and M. Agrawala in "Sizing
the Horizon: The Effects of Chart Size and Layering on the Graphical
Perception of Time Series Visualizations", CHI 2009.
This layout exports a single band mark prototype, which is intended to be used with an area mark. The band mark is contained in a panel which is replicated per band (and for negative/positive bands). For example, to create a simple horizon graph given an array of numbers:
vis.add(pv.Layout.Horizon) .bands(n) .band.add(pv.Area) .data(data) .left(function() this.index * 35) .height(function(d) d * 40);The layout can be further customized by changing the number of bands, and toggling whether the negative bands are mirrored or offset. (See the above-referenced paper for guidance.)
The fillStyle of the area can be overridden, though typically it
is easier to customize the layout's behavior through the custom
backgroundStyle, positiveStyle and negativeStyle
properties. By default, the background is white, positive bands are blue, and
negative bands are red. For the most accurate presentation, use fully-opaque
colors of equal intensity for the negative and positive bands.
Defined in: Horizon.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Constructs a new, empty horizon layout.
|
Field Attributes | Field Name and Description |
---|---|
The background color.
|
|
The band prototype.
|
|
The number of bands.
|
|
Default properties for horizon layouts.
|
|
The horizon mode: offset, mirror, or color.
|
|
The negative band color; if non-null, the interior of negative bands are
filled with the specified color.
|
|
The positive band color; if non-null, the interior of positive bands are
filled with the specified color.
|
- Fields borrowed from class pv.Panel:
- canvas, children, overflow, transform
- Fields borrowed from class pv.Bar:
- fillStyle, height, lineWidth, strokeStyle, width
- Fields borrowed from class pv.Mark:
- bottom, childIndex, cursor, data, events, index, left, parent, proto, reverse, right, root, scale, title, top, type, visible
- Methods borrowed from class pv.Panel:
- add, anchor
- Methods borrowed from class pv.Mark:
- anchorTarget, def, event, extend, margin, mouse, render