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

timelion secondary y axis removes configuration of the first one #9114

Closed
ppisljar opened this issue Nov 17, 2016 · 10 comments · Fixed by #9197
Closed

timelion secondary y axis removes configuration of the first one #9114

ppisljar opened this issue Nov 17, 2016 · 10 comments · Fixed by #9197
Labels
bug Fixes for quality problems that affect the customer experience Feature:Timelion Timelion app and visualization Feature:Visualizations Generic visualization features (in case no more specific feature label is available) v5.1.1

Comments

@ppisljar
Copy link
Member

in the latest master when you set a secondary y axis on timelion it would remove all the configuration you set on the first one (so the first one behaves like a default axis)

for example
(.static(4000), .static(5000), .static(6000)).yaxis(min=5000, position=right), .static(3000).yaxis(2, position=left)

will show both axes on the left (position=right on the first axis will get ignored)

@ppisljar ppisljar added Feature:Timelion Timelion app and visualization bug Fixes for quality problems that affect the customer experience labels Nov 17, 2016
@ppisljar
Copy link
Member Author

@rashidkpc the issue seems to be that somewhere (if you can help me point where i would really appreciate it) on the way from server to client undefined's get converted to null's ...

_.merge function here will overwrite all values from the first array with nulls from the second (but it wouldn't do so with undefined) ... the null condition doesnt work on array elements or nested objects.

@manuelbernhardt
Copy link

I don't know if this is the exact same bug, but there seems to be a rather odd behaviour when having multiple y-axis (we have 7 in one graph) - the position in which the series are being declared influences the rendering. I.e. series declared in the beginning will see their yaxis options being ignored.

@ppisljar
Copy link
Member Author

@manuelbernhardt seems to be the same issue

@manuelbernhardt
Copy link

manuelbernhardt commented Nov 22, 2016

It's actually pretty easy to reproduce this one:

.static(70).yaxis(2, min=0, max=100, label="70") .static(2).yaxis(3, min=0, max=5, label="2")  .static(20).yaxis(1, min=0, max=100, label="20")

Moving the first static(70) to the last position will make it behave correctly, but then one of the other axes won't see its option honoured.

Note that I observe this behaviour both on the 5.x branch and on a deployed 5.0 version of Kibana

@manuelbernhardt
Copy link

I found the cause. For some reason, the _global.yaxes parameter of the series looks like this

s1: [null, null, { ... }]
s2: [{ ... }]
s3: [null, { ... }]

The result that needs to be passed down to flot needs to be an yaxes array in which each object is at the Nth position, where N is the value of yaxis in the series.

Quoting the lodash doc: Subsequent sources overwrite property assignments of previous sources. This is to say that the current merge code overwrites subsequent values (array values get overwritten by subsequent nulls when two arrays get merged).

I'm seeing if I can come up with a solution, but it will most certainly contain a special treatment for yaxis rather than a global merge

@ppisljar
Copy link
Member Author

@manuelbernhardt _merge would work if those values would be undefined instead of null.
that is the case on the server side ... but somewhere along passing it down to client undefineds get converted to nulls ...
i didn't find exactly where this happens, but that would probably be a good place to fix this.

@manuelbernhardt
Copy link

This is where the data is pulled from the server I think.

AFAIK undefined is not part of JSON. So even if the response of the server contains "undefined", it will be turned into its JSON equivalent null automatically.

@rashidkpc
Copy link
Contributor

@ppisljar pretty sure this will fix it.

--- a/src/core_plugins/timelion/public/panels/timechart/schema.js
+++ b/src/core_plugins/timelion/public/panels/timechart/schema.js
@@ -222,7 +222,7 @@ module.exports = function timechartFn(Private, config, $rootScope, timefilter, $
               _.merge(options, series._global, function (objVal, srcVal) {
                 // This is kind of gross, it means that you can't replace a global value with a null
                 // best you can do is an empty string. Deal with it.
-                if (objVal == null) return srcVal;
+                if (srcVal == null) return objVal;
               });
             }

@manuelbernhardt
Copy link

@rashidkpc @ppisljar I can confirm that this fixes it, thanks! I backported it to a 5.0 deployment, will this make it into one of the next 5.x releases?

@rashidkpc
Copy link
Contributor

@manuelbernhardt yeah, this will go into 5.x

ppisljar added a commit that referenced this issue Nov 23, 2016
@tbragin tbragin added the Feature:Visualizations Generic visualization features (in case no more specific feature label is available) label Nov 23, 2016
elastic-jasper added a commit that referenced this issue Nov 23, 2016
Backports PR #9197

**Commit 1:**
fixing timelion Y axis #9114

* Original sha: 54107d6
* Authored by ppisljar <[email protected]> on 2016-11-23T09:37:52Z
epixa pushed a commit that referenced this issue Nov 23, 2016
Backports PR #9197

**Commit 1:**
fixing timelion Y axis #9114

* Original sha: 54107d6
* Authored by ppisljar <[email protected]> on 2016-11-23T09:37:52Z
elastic-jasper added a commit that referenced this issue Nov 23, 2016
Backports PR #9197

**Commit 1:**
fixing timelion Y axis #9114

* Original sha: 54107d6
* Authored by ppisljar <[email protected]> on 2016-11-23T09:37:52Z
epixa pushed a commit that referenced this issue Nov 23, 2016
…9200)

Backports PR #9197

**Commit 1:**
fixing timelion Y axis #9114

* Original sha: 54107d6
* Authored by ppisljar <[email protected]> on 2016-11-23T09:37:52Z
@tbragin tbragin added the v5.1.1 label Dec 8, 2016
airow pushed a commit to airow/kibana that referenced this issue Feb 16, 2017
…lastic#9200)

Backports PR elastic#9197

**Commit 1:**
fixing timelion Y axis elastic#9114

* Original sha: 54107d6
* Authored by ppisljar <[email protected]> on 2016-11-23T09:37:52Z

Former-commit-id: accc45c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Feature:Timelion Timelion app and visualization Feature:Visualizations Generic visualization features (in case no more specific feature label is available) v5.1.1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants