selectorMap

An extension of rasterMap for vectors and interactive selection. See #rasterMap.

selectorMap
Parameters
config (object) The initial configuration.
Name Description
config.disableAutoZoom object (default false) Prevent the map to autozoom to vectors bbox.
Returns
object: A selectorMap instance.
Example
datahub.map.selectorMap({
    parent: document.querySelector('.map')
})
Instance Members
removeAllPolygons
addRectangle
addPolygons
zoomToBoundingBox
on(eventName, callback)

rasterMap

A map with a raster layer.

rasterMap
Parameters
config (object) The initial configuration.
Name Description
config.parent object The parent DOM element.
config.colorScale object The colorScale to use for raster, one of datahub.palette.
config.basemapName string The name of the basemap: 'basemapDark', 'basemapLight'.
config.showLabels boolean (default true) Show the map label layer.
config.showTooltip boolean (default true) Show tooltips when hovering raster.
config.polygonTooltipFunc function? The function to format vector tooltip, has passed to L.geoJson.bindTooltip().
config.mapConfig function? Overrides Leaflet map config, as passed to L.map().
Returns
object: A rasterMap instance.
Example
datahub.map.rasterMap({
    parent: document.querySelector('.map'),
    colorScale: datahub.palette.equalizedSpectral,
    showLabels: false,
    mapConfig: {
        zoomControl: false
    }
})
.init()
Instance Members
init
renderImage
show
hide
resize
zoomToPolygonBoundingBox
renderPolygon
addMarker
addMarker
addMarker
hideZoomControl
renderVectorMap
on(eventName, callback)

multiChart

A configurable line/bar/area chart.

multiChart
Parameters
config (object) The initial configuration can be passed on init or later using multiChart.setConfig.
Name Description
config.parent object The parent DOM element.
config.data object? Data can be passed on init or later using multichart.setData.
config.width number (default parent.innerWidth) External width of the chart.
config.height number (default parent.innerHeight) External height of the chart.
config.margin object (default {top:50,right:50,bottom:100,left:50}) Margins around the chart panel.
config.axisXFormat string (default '%b') Label x labels format, as passed to d3.utcFormat.
config.axisTitleX string? X axis title.
config.axisTitleY string? Y axis title.
config.chartTitle string? Chart title.
config.reverseY boolean? Reverse the Y axis so higher values are on the bottom.
config.autoScaleY boolean? Auto range the scale from y data instead of clamping min to zero or negative.
config.domain Array<number>? [ min, max ] domain of the y scale, defaults to data extent.
config.labelsRewriterY function? Y axis label rewriting function. Receives (label, index) and has to return a string or a DOM string.
Returns
object: A multichart instance.
Example
datahub.multiChart({
    parent: document.querySelector('.chart'),
    data: {
        timestamp: datahub.data.generateTimestamps(),
        barData: datahub.data.generateTimeSeries()
    }
})
Instance Members
setData
setConfig
destroy
on(eventName, callback)

timeseries

A line/area/step/arrow timeseries chart.

