Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use table format #36

Open
PiotrekOpole opened this issue Apr 4, 2019 · 4 comments
Open

How to use table format #36

PiotrekOpole opened this issue Apr 4, 2019 · 4 comments

Comments

@PiotrekOpole
Copy link

Hi.
Im trying to use the table format but i am stuck in ctrl.tables.
Could u please show an example of using tables in svg panel?

@SwathiMuppalla
Copy link

SwathiMuppalla commented Oct 17, 2019

@MarcusCalidus @saurla @adrien-f Hi,
I am trying to use table format using elastic search. Could you please show an example especially if there are multiple queries?
I have two queries where I am printing individual version and trying to get their values.

Javascript for Version 1:

var version1 = s.select("#g1");
var v1 = version1.selectAll("text");
var vr1 = ctrl.data[0].datapoints[0][0];

But for version 2

var version2 = s.select("#g2");
var v1 = version2.selectAll("text");
var vr1 = ctrl.data[0].datapoints[0][1]; 

I am not getting correct value.
How to retrieve value for multiple queries?

@MarcusCalidus
Copy link
Owner

@SwathiMuppalla
I'm not quite sure how multiple Elasticsearch results are stored in ctrl.data. I guess to access the second result you would have to go for ctrl.data[1]. But unless I see what the data array looks like it is impossible to tell. Maybe try a console.log(ctrl.data); and post the output of the Chrome Developer Console here.

@SwathiMuppalla
Copy link

SwathiMuppalla commented Oct 18, 2019

@MarcusCalidus Thanks for your response.. console.log(ctrl.data); output is
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Something like this

  data: [        
       type: "column",
       name: "Version1",
       dataPoints: [
       { label: "A", y: 58 },
       { label: "B", y: 69 },
       { label: "C", y: 80 },                                    
       { label: "D", y: 74 },
       { label: "E", y: 64 }
       ]
     },
     {
      type: "column",
      name: "Version2",                
      dataPoints: [
      { label: "A", y: 63 },
      { label: "B", y: 73 },
      { label: "C", y: 88 },                                    
      { label: "D", y: 77 },
      { label: "E", y: 60 }
      ]
    }
    ]

First query gives data for Version1

   V1  Count
    A     50
    B     45
    C     35

So ctrl.data[0].datapoints[0][0] gives count of first row = 50
ctrl.data[1].datapoints[0][0] gives count of second row = 45
ctrl.data[2].datapoints[0][0] gives count of third row = 35

Second query gives data for Version2.

V2  Count
A    30
B    25
C    15

I am unable to retrieve the second query data of elasticsearch.
I tried
ctrl.data[0].datapoints[0][1]
ctrl.data[0].datapoints[1][0]
ctrl.data[0].datapoints[1][1]
But gives incorrect data.

Query Inspector has two objects with Object 0 has query 1 response and Object 1 has query 2 response
Screenshot (80)

Thanks,

@SwathiMuppalla
Copy link

SwathiMuppalla commented Oct 22, 2019

@MarcusCalidus I found the solution basically the data is stored sequentially
ctrl.data[0].datapoints[0][0]
ctrl.data[1].datapoints[0][0]
ctrl.data[2].datapoints[0][0]
stores the query 1 value
and
ctrl.data[3].datapoints[0][0]
ctrl.data[4].datapoints[0][0]
ctrl.data[5].datapoints[0][0]
stores the query 2 value..
Based on how many values query 1 has the next consecutive value is of query 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants