Demonstrates how to create a JavaScript Digital Band Chart or High-Low Fill using SciChart.js. This is our High Performance JavaScript Chart Library
import {
MouseWheelZoomModifier,
ZoomExtentsModifier,
ZoomPanModifier,
XyyDataSeries,
NumericAxis,
FastBandRenderableSeries,
SciChartSurface,
NumberRange,
SweepAnimation,
} from "scichart";
import { appTheme } from "./appTheme";
export const drawExample = async (rootElement: string | HTMLDivElement) => {
// Create a SciChartSurface
const { wasmContext, sciChartSurface } = await SciChartSurface.create(rootElement, {
theme: appTheme.SciChartJsTheme,
});
// Create an XAxis and YAxis
sciChartSurface.xAxes.add(new NumericAxis(wasmContext, { axisTitle: "X Axis" }));
sciChartSurface.yAxes.add(
new NumericAxis(wasmContext, {
growBy: new NumberRange(0.4, 0.4),
axisTitle: "Y Axis",
})
);
// Create some data for the example. We need X, Y and Y1 values
const xValues = [];
const yValues = [];
const y1Values = [];
const POINTS = 50;
const STEP = (3 * Math.PI) / POINTS;
for (let i = 0; i <= POINTS; i++) {
const k = 1 - i / 100;
xValues.push(i);
yValues.push(Math.sin(i * STEP) * k * 0.7);
y1Values.push(Math.cos(i * STEP) * k);
}
// Create the band series and add to the chart
// The bandseries requires a special dataseries type called XyyDataSeries with X,Y and Y1 values
sciChartSurface.renderableSeries.add(
new FastBandRenderableSeries(wasmContext, {
dataSeries: new XyyDataSeries(wasmContext, { xValues, yValues, y1Values }),
strokeThickness: 3,
fill: appTheme.VividOrange + "33",
fillY1: appTheme.VividSkyBlue + "33",
stroke: appTheme.VividOrange,
strokeY1: appTheme.VividSkyBlue,
isDigitalLine: true,
animation: new SweepAnimation({ duration: 800 }),
})
);
// Optional: Add some interactivity modifiers
sciChartSurface.chartModifiers.add(
new ZoomExtentsModifier(),
new ZoomPanModifier({ enableZoom: true }),
new MouseWheelZoomModifier()
);
return { wasmContext, sciChartSurface };
};
This example demonstrates how to create a high-performance digital band chart using SciChart.js in JavaScript. The implementation renders a digital band series with upper and lower fill effects, leveraging the capabilities of the XyyDataSeries to handle X, Y, and Y1 values.
The chart is initialized asynchronously using modern async/await patterns to create a SciChartSurface and configure numeric axes with NumericAxis in conjunction with a NumberRange for dynamic growth. The digital band series is constructed using FastBandRenderableSeries combined with an XyyDataSeries, with the digital styling enabled via the isDigitalLine property. A smooth animated transition is achieved using SweepAnimation. Unlike approaches using a Builder API, this example relies solely on direct JavaScript calls to configure the chart.
The example showcases high-performance rendering of digital band series with customized styling through specific fill and stroke options, using contrasting colors for the high and low sections. It integrates interactive modifiers such as ZoomPanModifier, ZoomExtentsModifier, and MouseWheelZoomModifier, ensuring a responsive user experience with real-time zooming and panning capabilities.
This JavaScript implementation highlights best practices for chart lifecycle management by asynchronously initializing the SciChartSurface and providing a cleanup function for proper disposal. Developers are encouraged to explore additional performance optimizations and integration strategies as detailed in the Getting Started with SciChart JS guide. Moreover, the use of asynchronous patterns and modular configuration paves the way for scalable and maintainable charting solutions in production environments.








































