Skip to content

xAdjust scriptable context not working properly #726

@d0ublezer0

Description

@d0ublezer0

I want adjust label position according to his width with this code:

{
      drawTime: 'beforeDraw',
      type: 'label',
      color: 'rgba(0, 32, 51, 0.6)',
      font: {
        size: 10,
      },
      xValue: x,
      xAdjust: ctx => {
        console.log('el', ctx.element); // get element with width
        console.log('el w', ctx.element.width); // undefined
        // return ctx.element ? -(ctx.element.width/2) : 0
        return -130;
      },
      yValue: y,
      textAlign: 'right',
      content: [trend.string, `R2: ${trend.r2}`],
      enabled: true
    };

But element.width sometime is undefined. How to resolve this?
Screenshot at Apr 12 16-29-04

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions