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

Arc mark rotation affects container layout #2780

Closed
marcprux opened this issue Aug 1, 2020 · 5 comments · Fixed by #2802
Closed

Arc mark rotation affects container layout #2780

marcprux opened this issue Aug 1, 2020 · 5 comments · Fixed by #2802
Assignees
Labels
bug For bugs or other software errors

Comments

@marcprux
Copy link
Member

marcprux commented Aug 1, 2020

Take the following pie chart with an arc mark:

{
  "$schema" : "https://vega.github.io/schema/vega-lite/v4.14.0.json",
  "title" : "Rotated Pie Chart",
  "mark" : {
    "angle" : 0,
    "type" : "arc"
  },
  "data" : {
    "name" : "data"
  },
  "encoding" : {
    "color" : {
      "field" : "category",
      "type" : "nominal"
    },
    "theta" : {
      "field" : "value",
      "type" : "quantitative"
    }
  },
  "datasets" : {
    "data" : [
      {
        "category" : 1,
        "value" : 4
      },
      {
        "category" : 2,
        "value" : 6
      },
      {
        "category" : 3,
        "value" : 10
      },
      {
        "category" : 4,
        "value" : 3
      },
      {
        "category" : 5,
        "value" : 7
      },
      {
        "category" : 6,
        "value" : 8
      }
    ]
  }
}

Screen Shot 2020-08-01 at 14 18 55

Change the mark's "angle" property from 0 to 45, and it is rendered as:

Screen Shot 2020-08-01 at 14 20 16

The padding and position relative to the title and legend all changed, even through all we wanted to do was change the default rotation of the pie chart.

@marcprux
Copy link
Member Author

marcprux commented Aug 1, 2020

Aug-01-2020 15-15-21

@domoritz
Copy link
Member

domoritz commented Aug 1, 2020

Is this a Vega-Lite or Vega issue?

@marcprux
Copy link
Member Author

marcprux commented Aug 1, 2020

Sorry, it's vega. The same behavior can be reproduced with the vega spec:

{
  "$schema": "https://vega.github.io/schema/vega-lite/v4.14.0.json",
  "title": "Rotated Pie Chart",
  "mark": {"angle": 45, "type": "arc"},
  "data": {"name": "data"},
  "encoding": {
    "color": {"field": "category", "type": "nominal"},
    "theta": {"field": "value", "type": "quantitative"}
  },
  "datasets": {
    "data": [
      {"category": 1, "value": 4},
      {"category": 2, "value": 6},
      {"category": 3, "value": 10},
      {"category": 4, "value": 3},
      {"category": 5, "value": 7},
      {"category": 6, "value": 8}
    ]
  }
}

@domoritz Can you re-host this issue in the vega project?

@kanitw kanitw transferred this issue from vega/vega-lite Aug 1, 2020
@jheer jheer self-assigned this Aug 14, 2020
@jheer jheer added the bug For bugs or other software errors label Aug 14, 2020
@jheer
Copy link
Member

jheer commented Aug 14, 2020

Thanks @marcprux! This reveals a bug in the arc bounds calculation. Here's the same example with the bounds also rendered, illustrating the problem:

image

@jheer
Copy link
Member

jheer commented Aug 14, 2020

The crux of the issue is that the angle channel for rotating the marks uses an indirect path for bounding box calculation: the bounds are calculated directly, and then rotated to match the angle. This results in bounding boxes at arbitrary angles, so we then compute the rectified bounding box in the pixel coordinate space of the rotated bounding box. The process can enlarge the bounding box size, creating the problem here. Clearly we need to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug For bugs or other software errors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants