Pre loader

Select Points in 3D charts (JavaScript)

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0
0

Hello,

I’ve observed that SciChart JavaScript does not currently support point selection or hit testing for 3D charts. Is there a method or workaround to implement point selection in 3D charts?

It would be helpful to obtain the coordinates of the selected point if such functionality is available.

Thank you for your assistance.

I attempted to use the Custom Modifier to capture point selection in a 3D chart, but I only received the screen coordinates of the mouse click, not the 3D coordinates of the point.

Is there a way to obtain the 3D coordinates of a selected point in Sci Chart JavaScript, or is there an alternative approach that can be used to achieve this?

i have included my attempt at this in the post.

Version
3.3.560
Attachments
  • You must to post comments
0
0

Hello! To get the Data Value coordinates of a point on a chart you can apply the HitTest API.
Some related pages:
Hit Test API Documentation
Hit Test API UsageExample

In your case, for a 3D chart, you can try creating a custom modifier like this:
Live Example

class CustomModifier extends ChartModifierBase3D {
public onAttach() {
  super.onAttach();
  if (this.parentSurface) {
    // Globally enable hit-test and selection pass (comes with a minor performance hit)
    this.parentSurface.isHitTestEnabled = true;
  }
}

modifierMouseDown(args: ModifierMouseArgs) {
  super.modifierMouseDown(args);

  const { x, y } = args.mousePoint;

  const seriesInfo = this.parentSurface.renderableSeries
    .asArray()
    .map((rs) => rs.hitTest(args.mousePoint))
    .find((result) => result.isHit);

  if (seriesInfo?.isHit) {
    const xyzSeriesInfo = seriesInfo as XyzSeriesInfo3D;
    if (xyzSeriesInfo.dataSeriesIndex) {
      console.log(
        `... XYZ Series hit = ${seriesInfo.dataSeriesName ?? "Unknown"}`
      );
      console.log(`... Index at ${xyzSeriesInfo.dataSeriesIndex}`);
      console.log(
        `... World coords at ${seriesInfo.hitWorldCoords.toString()}`
      );
      console.log(
        `... Data at ${seriesInfo.xValue}, ${seriesInfo.yValue}, ${seriesInfo.zValue}`
      );
    }
    const heightMapSeriesInfo = seriesInfo as SurfaceMeshSeriesInfo3D;
    if (heightMapSeriesInfo.xIndex && heightMapSeriesInfo.zIndex) {
      console.log(
        `... Mesh Series hit = ${seriesInfo.dataSeriesName ?? "Unknown"}`
      );
      console.log(
        `... X,Z index at ${heightMapSeriesInfo.xIndex}, ${heightMapSeriesInfo.zIndex}`
      );
      console.log(
        `... World coords at ${seriesInfo.hitWorldCoords.toString()}`
      );
      console.log(
        `... Data at ${seriesInfo.xValue}, ${seriesInfo.yValue}, ${seriesInfo.zValue}`
      );
    }
  }
}
}
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.