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

fix(core): Flipped y-axis stacked bar chart #1042

Merged
merged 2 commits into from
Feb 22, 2024

Conversation

etowahadams
Copy link
Contributor

@etowahadams etowahadams commented Feb 16, 2024

Fix #1041
Toward #

Change List

  • Fix stacked bar mark when y-axis is flipped.
{"arrangement": "vertical","views": [{"xDomain": {"chromosome": "chr1", "interval": [3000000, 3002010]},"title": "Flipped: true","layout": "linear","alignment": "overlay","data": {"url": "https://server.gosling-lang.org/api/v1/tileset_info/?d=sequence-multivec","type": "multivec","row": "base","column": "position","value": "count","categories": ["A", "T", "G", "C"],"start": "start","end": "end"},"tracks": [{"mark": "bar","id": "flipped-track","y": {"field": "count","type": "quantitative","axis": "none","flip": true}},{"dataTransform": [{"type": "filter", "field": "count", "oneOf": [0], "not": true}],"mark": "text","x": {"field": "start", "type": "genomic"},"xe": {"field": "end", "type": "genomic"},"size": {"value": 24},"color": {"value": "white"},"visibility": [{"operation": "less-than","measure": "width","threshold": "|xe-x|","transitionPadding": 30,"target": "mark"},{"operation": "LT","measure": "zoomLevel","threshold": 40,"target": "track"}]}],"x": {"field": "position", "type": "genomic"},"color": {"field": "base","type": "nominal","domain": ["A", "T", "G", "C"],"legend": true},"text": {"field": "base", "type": "nominal"},"style": {"textFontWeight": "bold"},"width": 800,"height": 100},{"layout": "linear","title": "Flipped: false","xDomain": {"chromosome": "chr1", "interval": [3000000, 3002010]},"alignment": "overlay","data": {"url": "https://server.gosling-lang.org/api/v1/tileset_info/?d=sequence-multivec","type": "multivec","row": "base","column": "position","value": "count","categories": ["A", "T", "G", "C"],"start": "start","end": "end"},"tracks": [{"id": "not-flipped-track","mark": "bar","y": {"field": "count","type": "quantitative","axis": "none","flip": false}},{"dataTransform": [{"type": "filter", "field": "count", "oneOf": [0], "not": true}],"mark": "text","x": {"field": "start", "type": "genomic"},"xe": {"field": "end", "type": "genomic"},"size": {"value": 24},"color": {"value": "white"},"visibility": [{"operation": "less-than","measure": "width","threshold": "|xe-x|","transitionPadding": 30,"target": "mark"},{"operation": "LT","measure": "zoomLevel","threshold": 40,"target": "track"}]}],"x": {"field": "position", "type": "genomic"},"color": {"field": "base","type": "nominal","domain": ["A", "T", "G", "C"],"legend": true},"text": {"field": "base", "type": "nominal"},"style": {"textFontWeight": "bold"},"width": 800,"height": 100}]}

Before:
image
After:
image

Circular layout

Before:
image

After:
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)

@etowahadams etowahadams changed the title fix(core): flipped stacked bar in linear track fix(core): Flipped y-axis stacked bar chart Feb 20, 2024
@@ -1011,7 +1011,7 @@ const factory: PluginTrackFactory<Tile, GoslingTrackOptions> = (HGC, context, op

// Replace width and height information with the actual values for responsive encoding
const [trackWidth, trackHeight] = this.dimensions; // actual size of a track
const axisSize = IsXAxis(resolvedSpec) ? HIGLASS_AXIS_SIZE : 0; // Why the axis size must be added here?
const axisSize = IsXAxis(resolvedSpec) && this.options.spec.layout === 'linear' ? HIGLASS_AXIS_SIZE : 0; // Why the axis size must be added here?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Circular tracks were receiving the incorrect track height because height was being added here.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, good catch.

Comment on lines +96 to +97
(isFlippedY && y - rowHeight >= 0) ||
(!isFlippedY && y <= 0)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add some extra conditions to keep incorrect draws from occurring

@etowahadams etowahadams marked this pull request as ready for review February 20, 2024 21:12
@etowahadams etowahadams requested a review from sehilyi February 20, 2024 21:13
Copy link
Member

@sehilyi sehilyi left a comment

Choose a reason for hiding this comment

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

Thank you for the fix!!

@sehilyi
Copy link
Member

sehilyi commented Feb 22, 2024

I will patch gosling.js once this is merged!

@sehilyi
Copy link
Member

sehilyi commented Feb 22, 2024

Oh, actually will increase the minor version considering #1044

@etowahadams etowahadams merged commit 6f13ae7 into main Feb 22, 2024
7 checks passed
@etowahadams etowahadams deleted the etowahadams/stacked-barchart branch February 22, 2024 23:08
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.

Flipping Stacked Barcharts fails
2 participants