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

Allow specifying specific order of stack in stacked charts #1734

Open
kanitw opened this Issue Nov 29, 2016 · 2 comments

Comments

Projects
None yet
3 participants
@kanitw
Copy link
Member

kanitw commented Nov 29, 2016

We currently do not have a way to specify manual order of stacking group (e.g., color or detail channel) in stacked charts.

Note: As seen in #1732 (comment), users might expect that color's scale domain also affect how stack is ordered.

For example, in the following spec.

{
  "data": {
    "url": "https://raw.githubusercontent.com/dhimmel/biorxiv-licenses/4ad9659e4fc823f4c491e13be4505248df5c1ab6/figure/license-vs-time/vega-lite-data.json"
  },
  "config": {
    "mark": {
      "stacked": "normalize"
    }
  },
  "encoding": {
    "color": {
      "field": "license",
      "scale": {
        "domain": [
          "CC BY",
          "CC BY-ND",
          "CC BY-NC",
          "CC BY-NC-ND",
          "None"
        ],
        "type": "ordinal"
      },
      "type": "nominal"
    },
    "x": {
      "axis": {
        "axisWidth": 0.0,
        "format": "%Y",
        "labelAngle": 0.0,
        "tickSize": 0.0
      },
      "field": "date",
      "scale": {
        "nice": "month"
      },
      "timeUnit": "yearmonth",
      "title": " ",
      "type": "temporal"
    },
    "y": {
      "aggregate": "count",
      "axis": {
        "axisWidth": 0.0,
        "grid": false,
        "labels": false,
        "ticks": 0.0
      },
      "field": "*",
      "title": "Proportion of Preprints",
      "type": "quantitative"
    }
  },
  "mark": "area"
}

The scale domain only determines how the domain values are mapped to first 5 color in the default color palette, but does not affect order of the stacking.

vega

TODOs:

  • design how we support manual order for stacking

    • Under the hood, one possible way to do this is to add a formula transform that add index for each domain value and use the index as sortby of stack transform.
    • syntax
  • decide if we want to use color/size/detail's sort by default.

cc: @dhimmel

@kanitw kanitw added this to the 2.0.0-pre Important Feature & Patches milestone Nov 29, 2016

@kanitw

This comment has been minimized.

Copy link
Member Author

kanitw commented Nov 29, 2016

Workaround

A workaround for now would be to use calculate to derive a new field and map the field to order channel. See https://vega.github.io/vega-lite/docs/stack.html#order

@kanitw

This comment has been minimized.

Copy link
Member Author

kanitw commented Nov 29, 2016

Potential Syntax

One potential syntax would be to make stack grouping channel (color/opacity/size/detail) supports sort as array of values for custom ordering and then make stack order depends on the grouping channel's order too.

cc: @domoritz, @arvind

dhimmel added a commit to dhimmel/biorxiv-licenses that referenced this issue Nov 29, 2016

@kanitw kanitw modified the milestones: 2.x.x Features & Patches, 2.0.0-pre Important Feature & Patches Jan 16, 2017

@kanitw kanitw closed this Aug 23, 2017

@kanitw kanitw reopened this Mar 18, 2018

@phivk phivk referenced this issue Mar 18, 2018

Closed

Make facet support `sort` #2176

0 of 10 tasks complete

@kanitw kanitw modified the milestones: 2.x.x Other Features & Patches, 2.x Visual Encoding Patches, 2.x Data & Transforms Patches May 9, 2018

@invokesus invokesus referenced this issue May 18, 2018

Merged

Add Stack Transform #3771

1 of 8 tasks complete

@kanitw kanitw assigned invokesus and unassigned sirahd May 31, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.