JavaScript Chart Hoverable Buy Sell Marker Annotations

Demonstrates how to add Hoverable Buy/Sell Markers (annotations) and News/Dividend bullets to a JavaScript Stock Chart using SciChart.js, High Performance JavaScript Charts

Fullscreen

Edit

 Edit

Docs

drawExample.ts

Copy to clipboard
Minimise
Fullscreen
1// Loading ... 

Trade Markers Example - JavaScript

Overview

This example demonstrates how to integrate SciChart.js using JavaScript to create a high performance stock chart that features interactive buy/sell markers and news/dividend annotations. The implementation focuses on asynchronous chart initialization, dynamic annotation management, and performance optimization via WebGL rendering.

Technical Implementation

The chart is initialized asynchronously using async/await together with Promise.all() to fetch simulated trading data and set up the SciChartSurface. A CategoryAxis is used for displaying dates (see The Category Axis) and NumericAxis represent pricing and additional metrics. Custom SVG-based annotations are created for buy and sell markers, and dynamic hover functionality is implemented via the AnnotationHoverModifier (see Annotation Hover API), which binds event handlers for interactive tooltips. Efficient chart rendering is achieved through WebGL, as detailed in Performance Tips & Tricks.

Features and Capabilities

The example simulates real-time trading actions by dynamically adding annotations based on randomized trading data. It supports advanced multi-axis layout configurations using techniques similar to those described for vertically and horizontally stacked axes. Interactive features such as hoverable annotations provide immediate trade details, and dynamically added news bullets give contextual information, enhancing user engagement. Additionally, the integration of custom SVG strings for marker design showcases how developers can tailor the visual appearance of annotations.

Integration and Best Practices

Designed for JavaScript applications, the example cleanly separates the initialization logic in a dedicated function that takes a DOM element as the chart container. This modular approach simplifies lifecycle management and cleanup via a destructor function. Developers are encouraged to follow these best practices, as explained in resources for asynchronous initialization in JavaScript like Sequential promises using async/await in JavaScript to enhance maintainability and performance. Furthermore, the use of custom event subscriptions and dynamic annotation management illustrates best practices for interactive charting solutions.

javascript Chart Examples & Demos

See Also: Financial Charts (11 Demos)

JavaScript Candlestick Chart | Online JavaScript Chart Examples

JavaScript Candlestick Chart

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

JavaScript OHLC Chart | Javascript Charts | SciChart.js Demo

JavaScript OHLC Chart

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

JavaScript Realtime Ticking Stock Chart | SciChart.js

JavaScript Realtime Ticking Stock Charts

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.

NEW!
JavaScript Orderbook Heatmap | Javascript Charts | SciChart.js

JavaScript Orderbook Heatmap

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

JavaScript Multi-Pane Stock Chart using Subcharts | View JavaScript Charts

JavaScript Multi-Pane Stock Charts using Subcharts

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

Tenor Curves Demo | Javascript Charts | SciChart.js Demo

Tenor Curves Demo

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.

JavaScript Multi-Pane Stock Chart | View JavaScript Charts

JavaScript Multi-Pane Stock Charts using Sync Multi-Chart

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

JavaScript Market Depth Chart | Javascript Charts | SciChart.js

JavaScript Market Depth Chart

Create a JavaScript Depth Chart, using the high performance SciChart.js chart library. Get free demo now.

JavaScript User Annotated Stock Chart | SciChart.js Demo

JavaScript User Annotated Stock Chart

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.

NEW!
JavaScript Trading Drawing Tools | Javascript Charts | SciChart.js

JavaScript Trading Drawing Tools

Create an interactive JavaScript trading charts for technical analysis. Trading Drawing Tools Demo, which shows how to use Polylines, Extended Lines, Rays, Channels, Pitchforks, Pitchfans, Fibonnaci Retracements, Measure, Stop Loss and Take Profit chart drawing tools for Technical Analysis.

NEW!
JavaScript Freehand Drawing Tools | SciChart.js Demo

JavaScript Freehand Drawing Tools

An example of using JavaScript FreehandDrawingModifier for arbitrary drawing on trading and financial charts. Can be used for drawing trends, arrow, markers, text, etc.

SciChart Ltd, 16 Beaufort Court, Admirals Way, Docklands, London, E14 9XL.