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: Init the better orient for the ranged bar #8475

Merged
merged 2 commits into from Oct 13, 2022
Merged

Conversation

yhoonkim
Copy link
Contributor

@yhoonkim yhoonkim commented Oct 12, 2022

Update the init logic to assign the better orient for ranged bar charts. The new logic is the same as the area.

Before

  • X, Y, Y2 -> "horizontal"
  • Y, X, X2 -> "vertical"

After

  • X, Y, Y2 -> Y, Y2 are binned ? "horizontal" : "vertical"
  • Y, X, X2 -> X, X2 are binned ? "vertical" : "horizontal"
📦 Published PR as canary version: 5.5.1--canary.8475.ccc3007.0

✨ Test out this PR locally via:

npm install vega-lite@5.5.1--canary.8475.ccc3007.0
# or 
yarn add vega-lite@5.5.1--canary.8475.ccc3007.0

@@ -43,9 +43,9 @@ describe('Mark: Bar', () => {
expect(props.height).toBeUndefined();
});

it('should draw vertical bar, with y from zero to field value and bar with quantitative x, x2, and y', () => {
const x: PositionFieldDef<string> = {field: 'bin_start', type: 'quantitative'};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since there are the test cases for the bin, I change this to cover not-binned cases.

Copy link
Member

Choose a reason for hiding this comment

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

The new tests are fine, but shouldn't you keep the old tests but add bin: 'binned' to it to cover the

if (isFieldDef(y) && isBinned(y.bin)) { condition you modified above?

@yhoonkim yhoonkim requested a review from kanitw October 12, 2022 00:51
@yhoonkim yhoonkim marked this pull request as ready for review October 12, 2022 00:51
Copy link
Member

@kanitw kanitw left a comment

Choose a reason for hiding this comment

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

Please take a look at regressions and resolve unintended changes + revise the tests you removed.

@@ -43,9 +43,9 @@ describe('Mark: Bar', () => {
expect(props.height).toBeUndefined();
});

it('should draw vertical bar, with y from zero to field value and bar with quantitative x, x2, and y', () => {
const x: PositionFieldDef<string> = {field: 'bin_start', type: 'quantitative'};
Copy link
Member

Choose a reason for hiding this comment

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

The new tests are fine, but shouldn't you keep the old tests but add bin: 'binned' to it to cover the

if (isFieldDef(y) && isBinned(y.bin)) { condition you modified above?

"y": {"scale": "y", "field": "residency_end"},
"y2": {"scale": "y", "field": "residency_start"}
"yc": {"scale": "y", "field": "residency"},
"height": {"value": 5}
Copy link
Member

Choose a reason for hiding this comment

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

This diff seems wrong?

You may need to add bin: "binned" in the related VL spec.

"y": {"scale": "y", "field": "count"},
"y2": {"scale": "y", "value": 0}
"yc": {"scale": "y", "field": "count"},
"height": {"value": 5}
Copy link
Member

Choose a reason for hiding this comment

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

This diff also seems wrong. You may need to add bin: "binned" in the related VL spec.

@@ -142,7 +142,7 @@
},
"x": {"scale": "x", "field": "year"},
"y": {"scale": "y", "field": "wages"},
"y2": {"scale": "y", "value": 0},
"y2": {"field": {"group": "height"}},
Copy link
Member

@kanitw kanitw Oct 12, 2022

Choose a reason for hiding this comment

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

This diff seems wrong. Not sure why, please investigate / debug to prevent this regression.

@@ -48,7 +48,7 @@
"title": "Distribution of Frame Render Time (ms)",
"width": {"step": 40},
"height": 100,
"mark": {"type": "bar", "cornerRadiusEnd": 0},
"mark": {"type": "bar", "cornerRadiusEnd": 0, "orient": "vertical"},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tried to add "binned" but failed due to #8476.
Adding "orient" is also an alternative way to make this spec work.

@yhoonkim yhoonkim requested a review from kanitw October 12, 2022 23:08
@@ -74,7 +74,7 @@
{ "calculate": "((!datum.commonwealth && datum.index % 2) ? -1: 1) * 2 + 95", "as": "offset" },
{ "calculate": "95", "as": "y" }
],
"mark": {"type": "bar", "stroke": "#000"},
"mark": {"type": "bar", "stroke": "#000", "orient": "vertical"},
Copy link
Member

Choose a reason for hiding this comment

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

This one has all of y, y2, x, x2, I think it should just be a rect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It works!

Copy link
Member

@kanitw kanitw left a comment

Choose a reason for hiding this comment

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

LGTM. Please try to see if changing bar to rect in wheat_wages works before merging.

@@ -16,7 +16,7 @@
},
"layer": [
{
"mark": {"type": "bar", "fill": "#aaa", "stroke": "#999"},
"mark": {"type": "bar", "fill": "#aaa", "stroke": "#999", "orient": "vertical"},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kanitw For this one, I will keep as "bar" but change to add "binned" on encoding.x instead of the "orient" since this spec has a kind of the bin transform implying it is binned.

@yhoonkim yhoonkim merged commit 217e860 into next Oct 13, 2022
@yhoonkim yhoonkim deleted the yh/ranged-bar-orient branch October 13, 2022 00:06
@vega-org-bot vega-org-bot mentioned this pull request Oct 13, 2022
6 tasks
@vega-org-bot
Copy link
Collaborator

🚀 PR was released in v5.6.0 🚀

@vega-org-bot vega-org-bot added released This PR has been released by auto shipit and removed prerelease labels Oct 14, 2022
BradyJ27 pushed a commit to BradyJ27/vega-lite that referenced this pull request Oct 19, 2023
* Add example for ranged bar with not binned position channels

* Change the init logic to assgin better orient for ranged bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released This PR has been released by auto shipit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants