Radar Chart with Dynamic Data

Hello,

I am a beginner with Kibana and Vega. I m trying to create a radar chart with an index.
I managed to create a chart with static values. See below:

vega code

However, when I try to do the same with my index, I get an error when I try to calculate the average of it. The first aggregation part is the one creating the problem for me. When I remove that part I have my chart but its not calculating average, its giving every value.

What am I doing wrong? Please help!

"data": [
    {
      "name": "table",
      "url": {
        "index": "dashboard_data",
        "body": {"size": 10000, "_source": ["dv_survey","Rating","department_displayvalue","country"]}
      },
      "format": {"property": "hits.hits"} ,
  
      "transform": [
         {
          "type": "aggregate",
          "groupby": ["datum._source.department_displayvalue"],
          "fields": ["datum._source.Rating"],
          "ops": ["average"],
          "as": ["Rating"]
        },
       { "type": "filter", "expr": "datum._source.Rating > 0 && datum._source.Rating < 7 &&  datum._source['country'] =='Germany'  " }
      ]
      
    },

    {
      "name": "keys",
      "source": "table",
      "transform": [
        {"type": "aggregate", "groupby": ["_source.department_displayvalue"] 
      
          }
      ]
    }
  ],

If you can provide the spec that will include some of your data and will be easier to troubleshoot it would be appreciated.

But on first glance I would try to remove the datum. part in your aggregate transform.

{
 "type": "aggregate",
 "groupby": ["_source.department_displayvalue"],
 "fields": ["_source.Rating"],
 "ops": ["average"],
 "as": ["Rating"]
}

Hey Aaron,

I tried removing datum but then I got the error "Unrecognized signal name: "_source" "

Here is the spec:
https://gist.githubusercontent.com/Bodach/489f80041dde90c110705cc0817ea200/raw/36fa891be97c7f05d83ae14be935e93aaa0fa7a3/bodach_spec.json

Thanks!

I would try doing a project transform first to remove all the _source requirement from the fields then the rest of the visualization should work just like the demo. What that is doing is essentially just renaming the field to drop the _source.

You want to filter before aggregating. If not the filter fields won't be there after you aggregate. Transforms are from top to bottom so they process in that order.

Also I think you want to remove Japan. If not then you are only left with Japan which won't work. To write that you would change the == to != like I did above.

      "transform": [
        {
          "type": "project",
          "fields": [
            "_source.dv_survey",
            "_source.Rating",
            "_source.department_displayvalue",
            "_source.country"
          ],
          "as": ["dv_survey", "Rating", "department_displayvalue", "country"]
        },
        {
          "type": "filter",
          "expr": "datum.Rating > 0 && datum.Rating < 7 &&  datum['country'] !='Japan'  "
        },
        {
          "type": "aggregate",
          "groupby": ["department_displayvalue"],
          "fields": ["Rating"],
          "ops": ["average"],
          "as": ["Rating"]
        }
      ],

It works! Thank you so much!

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