/ui/utils/histogram
The histogram utility module exports the histogram object with a create method to generate a histogram dataview.
// Definition of a histogram dataview within layer
"dataviews": {
"Histogram": {
"dataview": "histogram",
"viewport": true,
"options": {
"title": "My Histogram Title",
"caption": "My histogram caption",
"height": 200,
"tooltip": true,
"ylabel": "this is vertical label",
"xlabel": "this is horizontal label"
},
"queryparams": {
"field": "population",
"table": "network_location",
"buckets": 6, // optional, defaults to 7
"decimals": 1 // optional, default to 0
}
}
}
- Source
Methods
(inner) create(params)
Initial creation of histogram. The function requests data based on defined query settings and creates histogram visual element.
Name | Type | Description |
---|---|---|
params | Object | Histogram configuration object. |
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
params.target | HTMLElement | Target element for the histogram node. | ||
params.viewport | Boolean | Applies filtering by map current viewport, disabled by default. | ||
params.mapChange | Boolean | Applies filtering by map current viewport on each map change end event, disabled by default. Used for layer based histograms. | ||
params.query | String | <optional> | 'histogram' | Histogram query requires |
params.queryparams | Object | <optional> | Parameter for histogram query request. | |
params.options | Object | <optional> | Stores chart optional settings. | |
params.formatterParams | Object | <optional> | Configuration object for number formatting. | |
options.tooltip | Boolean | <optional> | Defaults to false. If enabled each bucket will have a tooltip with bucket properties. | |
options.width | Number | <optional> | Width in pixels for histogram container. | |
options.height | Number | <optional> | Height in pixels for histogram container. | |
options.title | String | <optional> | Title to display above. | |
options.caption | String | <optional> | Caption to display below. | |
options.ylabel | String | <optional> | Label for vertical axis. | |
options.xlabel | String | <optional> | Label for horizontal axis. | |
options.columnGap | String | <optional> | Gap between bars in pixels. Defaults to 10px. Use this property to alter bar thickness and spacing. |
- Source
(inner) createHistogramBuckets(params)
The method generates an array of bucket elements from the data buckets. The elements are rendered into the histogram node.
Name | Type | Description |
---|---|---|
params | Object | Histogram configuration object. |
- Source
(inner) setData(data)
The dataview setData method is called by the dataview update method. The data must be provided as an array of bucket object.
{
"count": 68,
"bucket": 0,
"bucket_min": "0",
"bucket_max": "143"
},
{
"count": 1166,
"bucket": 1,
"bucket_min": "143",
"bucket_max": "286"
},
{
"count": 1571,
"bucket": 2,
"bucket_min": "286",
"bucket_max": "429"
}
Name | Type | Description |
---|---|---|
data | Array | The histogram data. |
- Source