Skip to main content

Central Axis Layout

Placing Axis in the center the chart, like an oscilloscope or spectrum analyzer is possible with SciChart.js.

New to Cartesian graphs? Read our guide: Cartesian graph: what it is and how to read it. It covers the x and y axes, the origin, ordered pairs and the four quadrants, with a live chart whose axes cross at (0, 0) and points you can drag to read their coordinates.

To do this, use the CentralAxesLayoutManager📘 applied to the SciChartSurface.LayoutManager📘 property.

Here's a code sample:

// Demonstrates how to configure a central axis in SciChart.js
const { SciChartSurface, NumericAxis, SciChartJsNavyTheme, CentralAxesLayoutManager } = SciChart;

// or, for npm, import { SciChartSurface, ... } from "scichart"

const { wasmContext, sciChartSurface } = await SciChartSurface.create(divElementId, {
theme: new SciChartJsNavyTheme()
});

// Apply the CentralAxesLayoutManager to the SciChartSurface
sciChartSurface.layoutManager = new CentralAxesLayoutManager();

// Add an X, Y Axis
sciChartSurface.xAxes.add(
new NumericAxis(wasmContext, {
// To allow easier visualisation of axis position
backgroundColor: "#50C7E022",
axisBorder: {
borderTop: 1,
color: "#50C7E0"
}
})
);
sciChartSurface.yAxes.add(
new NumericAxis(wasmContext, {
// To allow easier visualisation of axis position
backgroundColor: "#F4842022",
axisBorder: {
borderRight: 1,
color: "#F48420"
}
})
);

This results in the following output:

Configure the Position of Central Axis​

CentralAxesLayoutManager📘 has some options you can use to configure the position of the horizontal and vertical axes.

The following code places an YAxis inside the chart at X=3 and an XAxis inside the chart at Y=100 pixels.

tip

Options available in the EInnerAxisPlacementCoordinateMode📘 enum include: DataValue, Pixel, or Relative, which allows placement of an axis at a fraction of the viewport from 0..1.

// Apply the CentralAxesLayoutManager to the SciChartSurface
sciChartSurface.layoutManager = new CentralAxesLayoutManager({
horizontalAxisPositionCoordinateMode: EInnerAxisPlacementCoordinateMode.DataValue,
verticalAxisPositionCoordinateMode: EInnerAxisPlacementCoordinateMode.Pixel,
horizontalAxisPosition: 3,
verticalAxisPosition: 100
});

// Continue to add your X,Y axis as before

This results in the following output: