JavaScript Custom Cursor Chart - Editor

This example serves as an example for creating a custom cursor for XY charts.

Custom cursors can be required for different purposes - like major structural changes or very application specific styling requirements.

If lesser changes to default cursors are required then please see read about different methods of configuring cursor behavior - ChartXY API reference has good links and explanations to follow.

Custom cursors are most importantly based on LCJS methods that allow solving nearest data points in series from any supplied location.
Custom user interactions and data point solving require solid understanding of different coordinate systems in web and LCJS, which is the primary reason this example exists;

// Add custom action when user moves mouse over series area.
chart.onSeriesBackgroundMouseMove((_, event) => {
    // `event` is a native JavaScript event, which packs the active mouse location in `clientX` and `clientY` properties.
    // it can be used for solving nearest data point ...
    const nearestDataPoint = series.solveNearestFromScreen(event)

    // ... or translated to a pair of Axes
    const mouseLocationAxis = chart.translateCoordinate(event, chart.coordsAxis)
})

In this example, the custom cursor visual is created with internal LCJS user interface components, showcasing a multi-cursor which displays one X coordinate and several Y coordinates at once.

The result table is created by combining LCJS layout elements with UITextBox elements - this allows any kind of value grid to be created.

More custom cursor examples can be found by looking for "cursor" tag in the Interactive Examples gallery - for example, using HTML & CSS for an animated result table or connecting to an UI framework.