Fix/scatter tooltip mode (#8354)

* scatter tooltip should be point by default
* edited mode on better level and updated docs to be bit more clear
This commit is contained in:
LeeLenaleee 2021-01-30 22:22:01 +01:00 committed by GitHub
parent 5eb3682b9f
commit b50fba3759
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 46 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -24,6 +24,10 @@ ScatterController.defaults = {
fill: false
},
interaction: {
mode: 'point'
},
plugins: {
tooltip: {
callbacks: {

View File

@ -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);
});
});