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

[bug fixes] annotations <> x domains, zeros in text #4194

Merged
merged 3 commits into from
Mar 15, 2018

Conversation

williaster
Copy link
Contributor

This PR fixes a couple bugs related to annotation usage

  • when adding x-interval annotations to time series charts, the x-scale domain does not account for the annotation data. I updated the logic to account for this.
  • when playing with annotations I noticed that you cannot currently enter a 0 in a TextControl component because the control only updates to values that evaluate truthy. I updated the logic to actually check for a value.

in examples below I added (interval or event) annotations with a table slice data source.

before (annotations clipped)
screen shot 2018-01-10 at 4 36 38 pm

after (annotations included)
screen shot 2018-01-10 at 4 36 38 pm

@mistercrunch @fabianmenges @graceguo-supercat @michellethomas

some other bugs I noted but didn't fix:

  • if the source for event or interval annotations is a table, passing down "from" and "until" should actually perform a filter on the table columns defined by "interval start column" (and "interval end column"), not on the slices "from" and "until" form data.
  • you can't set a y-max on a chart (looked into it, tricky with nvd3 without computing your own domain; I think we should fix with data-ui integration)

@williaster williaster changed the title [bug fixes] annotations, dynamic width, zeros in text [bug fixes] annotations <> x domains, zeros in text Jan 11, 2018
@mistercrunch
Copy link
Member

@fabianmenges is the best person to review this

@fabianmenges
Copy link
Contributor

I'll first comment on this:

if the source for event or interval annotations is a table, passing down "from" and "until" should actually perform a filter on the table columns defined by "interval start column" (and "interval end column"), not on the slices "from" and "until" form data.

I don't really think this is a bug but a use case that wasn't covered. The concepts of until and since are different from any other filter in Superset and the only ones I implemented.

That said, I thought about similar use cases before and there are some foundations you can use to do what you want to do.

Take a look here:
https://github.com/apache/incubator-superset/blob/04680e5ff138f7113a3d655133307049bc91ff3d/superset/assets/javascripts/explore/components/controls/AnnotationLayer.jsx#L408

This line will override the since field of the annotation slice to use the since value of the current slice. The logic that does that is here:

https://github.com/apache/incubator-superset/blob/04680e5ff138f7113a3d655133307049bc91ff3d/superset/assets/javascripts/chart/chartAction.js#L71

Now, in order to implement what you described you will need to add something like this to the AnnotationLayer:

this.setState({ overrides: { ...overrides, filters: [
  { col: timeColumn, op: '>', val: :  'since' },
  { col: intervalEndColumn, op: '<', val: :  'until' },
] } });

And make changes to the chartAction that appends/transforms the filters correctly. This will be pretty tricky to get working in a flexible way.

}).filter((r) => {
const isValid = !Number.isNaN(r[e.timeColumn].getMilliseconds());
if (isValid) {
xMin = xMin < r[e.timeColumn] ? xMin : r[e.timeColumn];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its a bit weird that the filtering here has side effects. Might be cleaner to find the min and max values in that series after filtering.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

!Number.isNaN(r[e.intervalEndColumn].getMilliseconds())
);
if (isValid) {
xMin = xMin < r[e.timeColumn] ? xMin : r[e.timeColumn];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code currently does not really check that timeColumn < intervalEndColumn and will flip them around when necessary. Not sure if we need to handle that though.

@mistercrunch
Copy link
Member

@williaster let's try to get this through, please resolve conflict and merge when you have a moment

@williaster
Copy link
Contributor Author

@mistercrunch will try to get this done today

@williaster
Copy link
Contributor Author

I think annotations are broken in production, so will debug that as part of this.

@williaster
Copy link
Contributor Author

fixed annotations separately in #4607, updated this PR / should be good to go so PTAL 👀

@codecov-io
Copy link

Codecov Report

Merging #4194 into master will decrease coverage by <.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4194      +/-   ##
==========================================
- Coverage   71.18%   71.18%   -0.01%     
==========================================
  Files         189      189              
  Lines       14847    14848       +1     
  Branches     1086     1085       -1     
==========================================
  Hits        10569    10569              
- Misses       4275     4276       +1     
  Partials        3        3
Impacted Files Coverage Δ
...cripts/explore/components/controls/TextControl.jsx 45.45% <0%> (-1.43%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update de44098...9ac4918. Read the comment docs.

@williaster
Copy link
Contributor Author

@mistercrunch @fabianmenges going to merge this if no objections

@graceguo-supercat
Copy link

LGTM

@graceguo-supercat graceguo-supercat merged commit e2bd40c into apache:master Mar 15, 2018
@williaster williaster deleted the chris--annotation-fixes branch March 15, 2018 22:20
graceguo-supercat pushed a commit to graceguo-supercat/superset that referenced this pull request Mar 15, 2018
* [bugs] account for annotations in nvd3 x scale domain, fix dynamic width explore charts, allow 0 in text control

* tweak TextControl casting

* [annotations] filter separately from finding data extent

(cherry picked from commit e2bd40c)
michellethomas pushed a commit to michellethomas/panoramix that referenced this pull request May 24, 2018
* [bugs] account for annotations in nvd3 x scale domain, fix dynamic width explore charts, allow 0 in text control

* tweak TextControl casting

* [annotations] filter separately from finding data extent
wenchma pushed a commit to wenchma/incubator-superset that referenced this pull request Nov 16, 2018
* [bugs] account for annotations in nvd3 x scale domain, fix dynamic width explore charts, allow 0 in text control

* tweak TextControl casting

* [annotations] filter separately from finding data extent
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.24.0 labels Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.24.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants