new Chart(options)
A class to render ChartJS charts using CartoDB data
Parameters:
Name | Type | Description |
---|---|---|
options |
nyc.carto.Chart.Options | Constructor options |
- Source:
Extends
Methods
chart(filterValuesArray, titleNode, descriptionValues)
Parameters:
Name | Type | Description |
---|---|---|
filterValuesArray |
Array.<Object.<string, Object.<string, string>>> | The values objects used along with the views filters and sqlTemlate to modify the queries for the chart series |
titleNode |
JQuery | Element | string | The HTML element for title text |
descriptionValues |
Array.<Object.<string, string>> | The values objects for replacing tokens in the descriptionTemplate |
- Source:
render()
Renders the chart or forces a rerendering of the chart
- Source:
replace(str, values) → {string}
Replace tokens in a string with values from a provided object
Parameters:
Name | Type | Description |
---|---|---|
str |
string | String with tokens to be replaced |
values |
Object.<string, string> | Values token for replacement |
- Inherited From:
- Source:
Returns:
String with replacement value substitution
- Type
- string
sql(template, values, filtersopt) → {string}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
template |
string | The SQL template with optional replacement tokens | |
values |
Object.<string, Object.<string, string>> | The replacement values | |
filters |
Object.<string, string> |
<optional> |
The filters to append to the WHERE clause (i.e. ) |
- Inherited From:
- Source:
Returns:
The SQL statement
- Type
- string
Example
var template = "SELECT * FROM bike WHERE ${where}";
var values = {
color: {value: "red"},
gear: {low: 10, high: 18}
};
var filters = {
color: "color = '${value}'",
gear: "gear BETWEEN ${low} AND ${high}"
};
var sqlTmpl = nyc.carto.SqlTemplate();
sqlTmpl.sql(template, values, filters);
//Returns "SELECT * FROM bike WHERE color = 'red' AND gear BETWEEN 10 AND 18"
Type Definitions
Options
Object type to hold constructor options for nyc.carto.Chart
Type:
- Object
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
canvas |
JQuery | Element | string | The canvas element for chart rendering | |
cartoSql |
cartodb.SQL | The object used to query CartoDB data | |
sqlTemplate |
string | The template with optional replacement tokens for generating queries for cartoSql | |
descriptionTemplate |
string | The template with optional replacement tokens for the chart description | |
dataColumn |
string | The data column for the y-axis chart values | |
labelColumn |
string | The data column for labeling the x-axis of the chart | |
filters |
Object.<string, Object.<string, string>> | The filters object used with the sqlTemplate for generating queries for cartoSql | |
chartOptions |
Object |
<optional> |
ChartJS options (See: http://www.chartjs.org/) |
seriesOptions |
Array.<Object> |
<optional> |
ChartJS options (See: http://www.chartjs.org/) |
labelLookupFunction |
function | A function to transform labelColumn column values from the data into readable labels |
- Source: