Skip to content
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

feat(track,core): support clockwise orientation in circular track #1078

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

etowahadams
Copy link
Contributor

@etowahadams etowahadams commented Jun 11, 2024

Fix #280
Toward #

Change List

  • Add a clockwise option to circular tracks to change the orientation.

Makes changes to axis, brush, and marks

Clockwise:
image

Not clockwise:
image

Example of clockwise axis

image

Checklist

  • Ensure the PR works with all demos on the online editor
  • Unit tests added or updated
  • Examples added or updated
  • Documentation updated (e.g., added API functions)
  • Screenshots for visual changes (e.g., new encoding support or UI change on Editor)

Comment on lines +7 to +17
export function valueToRadian(v: number, max: number, sa: number, ea: number, clockwise?: boolean) {
const safeVal = Math.max(Math.min(max, v), 0);
const gap = g ?? RADIAN_GAP;
const gap = RADIAN_GAP;
const radExtent = ((ea - sa) / 360) * Math.PI * 2 - gap * 2;
const radStart = (sa / 360) * Math.PI * 2;
return -(radStart + (safeVal / max) * radExtent) - Math.PI / 2.0 - gap;
const result = -(radStart + (safeVal / max) * radExtent) - Math.PI / 2.0 - gap;

if (clockwise) {
return -result - Math.PI;
}
return result;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main strategy is to add a "clockwise" option to to the radian calculation

@@ -4,21 +4,35 @@ export const RADIAN_GAP = 0; //0.04;
* Convert a value in a single-linear axis to a radian value. Anticlockwise, starts from 12 o'clock.
* v span from zero to `max`.
*/
export function valueToRadian(v: number, max: number, sa: number, ea: number, g?: number) {
Copy link
Contributor Author

@etowahadams etowahadams Jun 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

g?: number option was not used anywhere so got rid of it

@etowahadams
Copy link
Contributor Author

TODO: fix the clockwise brush

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Is it possible to change the orientation of circular tracks?
1 participant