# 3D/4D Visualization

**URL:** <https://discuss.elastic.co/t/3d-4d-visualization/128200>\
**Category:** Kibana\
**Created:** [April 16, 2018, 1:52pm UTC](https://discuss.elastic.co/t/3d-4d-visualization/128200 "2018-04-16T13:52:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarkusT](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markust/32/30037_2.png) [@MarkusT](https://discuss.elastic.co/u/MarkusT)\
**Post date:** [April 16, 2018, 1:52pm UTC](https://discuss.elastic.co/t/3d-4d-visualization/128200/1 "2018-04-16T13:52:48Z")

</div>

Hey there,

I hope you can help me, I've posted this question on github, bun got no answer for 4 weeks or so.

My plan is to build my own 3D/4D visualization, 3 dimensions to be choosen as the space koordinates and a fourth one for colouring. My basis is the area3D\_vis visualization from github ([https://github.com/JuanCarniglia/area3d\_vis](https://github.com/JuanCarniglia/area3d_vis)) and I want to set the colour dimension by myself.

What I did is: Extend the buckets by the z dimension:

```
{
    group: 'buckets',
    name: 'split',
    title: 'Z Dimension',
    aggFilter: ['terms',
      'significant_terms',
      'filters',
      'date_range',
      'histogram',
      'date_histogram',
      'range'
    ]
  }

```

just like the dimensions where defined - this works, I can choose it in kibana.  
And the metric can be choosen separately.  
The response table looks fine, too.

The js code for handling the response is

```
_.map(resp.aggregations, function (xElementRoot) {
  if (xElementRoot !== null) {
    _.map(xElementRoot.buckets, function (xElement) {
      if (xElement !== null) {
        x = parseInt(xElement.key);
        fiberX++;
        _.map(xElement[3].buckets, function (yElementBucket) {
          y = parseInt(yElementBucket.key);
          fiberY++;                                                                 
          _.map(xElement[4].buckets, function (zElementBucket) {
            z = parseInt(zElementBucket.key);
            fiberZ++;
            if (zElementBucket.hasOwnProperty('1')) {
              z = parseInt(zElementBucket[1].value);
            } else {
              z = zElementBucket.doc_count;
          }
          data.add({
            id: counter++,
            x: x,
            y: parseInt(yElementBucket.key),
            z: z,
            style: z
          });
        });
      });
    }
   });
  }
});

```

And there's the rub I think: the \_.map() function provided by vis.js  
Has anyone experience with vis.js or even the area3d\_vis visualization?

Thanks so far,

Markus

* * *

There was a Kibana issue/feature request on github a few... few more days ago:

> <https://github.com/elastic/kibana/issues/9002>

Anyone?

Kind regards,

Markus

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [April 20, 2018, 1:58pm UTC](https://discuss.elastic.co/t/3d-4d-visualization/128200/2 "2018-04-20T13:58:01Z")

</div>

`_.map()` is a lodash function. Documentation can be found at [https://lodash.com/docs/3.10.1#map](https://lodash.com/docs/3.10.1#map).

I am not sure what you are asking. Could you please re-state your question?

Nathan

---

<div class="post-metadata">

**Author:** ![MarkusT](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markust/32/30037_2.png) [@MarkusT](https://discuss.elastic.co/u/MarkusT)\
**Post date:** [April 23, 2018, 9:15am UTC](https://discuss.elastic.co/t/3d-4d-visualization/128200/3 "2018-04-23T09:15:04Z")

</div>

What I want to do is extend the existing visualization for kibana to select 4 dimensions, 3 in space and one as the colour (style variable -\> see data.add(...) in my last post).  
I am able to get the request to elastic right, but I don't get it to read the response right and handle it with \_.map().

Is this more comprehensible?

Thank you,  
Markus

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [April 23, 2018, 3:04pm UTC](https://discuss.elastic.co/t/3d-4d-visualization/128200/4 "2018-04-23T15:04:28Z")

</div>

In Kibana 6.0 and up, your plugin can use a [custom response handler](https://www.elastic.co/guide/en/kibana/current/development-visualization-request-handlers.html#development-custom-request-handler). If you are having trouble with the default response handler, then wire in your own.

It is still not clear why `_.map` is causing you problems. Maybe provide a response and the output of tabify?

---

<div class="post-metadata">

**Author:** ![MarkusT](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markust/32/30037_2.png) [@MarkusT](https://discuss.elastic.co/u/MarkusT)\
**Post date:** [April 24, 2018, 6:13am UTC](https://discuss.elastic.co/t/3d-4d-visualization/128200/5 "2018-04-24T06:13:08Z")

</div>

Here is the response:

```
{
  "took": 17,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 241,
    "max_score": 0,
    "hits": []
  },
  "aggregations": {
    "2": {
      "buckets": [
        {
          "3": {
            "buckets": [
              {
                "4": {
                  "buckets": [
                    {
                      "key": 1,
                      "doc_count": 120
                    }
                  ]
                },
                "key": 0,
                "doc_count": 120
              }
            ]
          },
          "key": 79,
          "doc_count": 120
        },
        {
          "3": {
            "buckets": [
              {
                "4": {
                  "buckets": [
                    {
                      "key": 1,
                      "doc_count": 1
                    },
                    {
                      "key": 2,
                      "doc_count": 120
                    }
                  ]
                },
                "key": -1,
                "doc_count": 121
              }
            ]
          },
          "key": 105,
          "doc_count": 121
        }
      ]
    }
  },
  "status": 200
}

```

and the output tabified (as formatted .csv):

```
"x", "y", "z", Count
79, 0, 1, 120
105, "-1", 1, 1
105, "-1", 2, 120

```

I think the problem is not directly coming from \_.map() but from the function provided in area3d\_vis,  
`function(xElementRoot){...}`,  
`function(xElement){...}`  
and  
`function(yElementBucket){...}`  
.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 22, 2018, 6:13am UTC](https://discuss.elastic.co/t/3d-4d-visualization/128200/6 "2018-05-22T06:13:13Z")

</div>

Closed on May 22, 2018, 6:13am UTC

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