Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/scatter tooltip mode #8354

Merged
merged 4 commits into from
Jan 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/docs/charts/line.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ The line chart allows a number of properties to be specified for each dataset. T
| [`pointRadius`](#point-styling) | `number` | Yes | Yes | `3`
| [`pointRotation`](#point-styling) | `number` | Yes | Yes | `0`
| [`pointStyle`](#point-styling) | `string`\|`Image` | Yes | Yes | `'circle'`
| [`showLine`](#line-styling) | `boolean` | - | - | `undefined`
| [`showLine`](#line-styling) | `boolean` | - | - | `true`
| [`spanGaps`](#line-styling) | `boolean`\|`number` | - | - | `undefined`
| [`stepped`](#stepped) | `boolean`\|`string` | - | - | `false`
| [`xAxisID`](#general) | `string` | - | - | first x axis
Expand Down
1 change: 1 addition & 0 deletions docs/docs/charts/scatter.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function example() {
## Dataset Properties

The scatter chart supports all of the same properties as the [line chart](./charts/line.mdx#dataset-properties).
By default, the scatter chart will override the showLine property of the line chart to `false`.

## Data Structure

Expand Down
4 changes: 4 additions & 0 deletions src/controllers/controller.scatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ ScatterController.defaults = {
fill: false
},

interaction: {
mode: 'point'
},

plugins: {
tooltip: {
callbacks: {
Expand Down
40 changes: 40 additions & 0 deletions test/specs/controller.scatter.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,44 @@ describe('Chart.controllers.scatter', function() {

jasmine.triggerMouseEvent(chart, 'mousemove', point);
});

it('should only show a single point in the tooltip on multiple datasets', function(done) {
var chart = window.acquireChart({
type: 'scatter',
data: {
datasets: [{
data: [{
x: 10,
y: 15
},
{
x: 12,
y: 10
}],
label: 'dataset1'
},
{
data: [{
x: 20,
y: 10
},
{
x: 4,
y: 8
}],
label: 'dataset2'
}]
},
options: {}
});
var point = chart.getDatasetMeta(0).data[1];

afterEvent(chart, 'mousemove', function() {
expect(chart.tooltip.body.length).toEqual(1);

done();
});

jasmine.triggerMouseEvent(chart, 'mousemove', point);
});
});