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

feat(annotations): add annotations to DebugState #1434

Merged
merged 25 commits into from
Nov 17, 2021

Conversation

rshen91
Copy link
Contributor

@rshen91 rshen91 commented Oct 18, 2021

Summary

Annotations are now added to debugState.

Details

The DebugStateAnnotations interface includes a data attribute which ultimately takes in an any type. I would like to restrict this if possible but it's from the dataValues off the LineAnnotationSpec or RectAnnotationSpec.

Issues

Closes #1260

Checklist

  • The proper feature labels have been added (e.g. :interactions, :axis)
  • All related issues have been linked (i.e. closes #123, fixes #123)
  • New public API exports have been added to packages/charts/src/index.ts

@rshen91 rshen91 changed the title feat(debug): add annotations to DebugState feat(annotations): add annotations to DebugState Oct 18, 2021
@rshen91 rshen91 added :annotation Annotation (line, rect, text) related issue :chart Chart element related issue enhancement New feature or request labels Oct 27, 2021
@rshen91 rshen91 marked this pull request as ready for review October 27, 2021 21:47
@rshen91 rshen91 requested review from markov00 and nickofthyme and removed request for markov00 October 28, 2021 13:53
Comment on lines 113 to 114
// API Extractor failing with LineAnnotationDatum | RectAnnotation, the dataValue in get_debug_state can be any value
data?: any;
Copy link
Member

Choose a reason for hiding this comment

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

can you please describe the API extractor failure?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I get warnings when changing the type from any that result in the yarn api:check failing with results expected same but got worse but now when Im running it, it's not producing those errors d5591a0 for changes

Copy link
Member

Choose a reason for hiding this comment

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

yep now it looks good no?
can you remove the comment on the code?
// API Extractor failing with LineAnnotationDatum | RectAnnotationDatum, the dataValue in get_debug_state can be any value

@rshen91 rshen91 requested a review from markov00 November 1, 2021 16:45
: {
id: annotation.id,
color: annotation?.style,
data: annotation.dataValues[index],
Copy link
Member

Choose a reason for hiding this comment

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

This is an invalid array access: the index is the index of the annotationSpecs array, but here you want to enumerate the dataValues array. You should rewrite the code to return an DebugStateAnnotations per each element into the dataValues array of each spec

Copy link
Contributor Author

@rshen91 rshen91 Nov 3, 2021

Choose a reason for hiding this comment

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

Ok awesome I think I'm following commit isn't showing on github right now but it's 0d4024 in my local environment and it looks like the CI is running.

For the click handle rect story with multiple rectangle and a line annotation, the debug state looks as follows:

'annotations':
  [{'data':{'coordinates':{'x0':0,'x1':1,'y0':0,'y1':4},'details':'details about this annotation'},
    'id':'rect1',
    'color':{'stroke':'#FFEEBC','strokeWidth':0,'opacity':0.25,'fill':'red'},
    'type':'rectangle'},
  {'data':{'coordinates':{'x0':0.8,'x1':2,'y0':1,'y1':5},'details':'details about this other annotation'},
    'id':'rect2',
    'color':{'stroke':'#FFEEBC','strokeWidth':0,'opacity':0.25,'fill':'blue'},
    'type':'rectangle'},
  {'data':{'dataValue':2,'details':'detail-0'},
    'id':'line_annotation',
    'color':{'line':{'stroke':'#777','strokeWidth':1,'opacity':1},
    'details':{'fontSize':10,'fontFamily':'sans-serif','fontStyle':'normal','fill':'#777','padding':0}},'type':'line',
    'domainType':'xDomain'}
  ]}">

@rshen91 rshen91 requested a review from markov00 November 3, 2021 14:57
Copy link
Collaborator

@nickofthyme nickofthyme left a comment

Choose a reason for hiding this comment

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

LGTM, please review the changes I added in c4dc3a9.

Comment on lines 17 to 26
export {
DebugState,
DebugStateLine,
DebugStateValue,
DebugStateAnnotations,
DebugStateArea,
DebugStateAxes,
DebugStateBar,
DebugStateLegend,
} from './state/types';
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't know that we really need to export all of these. Generally I look at it as "is someone gonna use this on its own". For instance the Theme people may define LegendStyles on its own and thus would require us to export it.

In this case however, I see the debug state being readonly, such that people say this state value should be x, and not setting downstream values of the debug state.

@markov00 thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

Isn't easier for them to know the shape of the debug state if we export the used types?

@rshen91
Copy link
Contributor Author

rshen91 commented Nov 10, 2021

jenkins test this please

@rshen91 rshen91 requested a review from markov00 November 17, 2021 16:27
Copy link
Member

@markov00 markov00 left a comment

Choose a reason for hiding this comment

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

It looks good for me!
Thanks for all the changes on the exposed APIs

@rshen91 rshen91 merged commit c5ea600 into elastic:master Nov 17, 2021
nickofthyme pushed a commit that referenced this pull request Nov 18, 2021
# [40.0.0](v39.0.2...v40.0.0) (2021-11-18)

### Bug Fixes

* **interactions:** remove the option for pixelRatio with png snapshot ([#1431](#1431)) ([eebb069](eebb069))
* **xy:** occlude points outside of y domain ([#1475](#1475)) ([3176f02](3176f02))

### Features

* **annotations:** add annotations to DebugState ([#1434](#1434)) ([c5ea600](c5ea600))
* **heatmap:** add valueShown in heatmap debug state ([#1460](#1460)) ([962e089](962e089))

### BREAKING CHANGES

* **interactions:** The getPNGSnapshot function no longer has an option for pixelRatio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:annotation Annotation (line, rect, text) related issue :chart Chart element related issue enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add annotations data to data-ech-debug-state
3 participants