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

Padding object should not require all position #1077

Closed
kanitw opened this issue Nov 22, 2017 · 2 comments
Closed

Padding object should not require all position #1077

kanitw opened this issue Nov 22, 2017 · 2 comments

Comments

@kanitw
Copy link
Member

kanitw commented Nov 22, 2017

Setting "padding": {"right": 30} makes the chart output nothing.

It seems like I need to specify "padding": {"top": 0,"bottom": 0,"left": 0,"right": 30} in order to make it work. I think we should not require "top": 0,"bottom": 0,"left": 0 in this case.

{
  "$schema": "https://vega.github.io/schema/vega/v3.0.json",
  "description": "A simple bar chart with embedded data.",
  "autosize": "pad",
  "padding": {"top": 0,"bottom": 0,"left": 0,"right": 30},
  "height": 200,
  "style": "cell",
  "data": [
    {
      "name": "source_0",
      "values": [
        {"abcdefghijklmnop": "A","b": 28},
        {"abcdefghijklmnop": "B","b": 55}
      ]
    },
    {
      "name": "data_0",
      "source": "source_0",
      "transform": [
        {
          "type": "formula",
          "expr": "toNumber(datum[\"b\"])",
          "as": "b"
        },
        {
          "type": "filter",
          "expr": "datum[\"b\"] !== null && !isNaN(datum[\"b\"])"
        }
      ]
    }
  ],
  "signals": [
    {"name": "x_step","value": 21},
    {
      "name": "width",
      "update": "bandspace(domain('x').length, 0.1, 0.05) * x_step"
    }
  ],
  "marks": [
    {
      "name": "marks",
      "type": "rect",
      "style": ["bar"],
      "from": {"data": "data_0"},
      "encode": {
        "update": {
          "x": {"scale": "x","field": "abcdefghijklmnop"},
          "width": {"scale": "x","band": true},
          "y": {"scale": "y","field": "b"},
          "y2": {"scale": "y","value": 0},
          "fill": {"value": "#4c78a8"}
        }
      }
    }
  ],
  "scales": [
    {
      "name": "x",
      "type": "band",
      "domain": {
        "data": "data_0",
        "field": "abcdefghijklmnop",
        "sort": true
      },
      "range": {"step": {"signal": "x_step"}},
      "paddingInner": 0.1,
      "paddingOuter": 0.05
    },
    {
      "name": "y",
      "type": "linear",
      "domain": {"data": "data_0","field": "b"},
      "range": [{"signal": "height"},0],
      "nice": true,
      "zero": true
    }
  ],
  "axes": [
    {
      "scale": "x",
      "orient": "bottom",
      "labelOverlap": true,
      "title": "abcdefghijklmnop",
      "zindex": 1,
      "encode": {
        "labels": {
          "update": {
            "angle": {"value": 270},
            "align": {"value": "right"},
            "baseline": {"value": "middle"}
          }
        }
      }
    },
    {
      "scale": "y",
      "orient": "left",
      "labelOverlap": true,
      "tickCount": {"signal": "ceil(height/40)"},
      "title": "b",
      "zindex": 1
    },
    {
      "scale": "y",
      "orient": "left",
      "domain": false,
      "grid": true,
      "labels": false,
      "maxExtent": 0,
      "minExtent": 0,
      "tickCount": {"signal": "ceil(height/40)"},
      "ticks": false,
      "zindex": 0,
      "gridScale": "x"
    }
  ],
  "config": {"axisY": {"minExtent": 30}}
}
@kanitw kanitw added the bug For bugs or other software errors label Nov 22, 2017
@jheer jheer removed the bug For bugs or other software errors label Nov 30, 2017
@jheer
Copy link
Member

jheer commented Nov 30, 2017

This is not technically a bug. It follows the current spec.

However, I agree that the spec should be modified to allow more flexibility here. I'll include updates in the next version of vega-parser (coming soon).

@jheer jheer mentioned this issue Dec 1, 2017
@jheer
Copy link
Member

jheer commented Dec 1, 2017

Fixed in vega-parser v2.3.2. Will be included in vega 3.0.8.

@jheer jheer closed this as completed Dec 1, 2017
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

No branches or pull requests

2 participants