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

内置的PointSelector不适合用于计算饼图/日出图等带角度的图表的选中域,能否将Selector开放到Selection中做参数以方便定制化? #274

Open
XiFengLang opened this issue Nov 24, 2023 · 0 comments

Comments

@XiFengLang
Copy link

PointSelector用2点之间的距离筛选出nearestDistance(代码如下),这套算法在饼图和日出图中会算出错误的nearestIndex,导致tooltip展示异常。我还没来得及学习Graphic专业知识,不清楚作者后续是否会增加一个判断角度的AngleSelector,如果Graphic专业领域中不需要AngleSelector,那希望作者开放更多的定制接口,以方便其他开发者定制图表功能。

    final point = coord.invert(points.single);
    if (dim == null) {
      updateNearest = (attributes) {
        final offset = attributes.representPoint - point;
        // The neighborhood is an approximate square.
        final distance = (offset.dx.abs() + offset.dy.abs()) / 2;
        if (distance < nearestDistance) {
          nearestIndex = attributes.index;
          nearestDistance = distance;
        }
      };
    } else {
      final getProjection = dim == Dim.x
          ? (Offset offset) => offset.dx
          : (Offset offset) => offset.dy;
      updateNearest = (attributes) {
        final p = attributes.representPoint;
        final distance = (getProjection(point) - getProjection(p)).abs();
        if (distance < nearestDistance) {
          nearestIndex = attributes.index;
          nearestDistance = distance;
        }
      };
    }
@XiFengLang XiFengLang changed the title 内置的PointSelector不适合用于计算饼图/日出图等带角度的图表的选中域,能否将Selector开放到Selection中做参数,以方便定制化 内置的PointSelector不适合用于计算饼图/日出图等带角度的图表的选中域,能否将Selector开放到Selection中做参数,以方便定制化? Nov 24, 2023
@XiFengLang XiFengLang changed the title 内置的PointSelector不适合用于计算饼图/日出图等带角度的图表的选中域,能否将Selector开放到Selection中做参数,以方便定制化? 内置的PointSelector不适合用于计算饼图/日出图等带角度的图表的选中域,能否将Selector开放到Selection中做参数以方便定制化? Nov 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant