Skip to content

Latest commit

 

History

History
516 lines (323 loc) · 13.9 KB

API.md

File metadata and controls

516 lines (323 loc) · 13.9 KB

Table of Contents

HistogramChart

Extends AbstractChart

Creates a new histogram graph.

Parameters

  • args Object argument object. See AbstractChart for general parameters.
    • args.binCount Number? approximate number of bins that should be used for the histogram. Defaults to what d3.bin thinks is best.
    • args.args ...any

mountRects

Mount the histogram rectangles.

Returns void

onPointHandler

Handle move events from the delaunay triangulation.

Returns Function handler function.

onLeaveHandler

Handle leaving the delaunay triangulation area.

Returns Function handler function.

mountDelaunay

Mount new delaunay triangulation.

Returns void

ScatterChart

Extends AbstractChart

Creates a new scatter graph.

Parameters

  • args Object argument object. See AbstractChart for general parameters.
    • args.sizeAccessor (String | Function) accesor specifying the size of a data point. Can be either a string (name of the size field) or a function (receiving a data point and returning its size). (optional, default d=>3)
    • args.xRug Boolean whether or not to generate a rug for the x axis. (optional, default false)
    • args.yRug Boolean whether or not to generate a rug for the y axis. (optional, default false)
    • args.args ...any

mountRugs

Mount new rugs.

Parameters

  • xRug Boolean whether or not to generate a rug for the x axis. (optional, default false)
  • yRug Boolean whether or not to generate a rug for the y axis. (optional, default false)

Returns void

mountPoints

Mount scatter points.

Returns void

onPointHandler

Handle incoming points from the delaunay triangulation.

Returns Function handler function

onLeaveHandler

Handle leaving the delaunay area.

Returns Function handler function

mountDelaunay

Mount new delaunay triangulation instance.

Returns void

LineChart

Extends AbstractChart

Creates a new line graph.

Parameters

  • $0 Object
    • $0.area
    • $0.confidenceBand
    • $0.voronoi
    • $0.defined (optional, default null)
    • $0.activeAccessor (optional, default null)
    • $0.activePoint
    • $0.args ...any
  • args Object argument object. See AbstractChart for general parameters.
    • args.area (Boolean | Array) specifies for which sub-array of data an area should be shown. Boolean if data is a simple array. (optional, default [])
    • args.confidenceBand Array? array with two elements specifying how to access the lower (first) and upper (second) value for the confidence band. The two elements work like accessors and are either a string or a function.
    • args.voronoi Object? custom parameters passed to the voronoi generator.
    • args.defined Function? optional function specifying whether or not to show a given data point.
    • args.activeAccessor (String | Function)? accessor specifying for a given data point whether or not to show it as active.
  • activePoint Object? custom parameters passed to the active point generator. See {@see Point} for a list of parameters.

mountLines

Mount lines for each array of data points.

Returns void

mountActivePoints

If an active accessor is specified, mount active points.

Parameters

  • params Object? custom parameters for point generation. See {@see Point} for a list of options.

Returns void

mountAreas

Mount all specified areas.

Parameters

  • area (Boolean | Array) specifies for which sub-array of data an area should be shown. Boolean if data is a simple array. (optional, default [])

Returns void

mountConfidenceBand

Mount the confidence band specified by two accessors.

Parameters

  • $0 Object
    • $0.lowerAccessor
    • $0.upperAccessor
  • lowerAccessor (Function | String) for the lower confidence bound. Either a string (specifying the property of the object representing the lower bound) or a function (returning the lower bound when given a data point).
  • upperAccessor (Function | String) for the upper confidence bound. Either a string (specifying the property of the object representing the upper bound) or a function (returning the upper bound when given a data point).

Returns void

mountMarkers

Mount markers, if any.

Returns void

onPointHandler

Handle incoming points from the delaunay move handler.

Returns Function handler function.

onLeaveHandler

Handles leaving the delaunay area.

Returns Function handler function.

mountDelaunay

Mount a new delaunay triangulation instance.

Parameters

Returns void

normalizeData

Normalizes the passed data to a nested array of objects.

isSingleObject: return error isArrayOfObjects: nest once isArrayOfArrays: do nothing isNestedArrayOfArrays: do nothing, assume index-based accessor isNestedArrayOfObjects: do nothing

Returns void

AbstractChart

