Use this demonstration to learn how to create a JavaScript Impulse Chart using SciChart.js, our own High Performance JavaScript Chart Library.
import { appTheme } from "./appTheme";
import {
NumericAxis,
XyDataSeries,
SciChartSurface,
FastImpulseRenderableSeries,
ZoomPanModifier,
ZoomExtentsModifier,
MouseWheelZoomModifier,
EllipsePointMarker,
NumberRange,
WaveAnimation,
} from "scichart";
export const drawExample = async (rootElement: string | HTMLDivElement) => {
const { sciChartSurface, wasmContext } = await SciChartSurface.create(rootElement, {
theme: appTheme.SciChartJsTheme,
});
sciChartSurface.xAxes.add(new NumericAxis(wasmContext, { axisTitle: "X Axis" }));
sciChartSurface.yAxes.add(new NumericAxis(wasmContext, { axisTitle: "Y Axis", growBy: new NumberRange(0.1, 0.1) }));
const xValues = [];
const yValues = [];
for (let i = 0; i < 70; i++) {
xValues.push(i);
yValues.push(Math.sin(i * 0.2) * -Math.log(i / 100));
}
const impulseSeries = new FastImpulseRenderableSeries(wasmContext, {
fill: appTheme.VividPink,
strokeThickness: 2,
pointMarker: new EllipsePointMarker(wasmContext, { width: 1, height: 1 }),
dataSeries: new XyDataSeries(wasmContext, { xValues, yValues }),
animation: new WaveAnimation({ duration: 500, delay: 200, fadeEffect: true }),
});
sciChartSurface.renderableSeries.add(impulseSeries);
sciChartSurface.chartModifiers.add(new ZoomPanModifier({ enableZoom: true }));
sciChartSurface.chartModifiers.add(new ZoomExtentsModifier());
sciChartSurface.chartModifiers.add(new MouseWheelZoomModifier());
return { sciChartSurface };
};
This example demonstrates how to create a high-performance Impulse Chart using SciChart.js with JavaScript. The implementation renders a lollipop or stem chart by calculating dynamic data points and leveraging a modern WebGL and WASM-based rendering engine.
The chart is asynchronously initialized using SciChartSurface.create(), which sets up a WebGL-powered WASM context for optimal rendering performance. For detailed guidance on this initialization process, see the Creating a new SciChartSurface and loading Wasm documentation. NumericAxis are configured via the constructor options, and custom data series are populated using XyDataSeries. The FastImpulseRenderableSeries is used to render the impulse chart with a built-in wave animation effect, as described in the Animations API.
This implementation includes interactive features such as panning and zooming through the use of ZoomPanModifier, ZoomExtentsModifier, and MouseWheelZoomModifier, enhancing user interaction with the chart. These interactive functionalities support real-time updates and dynamic customizations, ensuring that users can seamlessly explore the data. For more insights on interactive chart modifiers, refer to the Adding Zooming, Panning Behavior tutorial.
The JavaScript implementation emphasizes efficient resource management. A dedicated cleanup function is provided which deletes the chart instance when it is no longer needed, following best practices outlined in the Memory Best Practices | JavaScript Chart Documentation - SciChart. This approach ensures that memory is managed appropriately and resources are freed up promptly, maintaining optimal application performance.








































