Tooltip Component reusable API class that renders a
simple and configurable tooltip element for Britechart's
line chart or stacked area chart.
- Description:
- Tooltip Component reusable API class that renders a simple and configurable tooltip element for Britechart's line chart or stacked area chart.
- Source:
- Tutorials:
-
- Tutorial: tooltip
Example
var lineChart = line(),
tooltip = tooltip();
tooltip
.title('Tooltip title');
lineChart
.width(500)
.on('customMouseOver', function() {
tooltip.show();
})
.on('customMouseMove', function(dataPoint, topicColorMap, dataPointXPosition) {
tooltip.update(dataPoint, topicColorMap, dataPointXPosition);
})
.on('customMouseOut', function() {
tooltip.hide();
});
select('.css-selector')
.datum(dataset)
.call(lineChart);
select('.metadata-group .hover-marker')
.datum([])
.call(tooltip);
(require("Tooltip"))(_selection, _data)
- Description:
- This function creates the graph using the selection as container
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
_selection |
D3Selection | A d3 selection that represents the container(s) where the chart(s) will be rendered |
_data |
Object | The data to attach and generate the chart |
Requires
- module:d3-array,
Members
(static) axisTimeCombinations
- Description:
- constants to be used to force the x axis to respect a certain granularity current options: HOUR_DAY, DAY_MONTH, MONTH_YEAR
- Source:
constants to be used to force the x axis to respect a certain granularity
current options: HOUR_DAY, DAY_MONTH, MONTH_YEAR
Example
tooltip.dateFormat(tooltip.axisTimeCombinations.HOUR_DAY)
Methods
module:Tooltip(_selection, _data)
- Description:
- This function creates the graph using the selection as container
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
_selection |
D3Selection | A d3 selection that represents the container(s) where the chart(s) will be rendered |
_data |
Object | The data to attach and generate the chart |
(static) ariaDescription(_xopt) → {String|module}
- Description:
- Sets the accessible description announced for the chart.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
_x |
String |
<optional> |
Description rendered in the SVG desc |
Returns:
Current description or the chart for chaining
- Type
- String | module
(static) ariaLabel(_xopt) → {String|module}
- Description:
- Sets the accessible name announced for the chart.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
_x |
String |
<optional> |
Label rendered in the SVG title |
Returns:
Current label or the chart for chaining
- Type
- String | module
(static) autoResize(_xopt) → {Boolean|module}
- Description:
- Redraw when the parent container changes size.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
_x |
Boolean |
<optional> |
true to follow the container with a ResizeObserver |
Returns:
Current flag or the chart for chaining
- Type
- Boolean | module
(static) dateCustomFormat(_x) → {String|module}
- Description:
- Exposes the ability to use a custom date format
- Source:
Example
tooltip.dateFormat(tooltip.axisTimeCombinations.CUSTOM);
tooltip.dateCustomFormat('%H:%M %p')
Parameters:
| Name | Type | Description |
|---|---|---|
_x |
String | Desired custom format |
Returns:
Current format or module to chain calls
- Type
- String | module
(static) dateFormat(_x) → {String|module}
- Description:
- Exposes the ability to force the tooltip to use a certain date format
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
_x |
String | Desired format |
Returns:
Current format or module to chain calls
- Type
- String | module
(static) dateLabel(_x) → {String|module}
- Description:
- Gets or Sets the dateLabel of the data
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
_x |
String | Desired dateLabel |
Returns:
Current dateLabel or Chart module to chain calls
- Type
- String | module
(static) hide() → {module}
- Description:
- Hides the tooltip
- Source:
Returns:
Tooltip module to chain calls
- Type
- module
(static) locale(_x) → {String|module}
- Description:
- Pass locale for the tooltip to render the date in
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
_x |
String | Must be a locale tag like 'en-US' or 'fr-FR' |
Returns:
Current locale or module to chain calls
- Type
- String | module
(static) nameLabel(_x) → {String|module}
- Description:
- Gets or Sets the nameLabel of the data
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
_x |
String | Desired nameLabel |
Returns:
Current nameLabel or Chart module to chain calls
- Type
- String | module
(static) numberFormat(Desired) → {string|module}
- Description:
- Gets or Sets the number format for the value displayed on the tooltip
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
Desired |
string | number format |
Returns:
Current numberFormat or Chart module to chain calls
- Type
- string | module
(static) shouldShowDateInTitle(_x) → {Boolean|module}
- Description:
- Gets or Sets shouldShowDateInTitle
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
_x |
Boolean | Desired value |
Returns:
Current shouldShowDateInTitle or Chart module to chain calls
- Type
- Boolean | module
(static) show() → {module}
- Description:
- Shows the tooltip
- Source:
Returns:
Tooltip module to chain calls
- Type
- module
(static) title(_x) → {String|module}
- Description:
- Gets or Sets the title of the tooltip (to only show the date, set a blank title)
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
_x |
String | Desired title |
Returns:
Current title or module to chain calls
- Type
- String | module
(static) tooltipOffset(tooltipOffset) → {Object|module}
- Description:
- Pass an override for the offset of your tooltip
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
tooltipOffset |
Object | Object representing the X and Y offsets |
Returns:
Current tooltipOffset
- Type
- Object | module
(static) topicLabel(_x) → {String|module}
- Description:
- Gets or Sets the topicLabel of the data
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
_x |
String | Desired topicLabel |
Returns:
Current topicLabel or Chart module to chain calls
- Type
- String | module
(static) topicsOrder(_x) → {Array.<String>|module}
- Description:
- Pass an override for the ordering of your tooltip
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
_x |
Array.<String> | Array of the names of your tooltip items |
Returns:
Current overrideOrder or Chart module to chain calls
- Type
- Array.<String> | module
(static) update(dataPoint, colorMapping, position) → {Module}
- Description:
- Updates the position and content of the tooltip
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
dataPoint |
Object | Datapoint to represent |
colorMapping |
Object | Color scheme of the topics |
position |
Number | X-scale position in pixels |
Returns:
Tooltip module to chain calls
- Type
- Module
(static) valueFormatter(_x) → {function|module}
- Description:
- Gets or Sets the formatter function for the value displayed on the tooltip. Setting this property makes the tooltip ignore numberFormat.
- Source:
Example
tooltipChart.valueFormatter(value => value.toString().length.toString())
Parameters:
| Name | Type | Description |
|---|---|---|
_x |
function | Desired formatter function |
Returns:
Current valueFormatter or Chart module to chain calls
- Type
- function | module
(static) valueLabel(_x) → {String|module}
- Description:
- Gets or Sets the valueLabel of the data
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
_x |
String | Desired valueLabel |
Returns:
Current valueLabel or Chart module to chain calls
- Type
- String | module