Skip to content

Commit

Permalink
Merge pull request #270 from AUS-DOH-Safety-and-Quality/interactions-…
Browse files Browse the repository at this point in the history
…multi-selection

Add support for AllowInteractions and MultiSelection APIs
  • Loading branch information
andrjohns authored Apr 1, 2024
2 parents 03da158 + e0ab1d8 commit 1b09830
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
1 change: 1 addition & 0 deletions capabilities.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"supportsHighlight": true,
"supportsKeyboardFocus": true,
"supportsMultiVisualSelection": true,
"sorting": {
"implicit": { "clauses": [{ "role": "key", "direction": 1 }] }
},
Expand Down
42 changes: 22 additions & 20 deletions src/D3 Plotting Functions/drawDots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default function drawDots(selection: svgBaseType, visualObj: Visual) {
return (between(d.value, ylower, yupper) && between(d.x, xlower, xupper)) ? d.aesthetics.colour : "#FFFFFF";
})
.on("click", (event, d: plotData) => {
if (visualObj.host.hostCapabilities.allowInteractions) {
if (visualObj.viewModel.inputSettings.settings.spc.split_on_click) {
// Identify whether limits are already split at datapoint, and undo if so
const xIndex: number = visualObj.viewModel.splitIndexes.indexOf(d.x)
Expand Down Expand Up @@ -49,28 +50,29 @@ export default function drawDots(selection: svgBaseType, visualObj: Visual) {
.then(() => { selection.call(updateHighlighting, visualObj); });
}
event.stopPropagation();
})
// Display tooltip content on mouseover
.on("mouseover", (event, d: plotData) => {
// Get screen coordinates of mouse pointer, tooltip will
// be displayed at these coordinates
const x = event.pageX;
const y = event.pageY;
}
})
// Display tooltip content on mouseover
.on("mouseover", (event, d: plotData) => {
// Get screen coordinates of mouse pointer, tooltip will
// be displayed at these coordinates
const x = event.pageX;
const y = event.pageY;

visualObj.host.tooltipService.show({
dataItems: d.tooltip,
identities: [d.identity],
coordinates: [x, y],
isTouchEvent: false
});
})
// Hide tooltip when mouse moves out of dot
.on("mouseout", () => {
visualObj.host.tooltipService.hide({
immediately: true,
isTouchEvent: false
})
visualObj.host.tooltipService.show({
dataItems: d.tooltip,
identities: [d.identity],
coordinates: [x, y],
isTouchEvent: false
});
})
// Hide tooltip when mouse moves out of dot
.on("mouseout", () => {
visualObj.host.tooltipService.hide({
immediately: true,
isTouchEvent: false
})
});

selection.on('click', () => {
visualObj.selectionManager.clear();
Expand Down

0 comments on commit 1b09830

Please sign in to comment.