-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(goal): reduce whitespace for circular charts (#1413)
- Loading branch information
1 parent
a53a2ba
commit 6517523
Showing
18 changed files
with
105 additions
and
10 deletions.
There are no files selected for viewing
Binary file modified
BIN
+22 Bytes
(100%)
...-for-all-stories-goal-alpha-gauge-with-target-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
+27 Bytes
(100%)
...sts-for-all-stories-goal-alpha-goal-semantics-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
+231 Bytes
(100%)
...-tests-for-all-stories-goal-alpha-half-circle-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
+15 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
-20 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 modified
BIN
+100 Bytes
(100%)
...visual-tests-for-all-stories-goal-alpha-third-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
-30 Bytes
(100%)
...l-tests-for-all-stories-goal-alpha-two-thirds-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
+28.9 KB
...test-ts-goal-stories-sagitta-offset-should-limit-max-offset-to-3-2-π-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
...s-test-ts-goal-stories-sagitta-offset-should-limit-min-offset-to-π-2-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
+23.3 KB
...-goal-stories-sagitta-offset-should-render-goal-with-asymetric-angle-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
+137 Bytes
(100%)
...est-ts-goal-stories-theme-dark-should-render-gauge-with-target-story-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
+71 Bytes
(100%)
...ts-goal-stories-theme-eui-dark-should-render-gauge-with-target-story-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
-29 Bytes
(100%)
...s-goal-stories-theme-eui-light-should-render-gauge-with-target-story-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
+22 Bytes
(100%)
...st-ts-goal-stories-theme-light-should-render-gauge-with-target-story-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
47 changes: 47 additions & 0 deletions
47
packages/charts/src/chart_types/goal_chart/layout/viewmodel/utils.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,47 @@ | ||
/* | ||
* 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 { round } from '../../../../utils/common'; | ||
|
||
/** | ||
* Set to half circle such that anything smaller than a half circle will not | ||
* continue to increase offset | ||
*/ | ||
const LIMITING_ANGLE = Math.PI / 2; | ||
|
||
/** | ||
* Returns limiting angle form π/2 towards 3/2π from left and right | ||
*/ | ||
const controllingAngle = (...angles: Radian[]): Radian => | ||
angles.reduce((limitAngle, a) => { | ||
if (a >= Math.PI / 2 && a <= (3 / 2) * Math.PI) { | ||
const newA = Math.abs(a - Math.PI / 2); | ||
return Math.max(limitAngle, newA); | ||
} | ||
if (a >= -Math.PI / 2 && a <= Math.PI / 2) { | ||
const newA = Math.abs(a - Math.PI / 2); | ||
return Math.max(limitAngle, newA); | ||
} | ||
return limitAngle; | ||
}, LIMITING_ANGLE); | ||
|
||
/** @internal */ | ||
export function getSagitta(angle: Radian, radius: number, fractionDigits: number = 1) { | ||
const arcLength = angle * radius; | ||
const halfCord = radius * Math.sin(arcLength / (2 * radius)); | ||
const lengthMiltiplier = arcLength > Math.PI ? 1 : -1; | ||
const sagitta = radius + lengthMiltiplier * Math.sqrt(Math.pow(radius, 2) - Math.pow(halfCord, 2)); | ||
return round(sagitta, fractionDigits); | ||
} | ||
|
||
/** @internal */ | ||
export function getMinSagitta(startAngle: Radian, endAngle: Radian, radius: number, fractionDigits?: number) { | ||
const limitingAngle = controllingAngle(startAngle, endAngle); | ||
return getSagitta(limitingAngle * 2, radius, fractionDigits); | ||
} |
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