Skip to content

Getting the length of a horizontal bar after animation #320

Answered by stockiNail
thoughtassassin asked this question in Q&A
Discussion options

You must be logged in to vote

@thoughtassassin I think you should use getProps method of data element.

Here is the doc from CHART.JS:

  /**
   * Gets the current or final value of each prop. Can return extra properties (whole object).
   * @param {string[]} props - properties to get
   * @param {boolean} [final] - get the final value (animation target)
   * @return {object}
   */
  getProps(props, final) {
   ... 
  }
}

To get the value of width at the end of animation, have a look to following code, taken from you codepen:

offset: function(context) {
  const chart = context.chart;
  const area = chart.chartArea;
  const meta = chart.getDatasetMeta(context.datasetIndex);
  const model = meta.data[context.dataIndex];
  /…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by simonbrunel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #317 on June 09, 2022 14:32.