Page MenuHomePhabricator

global property "padding" is rendered incorrectly
Closed, DeclinedPublicBUG REPORT

Assigned To
None
Authored By
Pietrasagh
May 3 2020, 6:14 PM
Referenced Files
F36962262: Screenshot 2023-04-24 at 4.18.13 PM.png
Apr 24 2023, 11:20 PM
F31793835: wiki2.png
May 3 2020, 6:14 PM
F31793837: vega2.png
May 3 2020, 6:14 PM

Description

If global property padding is set to some value Graph extension applies it as offset to marks area instead of whole graph area.

Steps to Reproduce:

for actual results see sandbox on wiki or use Graph JSON on GraphSandbox
for expected results copy Vega JSON below to Vega editor

Actual Results:

wiki2.png (206×506 px, 11 KB)

Expected Results:

vega2.png (283×533 px, 20 KB)

since Graph is not 100% compatible with vega syntax below is modified graph JSON working with Vega editor
For this case required change is to replace "properties" with "encoding" in marks.

Graph JSON
{
  "version":2,
  "width": 500,
  "height": 200,
  "padding":3,
  "background":"lightgrey",
  
  "data": [
    {
      "name": "table",
      "values": [
        {"x": 0, "y": 28, "c":0}, 
        {"x": 1, "y": 43, "c":0}, 
        {"x": 2, "y": 480, "c":0}, 
        {"x": 3, "y": 19, "c":0}, 
        {"x": 4, "y": 52, "c":0}, 
        {"x": 5, "y": 24, "c":0}, 
        {"x": 6, "y": 1, "c":0},
        {"x": 7, "y": 17, "c":0}, 
        {"x": 8, "y": 68, "c":0}, 
        {"x": 9, "y": 49, "c":0} 
      ]
    }
  ],

  "scales": [
    {
      "name": "x",
      "type": "linear",
      "range": "width",
      "domain": {"data": "table", "field": "x"}
    },
    {
      "name": "y",
      "type": "log",
      "range": "height",
      "nice": false,
      "clamp": false,
      "zero": true,
      "domain": {"data": "table", "field": "y"},
      "domainMin": 5
    }
  ],
  "axes": [
    {"type":"x","format":"g", "scale": "x","orient":"bottom"},
    {"type":"y","format":"g","scale": "y","orient":"left"}
	
  ],
  
 "marks": 
  [
    {
         "type": "line",
         "clip":true,
          "from": {"data": "table"},
          "properties": {
            "enter": {
              "x": {"scale": "x", "field": "x"},
              "y": {"scale": "y", "field": "y"},
              "strokeWidth": {"value": 2.5},
              "stroke": {"value": "#1f77b4"}
              }
            }
    }
  ]
}
Vega JSON
{
	"version":2,
  "width": 500,
  "height": 200,
  "padding":3,
  "background":"lightgrey",
  
  "data": [
    {
      "name": "table",
      "values": [
        {"x": 0, "y": 28, "c":0}, 
        {"x": 1, "y": 43, "c":0}, 
        {"x": 2, "y": 480, "c":0}, 
        {"x": 3, "y": 19, "c":0}, 
        {"x": 4, "y": 52, "c":0}, 
        {"x": 5, "y": 24, "c":0}, 
        {"x": 6, "y": 1, "c":0},
        {"x": 7, "y": 17, "c":0}, 
        {"x": 8, "y": 68, "c":0}, 
        {"x": 9, "y": 49, "c":0} 
      ]
    }
  ],

  "scales": [
    {
      "name": "x",
      "type": "linear",
      "range": "width",
      "domain": {"data": "table", "field": "x"}
    },
    {
      "name": "y",
      "type": "log",
      "range": "height",
      "nice": false,
      "clamp": false,
      "zero": true,
      "domain": {"data": "table", "field": "y"},
      "domainMin": 5
    }
  ],
  "axes": [
    {"type":"x","format":"g", "scale": "x","orient":"bottom"},
    {"type":"y","format":"g","scale": "y","orient":"left"}
	
  ],
  
 "marks": 
  [
    {
         "type": "line",
         "clip":false,
          "from": {"data": "table"},
          "encode": {
            "enter": {
              "x": {"scale": "x", "field": "x"},
              "y": {"scale": "y", "field": "y"},
              "strokeWidth": {"value": 2.5},
              "stroke": {"value": "#1f77b4"}
              }
            }
    }
  ]
}

Event Timeline

Jdlrobson changed the task status from Open to Stalled.Apr 24 2023, 11:20 PM
Jdlrobson subscribed.

This will be fixed as part of upgrading our graphs to Vega 5 (T335048). I put the example JSON into [[Special:GraphSandbox]] to map the schema from version 2 to 5 (See output [1]) and it renders without a problem.
Stalling until T335048 has been resolved and we can verify the fix.

Screenshot 2023-04-24 at 4.18.13 PM.png (602×1 px, 78 KB)

[1] `
{

"$schema": "https://vega.github.io/schema/vega/v5.json",
"width": 500,
"height": 200,
"autosize": {
  "type": "fit",
  "resize": false,
  "contains": "padding"
},
"padding": 3,
"background": "lightgrey",
"data": [
  {
    "name": "table",
    "values": [
      {
        "x": 0,
        "y": 28,
        "c": 0
      },
      {
        "x": 1,
        "y": 43,
        "c": 0
      },
      {
        "x": 2,
        "y": 480,
        "c": 0
      },
      {
        "x": 3,
        "y": 19,
        "c": 0
      },
      {
        "x": 4,
        "y": 52,
        "c": 0
      },
      {
        "x": 5,
        "y": 24,
        "c": 0
      },
      {
        "x": 6,
        "y": 1,
        "c": 0
      },
      {
        "x": 7,
        "y": 17,
        "c": 0
      },
      {
        "x": 8,
        "y": 68,
        "c": 0
      },
      {
        "x": 9,
        "y": 49,
        "c": 0
      }
    ]
  }
],
"scales": [
  {
    "name": "x",
    "type": "linear",
    "range": "width",
    "domain": {
      "data": "table",
      "field": "x"
    }
  },
  {
    "name": "y",
    "type": "log",
    "range": "height",
    "nice": false,
    "clamp": false,
    "zero": true,
    "domain": {
      "data": "table",
      "field": "y"
    },
    "domainMin": 5
  }
],
"axes": [
  {
    "encode": {},
    "format": "g",
    "scale": "x",
    "orient": "bottom"
  },
  {
    "encode": {},
    "format": "g",
    "scale": "y",
    "orient": "left"
  }
],
"marks": [
  {
    "encode": {
      "enter": {
        "x": {
          "scale": "x",
          "field": "x"
        },
        "y": {
          "scale": "y",
          "field": "y"
        },
        "strokeWidth": {
          "value": 2.5
        },
        "stroke": {
          "value": "#1f77b4"
        }
      }
    },
    "type": "line",
    "clip": false,
    "from": {
      "data": "table"
    }
  }
]

}

The Graph extension is being archived.