Vega data transform lookup does not work for multiple keys in primary data set

480 views
Skip to first unread message

Damith

unread,
Jan 24, 2016, 12:45:17 AM1/24/16
to vega-js
Hi,

Lets say I have following primary data set. 

{
    "type": "Topology",
    "objects": {
        "countries": {
            "type": "GeometryCollection",
            "bbox": [-179.99999999999997, -90.00000000000003, 180.00000000000014, 83.64513000000001],
            "geometries": [{
                "type": "Polygon",
                "countryCode": "AFG",
                "id": "afghanistan",
                "arcs": [
                    [0, 1, 2, 3, 4, 5]
                ]
            }, {
                "type": "Polygon",
                "countryCode": "EGY",
                "id": "egypt",
                "arcs": [
                    [247, 248, 249, 250, 251]
                ]
            }
         }
     }
}

Following is my secondary data set.

["afghanistan",4.23],["EGY",1.23]

And my lookup function is below. 

          {
                "type": "lookup",
                "keys": ["id","countryCode"],
                "on": config.title,
                "onKey": metadata.names[config.x],//here correct attribute is given. So for above case this value will be either "afghanistan" or "EGY"
                "as": ["zipped"],
                "default": {"v": null, "country":"No data"}
            }

As per the documentation says "Lookup accepts one or more key values for the primary data set, each of which are then searched for within a single key field of the secondary data set. If a match is found, the full data object in the secondary data set is added as a property of the primary data set."  But it only works if I put on id for keys attribute in above lookup function. I believe it should check the  countryCode also for a match. Is this a bug ? Did I miss anything here. 


Roy I

unread,
Jan 25, 2016, 5:19:40 PM1/25/16
to vega-js
Documentation for Vega data transform type "lookup"
-------------------------------------------------
keys Array<Field> An array of one or more key fields in the primary data set to match against the secondary data set.

as Array<String> An array of field names in which to store the results of the lookup.                                       This array should have the same length as the keys parameter.
--------------------------------------------------

See Vega example and tutorial
     
   
        {
 "type": "lookup", 
           "on": "airports", 
           "onKey": "iata",
 
           "keys": ["origin", "destination"],
           "as":   ["_source", "_target"]
  
        },


        { "type": "filter",
           "test": "datum._source && datum._target"
        },

Damith

unread,
Feb 10, 2016, 8:55:19 AM2/10/16
to vega-js
Hi Roy,

Thanks for the information.
Reply all
Reply to author
Forward
0 new messages