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

Error in visualization #43

Closed
MrKuip opened this issue Apr 25, 2019 · 7 comments
Closed

Error in visualization #43

MrKuip opened this issue Apr 25, 2019 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@MrKuip
Copy link

MrKuip commented Apr 25, 2019

I get a popup when I run a vizualisation that has a datasweet formula.
The message is:

Error in visualisation
Cannot read property '0' or undefined.

The vizualization is a horizontal barchart with a datasweet formula: "100" (So just a number).
It happens with the following 2 circumstances (both must be true):

  1. I select a time range that has 0 (zero) documents.
  2. I have a terms-bucket

I do NOT get an error when (either of the 2)

  1. I select a time range with more than 0 (zero) documents.
  2. I do not have a terms-bucket (or if I change the terms-bucket into an range-bucket)

I'm using elasticsearch/ kibana 6.6.2

@lfroment-datasweet
Copy link

Hi, Datasweet Formula is intended only to compute some stuff from another metric or bucket set in your viz. You are trying to make it work without any reference to another metric/bucket, am I right?

@MrKuip
Copy link
Author

MrKuip commented Apr 25, 2019

No, i have 2 metrics defined.
I changed the formula from '(agg1 / agg3) * 1000' to '1000' because I wanted to see if the formula was the problem.
Did you try it the way I described?
Should I post the export of my visualization?
It happens with a term bucket and a timerange that results in 0 documents

@lfroment-datasweet
Copy link

lfroment-datasweet commented Apr 25, 2019

OK, I reproduced. Indeed in a "no document found" situation, Kibana throws "no result found" if a bucket split is active, and a "0" if no bucket split is active (or Range bucket split). Same problem with or without Datasweet-Formula implied.
So in the first case, Formula cannot calculate anything based on a "nil", thus, you got an error.
In the second case, Formula does its job : 0/1000=0.

@MrKuip
Copy link
Author

MrKuip commented Apr 26, 2019

Are you saying that the problem is in Kibana and not in datasweet?

I still think it is in datasweet.
I only get the error if I add an aggregation of type 'Datasweet Formula'.
Any other agregation does not produce this error

I think the execution of the formula throws the error.

  • If I have '1000' in the formula I get the error.
  • If I have a blanco formula I do not get the error.
    So my reasoning is that the error is thrown when the formula is executed.

@lfroment-datasweet
Copy link

The error is generated by the plugin, because Kibana output is a "no result found". When Kibana output is a zero, the plugin does its job.

@MrKuip
Copy link
Author

MrKuip commented Apr 26, 2019

I never ever programmed in javascript but I think I solved the problem.

In file './decorators/lib/apply_formula.js' I changed a line in function 'mutate'.
This is the original line:
const isRowValue = isObject(table.rows[0][0]);
I changed it in:
const isRowValue = isObject(table.rows[0]) && isObject(table.rows[0][0]);

The now get a nice 'no results found' message in my visualization.

@lfroment-datasweet
Copy link

@tcharlot-datasweet

@charlotth charlotth self-assigned this Apr 26, 2019
@charlotth charlotth added the bug Something isn't working label Apr 26, 2019
charlotth pushed a commit that referenced this issue Apr 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants