How to create a Market Depth (Order Book) JavaScript Chart using Mountain Series and a Custom Modifier
This example demonstrates how to build a high-performance Market Depth Chart using JavaScript and SciChart.js. It visualizes cumulative buy and sell order book data with two mountain series and a bespoke custom modifier that enhances mouse interactions, annotations, and hit testing.
The chart is initialized via the drawExample function which creates a SciChartSurface, configures NumericAxis, and instantiates two FastMountainRenderableSeries for buy and sell data. The custom modifier, DepthCursorModifier, is implemented directly using the core SciChart.js API to manage mouse events, dynamic annotations, and coordinate transformations. Developers can explore advanced customization through the Custom Chart Modifier API, which is leveraged to handle tasks such as updating crosshair lines and markers based on real-time mouse movement. The implementation also employs accurate hit testing using the RenderableSeries Hit-Test API and transforms canvas coordinates to data coordinates using the Axis APIs - Convert Pixel to Data Coordinates.
Key features include real-time updating of annotations, dynamic highlighting of data points, and robust mouse event handling that provides a seamless interactive experience. The chart efficiently computes the mid-price between buy and sell data points and highlights the interactive region with crosshair annotations.
This example follows best practices for resource management in JavaScript by providing a cleanup (destructor) function that disposes of the SciChartSurface when no longer needed. Additionally, performance optimizations are achieved through careful DPI scaling and efficient update routines as described in the Performance Tips & Tricks documentation. The implementation reinforces principles for developing high-performance, interactive charts while maintaining clear separation of concerns and robust handling of chart events.

Discover how to create a JavaScript Candlestick Chart or Stock Chart using SciChart.js. For high Performance JavaScript Charts, get your free demo now.

Easily create JavaScript OHLC Chart or Stock Chart using feature-rich SciChart.js chart library. Supports custom colors. Get your free trial now.

Create a JavaScript Realtime Ticking Candlestick / Stock Chart with live ticking and updating, using the high performance SciChart.js chart library. Get free demo now.

Create a Javascript heatmap chart showing historical orderbook levels using the high performance SciChart.js chart library. Get free demo now.

Create a JavaScript Multi-Pane Candlestick / Stock Chart with indicator panels, synchronized zooming, panning and cursors. Get your free trial of SciChart.js now.

Demonstrating the capability of SciChart.js to create a composite 2D & 3D Chart application. An example like this could be used to visualize Tenor curves in a financial setting, or other 2D/3D data combined on a single screen.

Create a JavaScript Multi-Pane Candlestick / Stock Chart with indicator panels, synchronized zooming, panning and cursors. Get your free trial of SciChart.js now.

Demonstrates how to place Buy/Sell arrow markers on a JavaScript Stock Chart using SciChart.js - Annotations API

This demo shows you how to create a <strong>{frameworkName} User Annotated Stock Chart</strong> using SciChart.js. Custom modifiers allow you to add lines and markers, then use the built in serialisation functions to save and reload the chart, including the data and all your custom annotations.