-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(goal): chart placement and overlap issues (#1620)
* fix goal chart vertical placement * enforce max angle without overlapping
- Loading branch information
1 parent
0eb7975
commit b5d375b
Showing
24 changed files
with
289 additions
and
52 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
Binary file modified
BIN
-39 Bytes
(100%)
...or-all-stories-goal-alpha-side-gauge-inverted-visually-looks-correct-1-snap.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 modified
BIN
+34 Bytes
(100%)
...l-tests-for-all-stories-goal-alpha-side-gauge-visually-looks-correct-1-snap.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
+17.6 KB
...agitta-shifted-goal-charts-should-apply-correct-bottom-shift-3-π-4-0-1-snap.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
+15.1 KB
...itta-shifted-goal-charts-should-apply-correct-bottom-shift-3-π-4-π-4-1-snap.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
+22.4 KB
...itta-shifted-goal-charts-should-apply-correct-bottom-shift-neg-π-8-π-1-snap.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
+21 KB
...es-sagitta-shifted-goal-charts-should-apply-correct-bottom-shift-π-0-1-snap.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
+15 KB
...itta-shifted-goal-charts-should-apply-correct-bottom-shift-π-4-3-π-4-1-snap.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
+20.1 KB
...-sagitta-shifted-goal-charts-should-apply-correct-bottom-shift-π-8-π-1-snap.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
+15.2 KB
...shifted-goal-charts-should-apply-correct-top-shift-neg-3-π-4-neg-π-4-1-snap.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
+14.9 KB
...shifted-goal-charts-should-apply-correct-top-shift-neg-π-4-neg-3-π-4-1-snap.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
+20.4 KB
...tta-shifted-goal-charts-should-apply-correct-top-shift-neg-π-8-neg-π-1-snap.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
+20.2 KB
...tta-shifted-goal-charts-should-apply-correct-top-shift-neg-π-neg-π-8-1-snap.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
+22.4 KB
...sagitta-shifted-goal-charts-should-apply-correct-top-shift-neg-π-π-8-1-snap.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
+22.6 KB
...sagitta-shifted-goal-charts-should-apply-correct-top-shift-π-8-neg-π-1-snap.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
+31.4 KB
...ies-test-ts-goal-stories-should-prevent-overlapping-angles-clockwise-1-snap.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
+31 KB
...t-ts-goal-stories-should-prevent-overlapping-angles-counterclockwise-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
89 changes: 89 additions & 0 deletions
89
packages/charts/src/chart_types/goal_chart/layout/viewmodel/utils.test.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,89 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { Radian } from './../../../../common/geometry'; | ||
import { normalizeAngles } from './utils'; | ||
|
||
const normalize = (a: Radian): number => a / Math.PI; | ||
const denormalize = (a: number): Radian => a * Math.PI; | ||
|
||
/** | ||
* Units of π | ||
*/ | ||
type AngleTuple = [start: number, end: number]; | ||
|
||
describe('Goal utils', () => { | ||
type TestCase = [initial: AngleTuple, final: AngleTuple]; | ||
describe('#normalizeAngles', () => { | ||
const testCases: TestCase[] = [ | ||
[ | ||
[1.5, 2.5], | ||
[-0.5, 0.5], | ||
], | ||
[ | ||
[-1.5, -2.5], | ||
[0.5, -0.5], | ||
], | ||
[ | ||
[0.5, 1], | ||
[0.5, 1], | ||
], | ||
[ | ||
[-0.5, -1], | ||
[-0.5, -1], | ||
], | ||
[ | ||
[0, 2], | ||
[0, 2], | ||
], | ||
[ | ||
[0, -2], | ||
[0, -2], | ||
], | ||
[ | ||
[2, 4], | ||
[0, 2], | ||
], | ||
[ | ||
[-2, -4], | ||
[0, -2], | ||
], | ||
[ | ||
[20, 21], | ||
[0, 1], | ||
], | ||
[ | ||
[-20, -21], | ||
[0, -1], | ||
], | ||
]; | ||
|
||
describe('counterclockwise', () => { | ||
it.each<TestCase>(testCases)('should normalize angles from %j to %j', (inital, final) => { | ||
const initialAngles = inital.map(denormalize) as AngleTuple; | ||
const result = normalizeAngles(...initialAngles).map(normalize); | ||
// needed for rounding errrors with normalizing | ||
expect(result[0]).toBeCloseTo(final[0]); | ||
expect(result[1]).toBeCloseTo(final[1]); | ||
}); | ||
}); | ||
|
||
describe('clockwise', () => { | ||
it.each<TestCase>(testCases.map((arr) => arr.map((a) => a.reverse() as AngleTuple) as TestCase))( | ||
'should normalize angles from %j to %j', | ||
(inital, final) => { | ||
const initialAngles = inital.map(denormalize) as AngleTuple; | ||
const result = normalizeAngles(...initialAngles).map(normalize); | ||
// needed for rounding errrors with normalizing | ||
expect(result[0]).toBeCloseTo(final[0]); | ||
expect(result[1]).toBeCloseTo(final[1]); | ||
}, | ||
); | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.