Page MenuHomePhabricator

marks "clip" property not working
Closed, DeclinedPublicBUG REPORT

Assigned To
None
Authored By
Pietrasagh
May 3 2020, 5:15 PM
Referenced Files
F31793778: vega.png
May 3 2020, 5:15 PM
F31793777: wiki.png
May 3 2020, 5:15 PM

Description

Graph extension ignores or doesn't render "clip" for marks. This feature is useful for plotting parts of larger datasets just with domainMin or ...Max without need to transform data.

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:

wiki.png (539×516 px, 21 KB)

Expected Results:

vega.png (522×217 px, 18 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,

  
  "data": [
    {
      "name": "table",
      "values": [
        {"x": 0, "y": 28, "c":0}, 
        {"x": 1, "y": 43, "c":0}, 
        {"x": 2, "y": 48, "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,

  
  "data": [
    {
      "name": "table",
      "values": [
        {"x": 0, "y": 28, "c":0}, 
        {"x": 1, "y": 43, "c":0}, 
        {"x": 2, "y": 48, "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"},
          "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 25 2023, 12:56 AM
Jdlrobson subscribed.

The graph (updated to schema version 5) is rendering the same on https://vega.github.io/editor/#/edited and https://en.wikipedia.beta.wmflabs.org/wiki/Special:GraphSandbox. So I think this is resolved?

{
  "$schema": "https://vega.github.io/schema/vega/v5.json",
  "width": 500,
  "height": 200,
  "autosize": {
    "type": "fit",
    "resize": false,
    "contains": "padding"
  },
  "data": [
    {
      "name": "table",
      "values": [
        {
          "x": 0,
          "y": 28,
          "c": 0
        },
        {
          "x": 1,
          "y": 43,
          "c": 0
        },
        {
          "x": 2,
          "y": 48,
          "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": true,
      "from": {
        "data": "table"
      }
    }
  ]
}

The Graph extension is being archived.