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

Add beforeDraw and afterDraw hooks to the annotations #744

Merged
merged 28 commits into from
Jan 27, 2023
Merged

Add beforeDraw and afterDraw hooks to the annotations #744

merged 28 commits into from
Jan 27, 2023

Conversation

stockiNail
Copy link
Collaborator

@stockiNail stockiNail commented May 21, 2022

This PR is adding before/after draw hooks in order to allow the user to apply whatever needed customization on out-of the-box annotations. Fix #146.

The hooks will be invoked once for every annotation for each drawing cycle.

plugins: {
  annotation: {
    annotations: {
      line: {
        type: 'line',
        ....
        beforeDraw(context) {
          console.log('beforeDraw');
        },
        afterDraw(context) {
          console.log('afterDraw');
        },
      },
    }
  }
}
Hook Arguments Return type Default Description
beforeDraw context void annotation.beforeDraw invoked before the element drawing
afterDraw context void annotation.afterDraw invoked after the element drawing

Common hooks for all annotations can be set in the annotation plugin options:

plugins: {
  annotation: {
    beforeDraw(context) {
      console.log('Common beforeDraw');
    },
    afterDraw(context) {
      console.log('Common afterDraw');
    },
    annotations: {
      line: {
        type: 'line',
        ....
      },
    }
  }
}

TODO

  • test cases
  • types
  • documentation
  • samples

@stockiNail stockiNail added this to the 2.0.0 milestone May 21, 2022
@stockiNail stockiNail marked this pull request as ready for review May 23, 2022 11:12
@stockiNail stockiNail modified the milestones: 2.0.0, 2.1.0 Jun 3, 2022
@stockiNail stockiNail marked this pull request as draft July 21, 2022 15:47
@stockiNail stockiNail marked this pull request as ready for review August 5, 2022 10:38
Copy link
Member

@kurkle kurkle left a comment

Choose a reason for hiding this comment

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

I still don't like the counters
How about making it simpler, just draw before/after the main element is drawn?
We could add afterDrawChildren later, if it's really needed.

@stockiNail
Copy link
Collaborator Author

I still don't like the counters
How about making it simpler, just draw before/after the main element is drawn?
We could add afterDrawChildren later, if it's really needed.

I think its reasonable
But Let me take time to review the PR
My memory is not so persistent and I dont remember so well what I wrote

@stockiNail
Copy link
Collaborator Author

stockiNail commented Sep 28, 2022

How about making it simpler, just draw before/after the main element is drawn?

done! review applied!

No counters anymore!

@stockiNail stockiNail modified the milestones: 2.1.0, 2.2.0 Nov 17, 2022
Copy link
Member

@kurkle kurkle left a comment

Choose a reason for hiding this comment

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

Sorry for the huge delay on these. LGTM

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

Successfully merging this pull request may close these issues.

padding issue with drawing an average line
2 participants