JavaScript Chart with Multiple X Axes

Demonstrates how to create a JavaScript Chart with multiple X,Y axis using SciChart.js, High Performance JavaScript Charts

Fullscreen

Edit

 Edit

Docs

drawExample.ts

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

Multiple X Axes Example in JavaScript

Overview

This example demonstrates how to create a high-performance chart with multiple X and Y axes using JavaScript and SciChart.js. Its purpose is to showcase the configuration of two independent pairs of numeric axes along with binding data series via unique axis IDs, while integrating interactive modifiers and custom annotations for an enhanced user experience.

Technical Implementation

The implementation begins by initializing a SciChartSurface with a custom theme. Two sets of NumericAxis are added: the primary (blue) set aligned using axis.alignment = EAxisAlignment.Bottom and EAxisAlignment.Left, and the secondary (orange) set aligned to the EAxisAlignment.Top and EAxisAlignment.Right. Data is generated through a random walk generator, and each data series is bound to its corresponding axis by setting a unique on axis.id. Series can then be registered on a specific axis by setting FastLineRenderableSeries.xAxisId and yAxisId. Interactive modifiers, including YAxisDragModifier, XAxisDragModifier as well as zoom, pan, mouse-wheel zoom and zoom-extents are then added. Developers seeking further details on multi-axis configuration may refer to the Tutorial 08 - Adding Multiple Axis and for interactivity see the Tutorial 03 - Adding Zooming, Panning Behavior.

Features and Capabilities

The chart offers several advanced features:

  • Multiple Axes Styling: Each numeric axis is customized with properties such as axis.alignment, axis.axisBorder, and background styling via axis.backgroundColor, providing distinct visual themes. More details can be found in the Axis Styling docs.
  • Axis Binding: By assigning axis IDs to renderable series, each series is rendered within its designated axis pair, ensuring clear separation and accurate scaling.
  • Interactive Modifiers: Modifiers like XAxisDragModifier, YAxisDragModifier, ZoomPanModifier, and MouseWheelZoomModifier enable dynamic interaction, helping users adjust the view in real time.
  • Annotations: Both native and text annotations are used to overlay contextual information on the chart.
  • WASM Performance: Utilizing a WebAssembly (wasm) context provides superior rendering performance, ensuring the chart remains efficient even with complex datasets. Additional insights are available at Pushing the Boundaries of JavaScript Chart Dashboard Performance.

Integration and Best Practices

Although this example is implemented using JavaScript, it illustrates best practices for resource cleanup and the management of the SciChartSurface lifecycle, as outlined in the Memory Best Practices guide. Even though a React component wrapper is provided for integration into larger applications, the core functionality relies solely on JavaScript, making it adaptable across various frameworks. This approach ensures that developers can easily integrate and expand upon the chart in different environments without the overhead of additional abstraction layers.

javascript Chart Examples & Demos

See Also: Chart Axis APIs (11 Demos)

JavaScript Chart with Secondary Y Axes | SciChart.js Demo

JavaScript Chart with Secondary Y Axes

Demonstrates Secondary Y Axis on a JavaScript Chart using SciChart.js. SciChart supports unlimited, multiple left, right, top, bottom X, Y axis with configurable alignment and individual zooming, panning

JavaScript Vertical Charts | Javascript Charts | SciChart.js

JavaScript Vertical Charts

Demonstrates alignment of Axis to create a vertical chart with SciChart.js - JavaScript Charts.

JavaScript Chart with Central Axes | SciChart.js Demo

JavaScript Chart with Central Axes

Demonstrates Central Axes on a JavaScript Chart using SciChart.js. SciChart supports unlimited left, right, top, bottom X, Y axis with configurable layout

JavaScript Chart with Static X Axis | SciChart.js Demo

JavaScript Chart with Static X Axis

Demonstrates isStaticAxis on a JavaScript Chart using SciChart.js.

JavaScript Chart with Vertically Stacked Axes | SciChart

JavaScript Chart with Vertically Stacked Axes

Demonstrates Vertically Stacked Axes on a JavaScript Chart using SciChart.js, allowing data to overlap

JavaScript Chart with Logarithmic Axis Example | SciChart

JavaScript Chart with Logarithmic Axis Example

Demonstrates Logarithmic Axis on a JavaScript Chart using SciChart.js. SciChart supports logarithmic axis with scientific or engineering notation and positive and negative values

NEW!
JavaScript Chart with DiscontinuousDateAxis Comparison

DiscontinuousDateAxis Comparison with Javascript

NEW!
JavaScript Chart with BaseValue Axes | SciChart.js Demo

JavaScript Chart with BaseValue Axes

Demonstrates BaseValue Axes on a JavaScript Chart using SciChart.js to create non-linear and custom-scaled axes such as log-like scales

Draw JavaScript Chart Behind Axis | SciChart.js Demo

Draw JavaScript Chart Behind Axis

Demonstrates the option of the transparent Axes customization on a JavaScript Chart using SciChart.js.

Axis Types | Javascript Charts | SciChart.js Demo

Axis Types

Demonstrates how to use arbitrary text for axis labels, rather than formatted data values, using the new TextLabelProvider

JavaScript Chart Axis Layout Options | SciChart.js Demo

JavaScript Chart Axis Layout Options

Demonstrates outer, inner, central and stacked axes, and use of axis alignment to create vertical charts

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