This abstract chart class implements all functionality that is shared between all available chart types. This is not meant to be directly instantiated.

Parameters

  • $0 Object
    • $0.data
    • $0.target
    • $0.markers
    • $0.baselines
    • $0.xAccessor (optional, default 'date')
    • $0.yAccessor (optional, default 'value')
    • $0.margin
    • $0.buffer
    • $0.width
    • $0.height
    • $0.color
    • $0.colors
    • $0.xScale
    • $0.yScale
    • $0.xAxis
    • $0.yAxis
    • $0.showTooltip
    • $0.tooltipFunction
    • $0.legend
    • $0.legendTarget
    • $0.brush
    • $0.custom ...any
  • args Object argument object.
    • args.data Array data that needs to be visualized.
    • args.target (String | Object) DOM node to which the graph should be mounted. Either D3 selection or D3 selection specifier.
    • args.width Number total width of the graph.
    • args.height Number total height of the graph.
    • args.markers Array markers that should be added to the chart. Each marker object should be accessible through the xAccessor and contain a label field. (optional, default [])
    • args.baselines Array baselines that should be added to the chart. Each baseline object should be accessible through the yAccessor and contain a label field. (optional, default [])
    • args.xAccessor (String | Function) either name of the field that contains the x value or function that receives a data object and returns its x value. (optional, default d=>d)
    • args.yAccessor (String | Function) either name of the field that contains the y value or function that receives a data object and returns its y value. (optional, default d=>d)
    • args.margin Object margin object specifying top, bottom, left and right margin. (optional, default {top:10,left:60,right:20,bottom:40})
    • args.buffer Number amount of buffer between the axes and the graph. (optional, default 10)
    • args.color (String | Array)? custom color scheme for the graph.
    • args.colors (String | Array) alternative to color. (optional, default schemeCategory10)
    • args.xScale Object? object that can be used to overwrite parameters of the auto-generated x Scale.
    • args.yScale Object? object that can be used to overwrite parameters of the auto-generated y Scale.
    • args.xAxis Object? object that can be used to overwrite parameters of the auto-generated x Axis.
    • args.yAxis Object? object that can be used to overwrite parameters of the auto-generated y Axis.
    • args.showTooltip Boolean? whether or not to show a tooltip.
    • args.tooltipFunction Function? function that receives a data object and returns the string displayed as tooltip.
    • args.legend Array? names of the sub-arrays of data, used as legend labels.
    • args.legendTarget (String | Object)? DOM node to which the legend should be mounted.
  • brush (Boolean | String)? if truthy, add a bidirectional brush. If x or y, add one-directional brush.

abstractRedraw

Draw the abstract chart.

Returns void

redraw

Draw the actual chart. This is meant to be overridden by chart implementations.

Returns void

mountLegend

Mount a new legend if necessary

Parameters

  • symbolType String symbol type (circle, square, line)

Returns void

mountXAxis

Mount new x axis.

Parameters

  • xAxis Object? object that can be used to overwrite parameters of the auto-generated x Axis.

Returns void

mountYAxis

Mount new y axis.

Parameters

  • yAxis Object? object that can be used to overwrite parameters of the auto-generated y Axis.

Returns void

mountTooltip

Mount a new tooltip if necessary.

Parameters

  • showTooltip Boolean? whether or not to show a tooltip.
  • tooltipFunction Function? function that receives a data object and returns the string displayed as tooltip.

Returns void

mountContainer

Mount the main container.

Returns void

setDataTypeFlags

This method is called by the abstract chart constructor. In order to simplify parsing of passed data, set flags specifying what types of data we're dealing with.

Returns void

mountSvg

This method is called by the abstract chart constructor. Append the local svg node to the specified target, if necessary. Return existing svg node if it's already present.

Returns void

normalizeData

If needed, charts can implement data normalizations, which are applied when instantiating a new chart.

Returns void

computeDomains

Usually, the domains of the chart's scales depend on the chart type and the passed data, so this should usually be overwritten by chart implementations.

Parameters

  • params Object object of custom parameters for the specific chart type

Returns Object specifying the domain for x and y axis as separate properties.

computeXAxisType

Meant to be overwritten by chart implementations. Set tick format of the x axis.

Returns void

computeYAxisType

Meant to be overwritten by chart implementations. Set tick format of the y axis.

Returns void