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

Vega - Unrecognized function: vlSelectionTest #29728

Closed
francisca-lima opened this issue Jan 31, 2019 · 6 comments
Closed

Vega - Unrecognized function: vlSelectionTest #29728

francisca-lima opened this issue Jan 31, 2019 · 6 comments
Labels
Feature:Vega Vega visualizations feedback_needed Team:Visualizations Visualization editors, elastic-charts and infrastructure

Comments

@francisca-lima
Copy link

francisca-lima commented Jan 31, 2019

Hello,

I am using the last version of Elastic/Kibana, 6.6, and vega has the following output: vega - Unrecognized function: vlSelectionTest. Anyone with the same issue? What can I do?
vlSelectionResolve not working as well.

Thank you.

@nickpeihl nickpeihl added the Team:Visualizations Visualization editors, elastic-charts and infrastructure label Feb 5, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app

@timroes
Copy link
Contributor

timroes commented Feb 5, 2019

Could you please share your Vega spec for that chart?

@timroes timroes added feedback_needed Feature:Vega Vega visualizations labels Feb 5, 2019
@francisca-lima
Copy link
Author

francisca-lima commented Feb 5, 2019

I was trying to use this example:

{
  "$schema": "https://vega.github.io/schema/vega/v4.json",
  "autosize": "pad",
  "padding": 5,
  "width": 800,
  "height": 400,
  "style": "cell",
  "data": [
    {"name": "label_store"},
    {
      "name": "source_0",
      "url": "data/stocks.csv",
      "format": {"type": "csv", "parse": {"date": "date"}, "delimiter": ","}
    },
    {
      "name": "data_0",
      "source": "source_0",
      "transform": [
        {"type": "filter", "expr": "(vlSelectionTest(\"label_store\", datum))"}
      ]
    }
  ],
  "signals": [
    {
      "name": "unit",
      "value": {},
      "on": [
        {"events": "mousemove", "update": "isTuple(group()) ? group() : unit"}
      ]
    },
    {"name": "label", "update": "vlSelectionResolve(\"label_store\")"},
    {
      "name": "label_tuple",
      "value": {},
      "on": [
        {
          "events": [{"source": "scope", "type": "mouseover"}],
          "update": "datum && item().mark.marktype !== 'group' ? {unit: \"layer_0_layer_1\", fields: label_tuple_fields, values: [(item().isVoronoi ? datum.datum : datum)[\"date\"]]} : null",
          "force": true
        }
      ]
    },
    {
      "name": "label_tuple_fields",
      "update": "[{\"field\":\"date\",\"channel\":\"x\",\"type\":\"E\"}]"
    },
    {
      "name": "label_modify",
      "on": [
        {
          "events": {"signal": "label_tuple"},
          "update": "modify(\"label_store\", label_tuple, true)"
        }
      ]
    }
  ],
  "marks": [
    {
      "name": "layer_0_layer_0_pathgroup",
      "type": "group",
      "from": {
        "facet": {
          "name": "faceted_path_layer_0_layer_0_main",
          "data": "source_0",
          "groupby": ["symbol"]
        }
      },
      "encode": {
        "update": {
          "width": {"field": {"group": "width"}},
          "height": {"field": {"group": "height"}}
        }
      },
      "marks": [
        {
          "name": "layer_0_layer_0_marks",
          "type": "line",
          "style": ["line"],
          "sort": {"field": "datum[\"date\"]", "order": "descending"},
          "from": {"data": "faceted_path_layer_0_layer_0_main"},
          "encode": {
            "update": {
              "stroke": {"scale": "color", "field": "symbol"},
              "tooltip": {
                "signal": "{\"date\": timeFormat(datum[\"date\"], '%b %d, %Y'), \"price\": format(datum[\"price\"], \"\"), \"symbol\": ''+datum[\"symbol\"]}"
              },
              "x": {"scale": "x", "field": "date"},
              "y": {"scale": "y", "field": "price"},
              "defined": {
                "signal": "datum[\"date\"] !== null && !isNaN(datum[\"date\"]) && datum[\"price\"] !== null && !isNaN(datum[\"price\"])"
              }
            }
          }
        }
      ]
    },
    {
      "name": "layer_0_layer_1_marks",
      "type": "symbol",
      "style": ["point"],
      "from": {"data": "source_0"},
      "encode": {
        "update": {
          "opacity": [
            {"test": "(vlSelectionTest(\"label_store\", datum))", "value": 1},
            {"value": 0}
          ],
          "fill": [
            {
              "test": "datum[\"date\"] === null || isNaN(datum[\"date\"]) || datum[\"price\"] === null || isNaN(datum[\"price\"])",
              "value": null
            },
            {"value": "transparent"}
          ],
          "stroke": [
            {
              "test": "datum[\"date\"] === null || isNaN(datum[\"date\"]) || datum[\"price\"] === null || isNaN(datum[\"price\"])",
              "value": null
            },
            {"scale": "color", "field": "symbol"}
          ],
          "tooltip": {
            "signal": "{\"date\": timeFormat(datum[\"date\"], '%b %d, %Y'), \"price\": format(datum[\"price\"], \"\"), \"symbol\": ''+datum[\"symbol\"]}"
          },
          "x": {"scale": "x", "field": "date"},
          "y": {"scale": "y", "field": "price"}
        }
      }
    },
    {
      "name": "layer_0_layer_1_voronoi",
      "type": "path",
      "from": {"data": "layer_0_layer_1_marks"},
      "encode": {
        "enter": {
          "fill": {"value": "transparent"},
          "strokeWidth": {"value": 0.35},
          "stroke": {"value": "transparent"},
          "isVoronoi": {"value": true}
        }
      },
      "transform": [
        {
          "type": "voronoi",
          "x": {"expr": "datum.datum.x || 0"},
          "y": {"expr": "0"},
          "size": [{"signal": "width"}, {"signal": "height"}]
        }
      ]
    },
    {
      "name": "layer_1_layer_0_marks",
      "type": "rule",
      "style": ["rule"],
      "from": {"data": "data_0"},
      "encode": {
        "update": {
          "stroke": [
            {
              "test": "datum[\"date\"] === null || isNaN(datum[\"date\"])",
              "value": null
            },
            {"value": "gray"}
          ],
          "tooltip": {
            "signal": "{\"date\": timeFormat(datum[\"date\"], '%b %d, %Y')}"
          },
          "x": {"scale": "x", "field": "date"},
          "y": {"field": {"group": "height"}},
          "y2": {"value": 0}
        }
      }
    },
    {
      "name": "layer_1_layer_1_layer_0_marks",
      "type": "text",
      "style": ["text"],
      "from": {"data": "data_0"},
      "encode": {
        "update": {
          "stroke": [
            {
              "test": "datum[\"date\"] === null || isNaN(datum[\"date\"]) || datum[\"price\"] === null || isNaN(datum[\"price\"])",
              "value": null
            },
            {"value": "white"}
          ],
          "strokeWidth": {"value": 2},
          "align": {"value": "left"},
          "dx": {"value": 5},
          "dy": {"value": -5},
          "tooltip": {
            "signal": "{\"price\": format(datum[\"price\"], \"\"), \"date\": timeFormat(datum[\"date\"], '%b %d, %Y')}"
          },
          "x": {"scale": "x", "field": "date"},
          "y": {"scale": "y", "field": "price"},
          "text": {"signal": "format(datum[\"price\"], \"\")"}
        }
      }
    },
    {
      "name": "layer_1_layer_1_layer_1_marks",
      "type": "text",
      "style": ["text"],
      "from": {"data": "data_0"},
      "encode": {
        "update": {
          "align": {"value": "left"},
          "dx": {"value": 5},
          "dy": {"value": -5},
          "fill": [
            {
              "test": "datum[\"date\"] === null || isNaN(datum[\"date\"]) || datum[\"price\"] === null || isNaN(datum[\"price\"])",
              "value": null
            },
            {"scale": "fill", "field": "symbol"}
          ],
          "tooltip": {
            "signal": "{\"price\": format(datum[\"price\"], \"\"), \"date\": timeFormat(datum[\"date\"], '%b %d, %Y'), \"symbol\": ''+datum[\"symbol\"]}"
          },
          "x": {"scale": "x", "field": "date"},
          "y": {"scale": "y", "field": "price"},
          "text": {"signal": "format(datum[\"price\"], \"\")"}
        }
      }
    }
  ],
  "scales": [
    {
      "name": "x",
      "type": "time",
      "domain": {
        "fields": [
          {"data": "source_0", "field": "date"},
          {"data": "data_0", "field": "date"}
        ]
      },
      "range": [0, {"signal": "width"}]
    },
    {
      "name": "y",
      "type": "linear",
      "domain": {
        "fields": [
          {"data": "source_0", "field": "price"},
          {"data": "data_0", "field": "price"}
        ]
      },
      "range": [{"signal": "height"}, 0],
      "nice": true,
      "zero": true
    },
    {
      "name": "color",
      "type": "ordinal",
      "domain": {"data": "source_0", "field": "symbol", "sort": true},
      "range": "category"
    },
    {
      "name": "fill",
      "type": "ordinal",
      "domain": {"data": "data_0", "field": "symbol", "sort": true},
      "range": "category"
    }
  ],
  "axes": [
    {
      "scale": "x",
      "orient": "bottom",
      "grid": false,
      "title": "date",
      "labelFlush": true,
      "labelOverlap": true,
      "tickCount": {"signal": "ceil(width/40)"},
      "zindex": 1
    },
    {
      "scale": "x",
      "orient": "bottom",
      "gridScale": "y",
      "grid": true,
      "tickCount": {"signal": "ceil(width/40)"},
      "domain": false,
      "labels": false,
      "maxExtent": 0,
      "minExtent": 0,
      "ticks": false,
      "zindex": 0
    },
    {
      "scale": "y",
      "orient": "left",
      "grid": false,
      "title": "price",
      "labelOverlap": true,
      "tickCount": {"signal": "ceil(height/40)"},
      "zindex": 1
    },
    {
      "scale": "y",
      "orient": "left",
      "gridScale": "x",
      "grid": true,
      "tickCount": {"signal": "ceil(height/40)"},
      "domain": false,
      "labels": false,
      "maxExtent": 0,
      "minExtent": 0,
      "ticks": false,
      "zindex": 0
    }
  ],
  "legends": [
    {
      "stroke": "color",
      "gradientLength": {"signal": "clamp(height, 64, 200)"},
      "title": "symbol",
      "encode": {
        "symbols": {
          "update": {"fill": {"value": "transparent"}, "opacity": {"value": 1}}
        }
      }
    },
    {
      "fill": "fill",
      "gradientLength": {"signal": "clamp(height, 64, 200)"},
      "title": "symbol",
      "encode": {"symbols": {"update": {"shape": {"value": "square"}}}}
    }
  ],
  "config": {"axisY": {"minExtent": 30}}
}

@timroes
Copy link
Contributor

timroes commented Feb 5, 2019

Hi, I don't think there is a function vlSelectionTest in Vega? I tried to search the documentation and also the rest of the internet, and I couldn't find any reference (except your post) to this function. What are you expecting that function to do, and could you please point to a specific documentation for that function?

@francisca-lima
Copy link
Author

When converting this vega-lite to vega, this function appears in the code.
Example: https://vega.github.io/editor/#/examples/vega-lite/interactive_multi_line_label
Any idea?

@timroes
Copy link
Contributor

timroes commented Feb 5, 2019

Thanks, that helped actually. I searched through Vega source code and it seems that is a newer method. Kibana is not yet up to date with the newest Vega version, thus doesn't support that function right now. I'll be closing this, and refer to #22644 for updating Vega to the most recent version.

@timroes timroes closed this as completed Feb 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Vega Vega visualizations feedback_needed Team:Visualizations Visualization editors, elastic-charts and infrastructure
Projects
None yet
Development

No branches or pull requests

4 participants