-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3324 from ag-grid/AG-13216/gauges_pickFocus
AG-13216 Gauges `pickFocus` implementation
- Loading branch information
Showing
12 changed files
with
161 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
packages/ag-charts-enterprise/src/series/gauge-util/focus.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { _ModuleSupport } from 'ag-charts-community'; | ||
|
||
const { clamp } = _ModuleSupport; | ||
type SeriesNodeDatum = _ModuleSupport.SeriesNodeDatum<unknown>; | ||
type SelectionNode = { node: _ModuleSupport.Path; datum: SeriesNodeDatum }; | ||
type PickFocusInputs = _ModuleSupport.PickFocusInputs; | ||
type PickFocusOutputs = _ModuleSupport.PickFocusOutputs; | ||
type GaugeSeriesProperties = { | ||
contextNodeData?: { | ||
nodeData: SeriesNodeDatum[]; | ||
targetData: SeriesNodeDatum[]; | ||
}; | ||
datumSelection: Iterable<SelectionNode>; | ||
targetSelection: Iterable<SelectionNode>; | ||
}; | ||
|
||
export function pickGaugeFocus(self: GaugeSeriesProperties, opts: PickFocusInputs): PickFocusOutputs | undefined { | ||
const others = [ | ||
{ data: self.contextNodeData?.nodeData, selection: self.datumSelection }, | ||
{ data: self.contextNodeData?.targetData, selection: self.targetSelection }, | ||
].filter((v) => v.data && v.data.length > 0); | ||
const otherIndex = clamp(0, opts.otherIndex + opts.otherIndexDelta, others.length - 1); | ||
if (others.length === 0) return; | ||
|
||
const { data, selection } = others[otherIndex]; | ||
if (data == null || data.length === 0) return; | ||
|
||
const datumIndex = clamp(0, opts.datumIndex, data.length - 1); | ||
const datum = data[datumIndex]; | ||
|
||
for (const node of selection) { | ||
if (node.datum === datum) { | ||
const bounds = node.node; | ||
return { bounds, showFocusBox: true, clipFocusBox: true, datum, datumIndex, otherIndex }; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+12.3 KB
...2e/keyboard-nav.spec.ts-snapshots/linear-gauge-bar-highlight-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.8 KB
...eyboard-nav.spec.ts-snapshots/linear-gauge-target0-highlight-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+12.7 KB
...eyboard-nav.spec.ts-snapshots/linear-gauge-target2-highlight-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+51.5 KB
...yboard-nav.spec.ts-snapshots/radial-gauge-hideNeedle-hideBar-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+45.4 KB
...yboard-nav.spec.ts-snapshots/radial-gauge-hideNeedle-showBar-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+52.6 KB
...yboard-nav.spec.ts-snapshots/radial-gauge-showNeedle-hideBar-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+46.2 KB
...yboard-nav.spec.ts-snapshots/radial-gauge-showNeedle-showBar-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.