# JS client - create visualization in ES 6.2

**URL:** <https://discuss.elastic.co/t/js-client-create-visualization-in-es-6-2/130196>\
**Category:** Kibana\
**Created:** [May 2, 2018, 6:59am UTC](https://discuss.elastic.co/t/js-client-create-visualization-in-es-6-2/130196 "2018-05-02T06:59:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![milkamar](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@milkamar](https://discuss.elastic.co/u/milkamar)\
**Post date:** [May 2, 2018, 6:59am UTC](https://discuss.elastic.co/t/js-client-create-visualization-in-es-6-2/130196/1 "2018-05-02T06:59:28Z")

</div>

Hi,  
I want to create visualization via JS client in ES 6.2.

I have read this :  
[How to put a visualization directly in Kibana/ElasticSearch?](https://discuss.elastic.co/t/how-to-put-a-visualization-directly-in-kibana-elasticsearch/48325) ;

but when I compare already existing visualizations in my 6.2 and what is provided in answers in topic mentioned above, there are some differences:  
\_type is "doc", not "visualization"  
\_id is not uuid, but "visualization":uuid  
\_source does not directly contain visualization data, but rather inner "visualization" object

Here is my code:

```
  var _id = uuidv1();

  client.create({
    index: '.kibana',
    type: 'doc',
    //id: 'visualization:' + _id,
    body: _source,
    refresh: true
  }).then(function (response) {
    console.log('visualization was created:' + response._id);
  },
  function(error){
    console.log('Error creating visualization:' + error);
  })

```

; where \_source variable is this JSON:  
{  
"type":"visualization",  
"visualization":{  
"title":"dashboarder - Average wait time (OEM)",  
"visState": "{"title":"dashboarder - Average wait time (OEM)","type":"timelion","params":{"expression":".es(index=oem-control-file-sequential-read\*).label("control-file-sequential-read [ms]"), \n.es(index=oem-db-file-scattered-read\*).label("db-file-scattered-read [ms]"),\n.es(index=oem-db-file-sequential-read\*).label("db-file-sequential-read [ms]"),\n.es(index=oem-direct-path-read\*).label("direct-path-read [ms]"),\n.es(index=oem-direct-path-readtemp\*).label("direct-path-readtemp [ms]"),\n.es(index=oem-log-file-sync\*).label("log-file-sync [ms]"),"interval":"auto"},"aggs":[]}",  
"uiStateJSON": "{}",  
"kibanaSavedObjectMeta": { "searchSourceJSON": "{}" }  
}  
}

If I run this, document is successfully created - I can see it in ".kibana" index via "dev tools", but it does not display in "visualize" tab.

Does anybody have any tips ?  
Thanks 🙂

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [May 2, 2018, 8:37am UTC](https://discuss.elastic.co/t/js-client-create-visualization-in-es-6-2/130196/2 "2018-05-02T08:37:47Z")

</div>

Moved to the Kibana topic

---

<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 30, 2018, 8:37am UTC](https://discuss.elastic.co/t/js-client-create-visualization-in-es-6-2/130196/3 "2018-05-30T08:37:49Z")

</div>

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