- Source:
Methods
addTableNotes(chart, noteopt)
add table notes to lower right of chart. Used when exporting, but can also be used on its own.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
chart |
Object
|
The chart object. | |
note |
String
|
<optional> |
Defaults to chart.options.exporting.JCHS.tableNotes but you can pass any text you like. |
createSearchBox(data, callback, chart_slug, col_indexopt, typeopt, placeholderopt)
Shorthand for createSearchBoxes(1, ...arguments).
(i.e., this function is equivalent to calling createSearchBoxes with number_of_boxes = 1)
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
data |
Array
|
Reference dataset for chart. | |
callback |
function
|
Function called on seach_box `change` event. Passes the value of the search box as the only argument (i.e., $(`#search_input_${chart_slug}`).val()). | |
chart_slug |
String
|
Unique ID of chart, to ensure unique
ids in HTML.
|
|
col_index |
Number
|
<optional> |
Column index of data to be listed in the search box. Defaults to 0. |
type |
String
|
<optional> |
'dropdown' or 'search'. Only differences are 'dropdown' has a down arrow at the right side of the box and has placeholder text 'Select a metro...', while 'search' has no arrow and has placehold text 'Search for metro...'. |
placeholder |
String
|
<optional> |
Override the default placeholder text. (e.g., 'Select a state...'). |
createSearchBoxes(number_of_boxes, data, callback, chart_slugopt, col_indexopt, typeopt, placeholderopt)
Add search box with filtered list to the page. Adds one item to the list
for each unique value of a column from ref_data.
On clicking a list item, the passed callback function is called, which
passes the value of the search box as the only argument
(i.e., $(`#search_input_${chart_slug}`).val()).
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
number_of_boxes |
Number
|
Number of search boxes to create (max of 8). | |
data |
Array
|
Reference dataset for chart. | |
callback |
function
|
Function called on seach_box `change` event. Passes the value of the search box as the only argument (i.e., $(`#search_input_${chart_slug}`).val()). | |
chart_slug |
String
|
<optional> |
Unique ID of chart, to ensure unique
ids in HTML.
|
col_index |
Number
|
<optional> |
Column index of data to be listed in the search box. Defaults to 0. |
type |
String
|
<optional> |
'dropdown' or 'search'. Only differences are 'dropdown' has a down arrow at the right side of the box and has placeholder text 'Select a metro...', while 'search' has no arrow and has placehold text 'Search for metro...'. |
placeholder |
String
|
Array
|
<optional> |
Override the default placeholder text. Pass as an array to have different placeholder text in each box. (e.g., 'Select a state...' or ['Select a state...', 'Select a county...']). |
mapLocatorCircle(map_object, search_value)
Draw a circle animated to "zero in" on a location, based on
a search value that corresponds to a point name in the series
displayed on the map. Useful when called from the searchCallback
function when a user selects a metro from the search dropdown.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
map_object |
Object
|
Object containing a Highcharts map. |
search_value |
String
|
The name to search for on the map. Compares the search_value to the point.name for each point in the currently displayed series. |
numFormat(number, decimalsopt) → {String}
Format a number and return a string. Based on Highcharts.numberFormat().
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
number |
Number
|
The input number to format. | |
decimals |
Number
|
<optional> |
The number of decimal places. A value of -1 preserves the amount in the input number. Defaults to -1. |
Returns:
- Type:
-
String
The formatted number.
requestURL(sheetID, rangeopt) → {String}
Builds a GET request URL for the Google Sheets API, based on input
sheet ID and range.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
sheetID |
String
|
Unique ID of the Google Sheet (e.g., '1LxTyrgt7sTtRYzEr6BlTnKwpwoQPz5WiIrA8dpocgRM'). | |
range |
String
|
<optional> |
The data range. Defaults to 'Sheet1'. Accepts sheet ranges that conform to the Google API (e.g., 'Sheet1!A:F'). |
Returns:
- Type:
-
String
A URL.
responsiveAnnotation(chart, text, xopt, yopt, verticalAlignopt, alignopt)
Add annontation text that responsively changes font size.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
chart |
Object
|
Reference to chart object. (`this` if called from within Highcharts event function.) | |
text |
String
|
Text to draw on chart. | |
x |
Number
|
<optional> |
y adjust for text location. Default is 0. |
y |
Number
|
<optional> |
y adjust for text location. Default is -20. |
verticalAlign |
String
|
<optional> |
Vertical alignment of text. Default is 'bottom'. |
align |
String
|
<optional> |
Horizontal alignment of text. Default is 'center'. |
Example
var rho_value = 'L(1) ρ = 0.53'
...
chart: {
events: {
render: function() {
H.JCHS.responsiveAnnotation(this, rho_value)
}
}
}
...
yAxisTitle(chart, yAxis_title, yAxis2_titleopt)
Add y-axis titles in JCHS style, horizontal above the chart.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
chart |
Object
|
Reference to chart object. (`this` if called from within Highcharts event function.) | |
yAxis_title |
String
|
Main y-axis title. | |
yAxis2_title |
String
|
<optional> |
Secondary (right) y-axis title. |