-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(goal): reduce whitespace for circular charts #1413
Merged
+105
−10
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(goal): reduce whitespace for circular charts
commit 5aff0859f2a6283a035c907756b4c45e64c00645
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is the sometimes considerable stroke width of the arc taken into account?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's true. How is the stroke width able to be set? Also I assume you are referring to the width of the colored bands themselves right?