Angular Vertical Charts

Demonstrates how to create a rotated Angular Chart with vertical X-Axis using SciChart.js, High Performance JavaScript Charts

Fullscreen

Edit

 Edit

Docs

drawExample.ts

angular.ts

RandomWalkGenerator.ts

theme.ts

Copy to clipboard
Minimise
Fullscreen
1import {
2    EAxisAlignment,
3    ECoordinateMode,
4    EHorizontalAnchorPoint,
5    EllipsePointMarker,
6    EMultiLineAlignment,
7    EVerticalAnchorPoint,
8    EWrapTo,
9    FastLineRenderableSeries,
10    MouseWheelZoomModifier,
11    NativeTextAnnotation,
12    NumberRange,
13    NumericAxis,
14    SciChartSurface,
15    XyDataSeries,
16    ZoomExtentsModifier,
17    ZoomPanModifier,
18} from "scichart";
19import { appTheme } from "../../../theme";
20import { RandomWalkGenerator } from "../../../ExampleData/RandomWalkGenerator";
21
22export const drawExample = async (rootElement: string | HTMLDivElement) => {
23    const { wasmContext, sciChartSurface } = await SciChartSurface.create(rootElement, {
24        theme: appTheme.SciChartJsTheme,
25    });
26
27    // Setting an XAxis on the Left or Right
28    // and YAxis on the Top or Bottom
29    // causes the chart and series to be rotated vertically
30    sciChartSurface.xAxes.add(
31        new NumericAxis(wasmContext, {
32            axisTitle: "X Axis with Alignment = Left",
33            axisAlignment: EAxisAlignment.Left,
34            growBy: new NumberRange(0.15, 0.05),
35        })
36    );
37
38    sciChartSurface.yAxes.add(
39        new NumericAxis(wasmContext, {
40            axisTitle: "Y Axis with Alignment = Bottom",
41            axisAlignment: EAxisAlignment.Bottom,
42            growBy: new NumberRange(0.1, 0.1),
43        })
44    );
45
46    // Generate some data. xValues/yValues are just arrays of numbers
47    const generator = new RandomWalkGenerator().Seed(1337).getRandomWalkSeries(100);
48    const xValues = generator.xValues;
49    const yValues = generator.yValues;
50
51    // Add a line series to the chart. This will be drawn vertically.
52    sciChartSurface.renderableSeries.add(
53        new FastLineRenderableSeries(wasmContext, {
54            dataSeries: new XyDataSeries(wasmContext, { xValues, yValues }),
55            pointMarker: new EllipsePointMarker(wasmContext, {
56                width: 9,
57                height: 9,
58                fill: appTheme.ForegroundColor,
59                stroke: appTheme.VividOrange,
60            }),
61            strokeThickness: 5,
62            stroke: appTheme.VividOrange,
63        })
64    );
65
66    // Add title / instructions
67    sciChartSurface.annotations.add(
68        new NativeTextAnnotation({
69            x1: 0.02,
70            y1: 0.02,
71            xCoordinateMode: ECoordinateMode.Relative,
72            yCoordinateMode: ECoordinateMode.Relative,
73            horizontalAnchorPoint: EHorizontalAnchorPoint.Left,
74            verticalAnchorPoint: EVerticalAnchorPoint.Top,
75            fontSize: 16,
76            opacity: 0.77,
77            textColor: appTheme.ForegroundColor,
78            text: "To rotate a chart in SciChart.js, set XAxis.alignment = Left/Right and YAxis.alignment=Top/Bottom",
79            wrapTo: EWrapTo.ViewRect,
80            multiLineAlignment: EMultiLineAlignment.Left,
81        })
82    );
83
84    // Add some interactivity modifiers
85    sciChartSurface.chartModifiers.add(new ZoomPanModifier({ enableZoom: true }));
86    sciChartSurface.chartModifiers.add(new ZoomExtentsModifier());
87    sciChartSurface.chartModifiers.add(new MouseWheelZoomModifier());
88
89    sciChartSurface.zoomExtents();
90
91    return { wasmContext, sciChartSurface };
92};
93

Angular Vertical Charts Example

Overview

This Angular example demonstrates how to create a rotated chart using SciChart.js. By setting the X-Axis alignment to Left and the Y-Axis alignment to Bottom, the chart is rendered vertically. This high performance example leverages Angular's standalone components, as described in the Getting started with standalone components - Angular documentation, and uses the scichart-angular package for seamless integration.

Technical Implementation

The implementation utilizes a standalone Angular component that renders the ScichartAngularComponent with an initChart callback. Within this callback, a SciChartSurface is created along with NumericAxis configured for a vertical display by setting axis.axisAlignment to EAxisAlignment.Left and EAxisAlignment.Bottom. Generated data from a random walk series is visualized with a FastLineRenderableSeries and enhanced by an EllipsePointMarker. A NativeTextAnnotation provides guidance, while interactive modifiers such as ZoomPanModifier, ZoomExtentsModifier, and MouseWheelZoomModifier add dynamic chart interactivity. Detailed axis configuration is explained in the Vertical Charts (Rotate, Transpose Axis) - SciChart guide and interactive behaviors are outlined in the Tutorial 03 - Adding Zooming, Panning Behavior documentation.

Features and Capabilities

This example showcases real-time update capabilities and interactive chart features powered by SciChart.js. The chart’s configuration supports dynamic data rendering, advanced interactivity including zooming and panning, and enhanced visual styling with custom point markers and annotations, ensuring a robust and responsive data visualization experience.

Integration and Best Practices

Angular integration is achieved by encapsulating the chart creation logic within a standalone component and initializing the chart via the initChart property. This pattern aligns with modern Angular practices for component-based design. Developers can further explore performance optimization and integration techniques by referring to the Getting Started with SciChart JS guide which shows how to integrate SciChart to an Angular application. Memory management is efficiently handled through the lifecycle of the SciChartSurface, ensuring resources are properly disposed when no longer needed.

angular Chart Examples & Demos

See Also: Chart Axis APIs (11 Demos)

Angular Chart with Multiple X Axes | SciChart.js Demo

Angular Chart with Multiple X Axes

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

Angular Chart with Secondary Y Axes | SciChart.js Demo

Angular Chart with Secondary Y Axes

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

Angular Chart with Central Axes | Angular Charts | SciChart.js

Angular Chart with Central Axes

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

Angular Chart with Static X Axis | Angular Charts | SciChart.js

Angular Chart with Static X Axis

Demonstrates isStaticAxis on a Angular Chart using SciChart.js.

Angular Chart with Vertically Stacked Axes | SciChart.js

Angular Chart with Vertically Stacked Axes

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

Angular Chart with Logarithmic Axis Example | SciChart.js

Angular Chart with Logarithmic Axis Example

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

NEW!
Angular Chart with DiscontinuousDateAxis  Comparison

DiscontinuousDateAxis Comparison with Angular

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

Angular Chart with BaseValue Axes

Demonstrates BaseValue Axes on an Angular Chart using SciChart.js to create non-linear and custom-scaled axes

Draw Angular Chart Behind Axis | Angular Charts | SciChart.js

Draw Angular Chart Behind Axis

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

Axis Types | Angular Charts | SciChart.js Demo

Axis Types

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

Angular Chart Axis Layout Options | SciChart.js Demo

Angular 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.