timeseries
Parameters
config (object) The initial configuration can be passed on init or later using timeseries.setConfig.
Name Description
config.parent object The parent DOM element.
config.data object Data can be passed on init or later using timeseries.setData.
config.reference number Value for the reference line.
config.tooltipTimestamp Date Timestamp of element to highlight.
config.width number (default parent.innerWidth) External width of the chart.
config.height number (default parent.innerHeight) External height of the chart.
config.chartType string (default 'line') Chart type: 'line', 'area', 'step', 'arrow'.
config.margin object (default {top:0,right:0,bottom:10,left:10}) Margins around the chart panel.
config.hide Array<string>? An array of names of elements to hide: 'xTitle', 'yTitle', 'tooltip', 'xAxis', 'yAxis', 'shapes', 'xGrid', 'xTitle', 'yTitle', 'tooltipDot'.
config.domain Array<number>? [ min, max ] domain of the y scale, defaults to data extent.
config.xTicks string (default d3.utcMinute.every(20)) Target x tick count, as passed to d3.axis.ticks.
config.axisXFormat string (default '%H:%M') X tick format, as passed to d3.axis.tickFormat.
config.yTicks string (default 6) Target y tick count, as passed to d3.axis.ticks.
config.axisYFormat string (default '.2') Y tick format, as passed to d3.axis.format.
config.yAxisTitle string? Y axis title.
config.xTitleFormat string (default d3.utcFormat('%c')) Format of the hovered timestamp close to the x axis.
config.valueFormatter function? Formatter for the tooltip value. Receives (data, index) and should return a string.
config.stepRange number (default 3) Only for type:step, band range above and below the line.
config.axisOnly boolean (default false) A minimal version of the chart only showing the x axis.
config.arrowSkip number (default 3) Only for type:arrow, keeping 1 arrow out of n.
Returns
object: A timeseries instance.
Example
datahub.timeseries({
    parent: document.querySelector('.timeseries-area'),
    chartType: 'area',
    data: datahub.data.generateTimeSeriesSplit()
})
Instance Members
setData
setConfig
destroy
on(eventName, callback)

verticalChart

A vertical positive/negative bar chart with reference bar.

verticalChart
Parameters
config (object) The initial configuration can be passed on init or later using verticalChart.setConfig.
Name Description
config.parent object The parent DOM element.
config.elements Array<object> Data in the form {key, label, value}.
config.referenceBarSize number The size of the reference bar in px.
config.title string The chart title.
config.unit string The axis unit.
Returns
object: A verticalChart instance.
Example
datahub.verticalChart({
    parent: document.querySelector('.vertical-chart')
    title: 'Title',
    elements:[
        {key: 'approved', label: 'Approved', value: 125},
        {key: 'written', label: 'Written', value: 16},
        {key: 'remains', label: 'Remains', value: -79}
    ],
    referenceBarSize: 100,
    unit: '%'
})
Instance Members
setConfig
destroy

waterfallChart

A waterfall chart designed for a specific use case.

waterfallChart
Parameters
config (object) The initial configuration can be passed on init or later using waterfallChart.setConfig.
Name Description
config.parent object The parent DOM element.
config.elements Array<object> Data in the form {key, label, value}.
Returns
object: A waterfallChart instance.
Example
var waterfall = datahub.waterfallChart({
    parent: document.querySelector('.waterfall-chart')
    elements:[
        {key: 'initial', label: 'Initial', value: 53},
        {key: 'closed', label: 'Closed', value: -30},
        {key: 'open', label: 'Open', value: 23},
        {key: 'new', label: 'New', value: 15},
        {key: 'total', label: 'Total', value: 38}
    ]
})
Instance Members
setConfig
destroy

weatherChart

A weather chart built on top of datahub.timeseries.

weatherChart
Parameters
config (object) The initial configuration can be passed on init or later using weatherChart.setConfig.
Name Description
config.parent object The parent DOM element.
config.data object Data can be passed on init or later using weatherChart.setData.
config.width number (default parent.innerWidth) External width of the chart.
config.height number (default parent.innerHeight) External height of the chart.
config.historicalXTicks number (default d3.utcHour.every(12)) Target historical x tick count, as passed to d3.axis.ticks.
config.historicalXFormat string (default '%H:%M') Historical x tick format, as passed to d3.axis.tickFormat.
config.forecastXTicks number (default d3.utcHour.every(12)) Target forecast x tick count, as passed to d3.axis.ticks.
config.forecastXFormat string (default '%H:%M') Forecast x tick format, as passed to d3.axis.tickFormat.
config.historicalArrowSkip number (default 3) Only keeping 1 historical arrow out of n.
config.forecastArrowSkip number (default 6) Only keeping 1 forecast arrow out of n.
Returns
object: A weatherChart instance.
Example
var data = datahub.data.generateWeatherChartData()
var chart = datahub.weatherChart({
    parent: document.querySelector('.weather-chart'),
    data: data
})
.on('tooltipChange', function(e){ console.log(e) })
.setData(data)
Instance Members
setData
setConfig
destroy