Accessing parent values inside signal update

Hello together,

I have a Query in my Vega data-body which gives me some news titles. I print them in rows with a marks in marks section as you can see in the upcoming.

{
  "$schema": "https://vega.github.io/schema/vega/v5.json",
  "description": "A bar chart of flight statistics, aggregated by the selected time unit.",
  "padding": 30,
  "autosize": {"type": "fit", "resize": true, "contains": "padding"},
  "signals": [
      {
      name: point_click
      on: [{
        events: {
          source: scope
          type: click
          markname: point
        }
        update: '''kibanaAddFilter({        "match_phrase": {
      "title_keyword": "How_To_Access_Title_Keyword_In_Here?"
    }}, 'clusters')'''
      }]
    }
  ],
  "title": {
    "text": "First Published",
    "subtitle": "",
    "subtitleFontStyle": "italic",
    "frame": "group",
    "anchor": "start",
    "offset": 10
  },
  "layout": {
    "padding": 10,
    "columns": 2,
    "align": "all"
  },
  "data": [{
    "name": "FirstPublished",
    "url":{
      index: "clusters",
      body: {
        query: {
          nested: {
            path: "articles",
            query: {
              bool: {
                must: [
                  // This string will be replaced
                  // with the auto-generated "MUST" clause
                  "%dashboard_context-must_clause%"
                  {
                    range: {
                      // apply timefilter (upper right corner)
                      // to the @timestamp variable
                      first_date: {
                        // "%timefilter%" will be replaced with
                        // the current values of the time filter
                        // (from the upper right corner)
                        "%timefilter%": true
                      }
                    },
                    "range":{
                      "articles.delay": { "lte": 0 } 
                    }
                  }
                ]
                must_not: [
                  // This string will be replaced with
                  // the auto-generated "MUST-NOT" clause
                  "%dashboard_context-must_not_clause%"
                ]
                filter: [
                  // This string will be replaced
                  // with the auto-generated "FILTER" clause
                  "%dashboard_context-filter_clause%"
                ]
              }
            }
          }
        }
      }
    }
    "format": {
      "property": "hits.hits"
    }
  }],
    "marks": [
    {
      "name": "point",
      "type": "group",
      "from": { "data": "FirstPublished" },
      "marks": [
        {
          "type": "text",
          "encode": {
            "update": {
              "x": {"value": 0},
              "y": {"value": 0},
              "text": {"field": {"parent" : "_source.title_keyword"}}              "cursor": {"value": "pointer"},
              "fill": {"value": "Black"}
            }
          "hover": {"fill":{"value":"Teal"}}
          }
        }
      ]
    }
  ]
}

When clicking on a title I want to filter for this title in my Dashboard with the help of "kibanaAddfilters". I have done this several times and it works great. The problem here is that I am using a marks in marks section and I don't know how to access the "_source.title_keyword" inside my KibanaAddFilter function inside the update part of my signal. Normally I can access the value with "datum.fieldname" but since I am using "parent.fieldname" inside my marks section this is not working.
Does anybody has an idea how I can access the corresponding "_source.title_keyword" inside my KibanaAddFilter function when clicking on it?

Many Thanks for any of your help!

Here is a full example that shows it. Short answer is I think you are looking for datum.title_keyword

{
    "$schema": "https://vega.github.io/schema/vega/v5.json",
    "signals": [
      {
        "name": "addFilter",
        "on": [
          {
            "events": {"type": "click", "markname": "sourceCodeText"},
            "update": "kibanaAddFilter({ match_phrase: { \"category.keyword\": datum.sourceCode }})"
          }
        ]
      },
      {
        "name": "removeAllFilter",
        "on": [
          {
            "events": {"type": "click", "markname": "removeAllFilter"},
            "update": "kibanaRemoveAllFilters()"
          }
        ]
      }
    ],
    "data": [
      {
        "name": "table",
        "values": [
          {"sourceCode": "Home, Dinner"},
          {"sourceCode": "Space, Time"},
          {"sourceCode": "IT, Depends"},
          {"sourceCode": "Progress, SIMPLE Perfection"},
          {"sourceCode": "01.02, /FORMAT"},
          {"sourceCode": "As YOU, Are"},
          {"sourceCode": "HUMBLE, Ambitious"}
        ]
      }
    ],
    "scales": [
      {
        "name": "yscale",
        "type": "band",
        "domain": {"data": "table", "field": "sourceCode"},
        "range": {"step": 20}
      }
    ],
    "marks": [
      {
        "name": "removeAllFilter",
        "type": "text",
        "encode": {
          "enter": {
            "x": {"value": 10},
            "y": {"value": 10},
            "text": {"value": "Remove Filters"}
          }
        }
      },
      {
        "name": "sourceCodeText",
        "type": "text",
        "from": {"data": "table"},
        "encode": {
          "enter": {
            "x": {"value": 10},
            "y": {"scale": "yscale", "field": "sourceCode", "offset": 50},
            "text": {"field": "sourceCode"}
          }
        }
      }
    ]
  }

thanks for your response but that is not working. The statement "datum.something" works normally fine, but obviously not when having a marks in marks section. I am accessing my text value in the inner marks with "parent": "_source.title_keyword". So I guess there must be a similar call to access the clicked text value in my KibanaAddFilter-Function. Something like "parent.datum.title_keyword" maybe...
Do you have any other Ideas? Thanks :slight_smile:

    "marks": [
    {
      "name": "point",
      "type": "group",
      "from": { "data": "FirstPublished" },
      "marks": [
        {
          "type": "text",
          "encode": {
            "update": {
              "x": {"value": 0},
              "y": {"value": 0},
              "text": {"field": {"parent" : "_source.title_keyword"}}              "cursor": {"value": "pointer"},
              "fill": {"value": "Black"}
            }
          "hover": {"fill":{"value":"Teal"}}
          }
        }
      ]
    }
  ]

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.