showHint method

void showHint(
  1. String label,
  2. Point<num> point
)

Shows a hint with label at point in canvas.

Implementation

void showHint(String label, Point<num> point) {
  //print('showHint> $label ; $point');

  hideHint();

  var arrowSize = 6;

  num x = point.x * (1 / offsetWidthRatio);
  num y = point.y * (1 / offsetHeightRatio);

  x += canvas.offset.left - (8 + arrowSize - 1);
  y += canvas.offset.top + arrowSize;

  var hint = DivElement()
    ..style.textAlign = 'center'
    ..style.borderRadius = '6px'
    ..style.padding = '6px 6px'
    ..style.position = 'absolute'
    ..style.zIndex = '999999'
    ..style.left = '${x}px'
    ..style.top = '${y}px'
    ..style.backgroundColor = 'rgba(0,0,0, 0.70)'
    ..style.color = 'rgba(255,255,255, 0.70)'
    ..style.pointerEvents = 'none';

  hint.text = label;

  var arrow = DivElement()
    ..style.left = '8px'
    ..style.top = '0px'
    ..style.position = 'absolute'
    ..style.transform = 'translate(0%, -100%)'
    ..style.width = '0'
    ..style.height = '0'
    ..style.borderLeft = '${arrowSize - 1}px solid transparent'
    ..style.borderRight = '${arrowSize - 1}px solid transparent'
    ..style.borderBottom = '${arrowSize}px solid rgba(0,0,0, 0.70)';

  hint.append(arrow);

  canvas.parent!.children.add(hint);

  _currentHint = hint;
}