-
Notifications
You must be signed in to change notification settings - Fork 6
Controls
object
The controls object represents a set of inputs that are rendered with standard HTML <input>
and <select>
elements. These inputs manipulate any charts associated with this control object by either assigning new values to the charts' config properties (to change the charts' appearance or behavior) or changing the objects in the charts' filters array (to subset the data that is visualized in the chart).
string
CSS selector identifying the DOM element housing the rendered controls
array
raw (unfiltered, untransformed) dataset stored by the controls; this dataset is passed to the controls object from any associated chart object
object
an object specifying controls settings
array
an array of objects, each of which defines an input that controls some aspect of any associated charts
string
determines what type of input is rendered; types can be:
-
"text"
renders a<input type="text">
element whose value is assigned to a given option -
"number"
renders a<input type="number">
element whose value is assigned to a given option -
"list"
renders a<input type="text">
element whose comma-separated values are parsed into anarray
that is assigned to a given option -
"dropdown"
renders a<select>
element whose value is assigned to a given option -
"btngroup"
renders a set of<button>
elements; the value for the active button is assigned to a given option -
"checkbox"
renders a<input type="checkbox">
element that toggles the value assigned to a given option -
"radio"
renders a set of<input type="radio">
elements that toggle the value assigned to a given option -
"subsetter"
renders a<select>
element whose value is used to filter the data displayed in associated charts
string
label describing the input that appears above the <input>
element itself
string
applies only when input.type is not set to "subsetter"
a string that references an option in the target charts' config object that the input can manipulate; nested options can be specified using dot notations, such as "x.type"
array
applies only when input.type is not set to "text"
, "number"
, "list"
, or "checkbox"
an array of values to populate the input; these values are typically strings that map to possible values for the given option, such as "linear"
and "log"
for the x.type option or dataset columns for the x.column option; if this array is not explicitly defined, the values will default to all possible columns from the dataset
default: automatic
string
applies only when input.type is set to "subsetter"
a column from the dataset that will be used to filter any target charts
string
applies only when input.type is set to "subsetter"
specifies the initial value the subsetter is set to; if specified, the subsetter will not contain the All option
boolean
applies only when input.type is set to "dropdown"
dictates whether option underlying the control must be selected or not; when set to true
, a None option
appears in the select
element
boolean
applies only when input.type is set to "dropdown"
dictates whether option underlying the control must be selected or not; when set to true
, a None option
appears in the select
element
boolean
indicates that the control requires an option; adds an outlined, red span to the control group with the text Required
function
a callback function that will be called immediately before the target charts are redrawn; can be useful to changing multiple chart configuration options or otherwise triggering multiple changes at once
array
a list of chart objects that the controls object can manipulate
d3.selection
a d3 selection of a <div>
appended within the DOM element specified by div
maniuplates the config objects for each associated chart and calls their .draw() methods to trigger re-rendering
Param | Type | Description |
---|---|---|
option | string |
property of the config object to change |
value | any | the new value to assign to the given option |
initializes the controls object by parsing the data provided by raw
and triggering rendering of all inputs specified in config
Param | Type | Description |
---|---|---|
raw | array |
raw data to be used to populate control inputs |
clears the container div and triggers rendering of control inputs
triggers rendering of each input as defined by the inputs
array in config
renders a set of buttons; the value represented by the highlighted (clicked) button is assigned to the given option
Param | Type | Description |
---|---|---|
control | object |
an object describing the input from the inputs array from the config object |
control_wrap | d3.selection |
the selected element in which to append the rendered input |
renders a checkbox that toggles the value assigned to a given option
Param | Type | Description |
---|---|---|
control | object |
an object describing the input from the inputs array from the config object |
control_wrap | d3.selection |
the selected element in which to append the rendered input |
renders a <select>
element whose value is assigned to a given option
Param | Type | Description |
---|---|---|
control | object |
an object describing the input from the inputs array from the config object |
control_wrap | d3.selection |
the selected element in which to append the rendered input |
renders a <input type="number">
element whose value is assigned to a given option
Param | Type | Description |
---|---|---|
control | object |
an object describing the input from the inputs array from the config object |
control_wrap | d3.selection |
the selected element in which to append the rendered input |
renders a set of radio buttons that toggles the value assigned to a given option
Param | Type | Description |
---|---|---|
control | object |
an object describing the input from the inputs array from the config object |
control_wrap | d3.selection |
the selected element in which to append the rendered input |
renders a <select>
element whose value is used to filter the data displayed in associated charts
Param | Type | Description |
---|---|---|
control | object |
an object describing the input from the inputs array from the config object |
control_wrap | d3.selection |
the selected element in which to append the rendered input |
renders a <input type="text">
element whose value is assigned to a given option
Param | Type | Description |
---|---|---|
control | object |
an object describing the input from the inputs array from the config object |
control_wrap | d3.selection |
the selected element in which to append the rendered input |
Removes all components of the controls from the DOM. Added in version 1.7.0