Angular Digital Mountain Chart

For Digital Mountain Charts, you can use this demonstration to see how to create a Angular Digital Mountain Chart using SciChart.js, and its powerful JavaScript Chart Library.

src/drawExample.ts
import {
    FastMountainRenderableSeries,
    GradientParams,
    MouseWheelZoomModifier,
    NumberRange,
    NumericAxis,
    Point,
    RubberBandXyZoomModifier,
    SciChartSurface,
    WaveAnimation,
    XyDataSeries,
    ZoomExtentsModifier,
} from "scichart";
import { appTheme } from "./appTheme";
import { RandomWalkGenerator } from "./RandomWalkGenerator";

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.05, 0.05),
            axisTitle: "Y Axis",
        })
    );

    const POINTS = 200;

    // Create arrays of x, y values
    const xValues = Array.from(Array(POINTS).keys());
    const yValues = new RandomWalkGenerator().Seed(0).getRandomWalkSeries(POINTS).yValues;

    // Create a Mountain Series and add to the chart
    const mountainSeries = new FastMountainRenderableSeries(wasmContext, {
        dataSeries: new XyDataSeries(wasmContext, { xValues, yValues }),
        stroke: appTheme.VividOrange,
        strokeThickness: 3,
        zeroLineY: 0.0,
        fill: appTheme.VividOrange, // when a solid color is required, use fill
        // when a gradient is required, use fillLinearGradient
        fillLinearGradient: new GradientParams(new Point(0, 0), new Point(0, 1), [
            { color: appTheme.MutedOrange, offset: 0 },
            { color: "Transparent", offset: 1 },
        ]),
        isDigitalLine: true,
        animation: new WaveAnimation({ duration: 1000, fadeEffect: true, zeroLine: 0 }),
    });
    sciChartSurface.renderableSeries.add(mountainSeries);

    // Optional: Add some interactivity to the chart
    sciChartSurface.chartModifiers.add(new ZoomExtentsModifier());
    sciChartSurface.chartModifiers.add(new RubberBandXyZoomModifier());
    sciChartSurface.chartModifiers.add(new MouseWheelZoomModifier());

    sciChartSurface.zoomExtents();
    return { wasmContext, sciChartSurface };
};

Angular Digital Mountain Chart

Overview

This example demonstrates how to integrate a high-performance WebGL chart into an Angular application using SciChart.js. The chart renders a digital mountain series based on a simulated random walk data set, showcasing a stepped-line visual effect with gradient fills and smooth wave animations. For further details on the digital mountain series, refer to the Digital Mountain Chart Documentation.

Technical Implementation

The chart is implemented within an Angular standalone component that leverages the ScichartAngularComponent. The component initializes the chart by passing a dedicated function that creates a SciChartSurface, configures *NumericAxis, and adds a FastMountainRenderableSeries configured for digital line rendering (via the isDigitalLine property). The series is augmented with a WaveAnimation and a gradient fill constructed from GradientParams. This approach uses direct instantiation of the SciChart.js classes rather than a builder API, providing granular control over the chart configuration.

Features and Capabilities

The example includes robust interactive features such as ZoomExtentsModifier, RubberBandXyZoomModifier, and MouseWheelZoomModifier that enable intuitive zooming and panning. The visual capabilities are enhanced with gradient fills and dynamic animations, creating an engaging user experience. These interactive modifiers, combined with the high-performance rendering of SciChart.js, allow for real-time data presentation and exploration.

Integration and Best Practices

By utilizing Angular standalone components as outlined in the Angular Standalone Components guide, the integration remains modular and maintainable. The usage of external libraries follows recommended Angular practices as seen in Angular Integration Techniques. The component lifecycle is managed according to the Angular lifecycle hooks, ensuring proper initialization and resource management. Additionally, adopting Angular performance optimization techniques aids in handling the computational demands of a WebGL-based chart, ensuring a smooth, high-fidelity user experience.