Demonstrates how to create a Angular Chart with transparent axes using SciChart.js, High Performance JavaScript Charts
drawExample.ts
angular.ts
theme.ts
1import {
2 ECoordinateMode,
3 EHorizontalAnchorPoint,
4 ELineDrawMode,
5 FastLineRenderableSeries,
6 MouseWheelZoomModifier,
7 NumberRange,
8 NumericAxis,
9 PinchZoomModifier,
10 SciChartSurface,
11 TextAnnotation,
12 XyDataSeries,
13 ZoomPanModifier,
14 Thickness,
15} from "scichart";
16import { appTheme } from "../../../theme";
17
18export const drawExample = async (rootElement: string | HTMLDivElement) => {
19 const { sciChartSurface, wasmContext } = await SciChartSurface.create(rootElement, {
20 theme: appTheme.SciChartJsTheme,
21 title: "SciChartSurface with Series Drawn Behind Axis",
22 titleStyle: {
23 fontSize: 20,
24 fontWeight: "Bold",
25 placeWithinChart: true,
26 padding: Thickness.fromString("14 2 10 0"),
27 color: appTheme.ForegroundColor + "C4",
28 },
29 });
30
31 // When true, Series are drawn behind axis (Axis inside chart)
32 sciChartSurface.drawSeriesBehindAxis = true;
33
34 sciChartSurface.xAxes.add(
35 new NumericAxis(wasmContext, {
36 growBy: new NumberRange(0.1, 0.1),
37 visibleRange: new NumberRange(28.0, 42.6),
38 axisTitle: "X Axis",
39 labelStyle: {
40 fontSize: 20,
41 },
42 axisBorder: {
43 borderTop: 0,
44 color: appTheme.PaleSkyBlue + "33",
45 },
46 })
47 );
48 sciChartSurface.yAxes.add(
49 new NumericAxis(wasmContext, {
50 growBy: new NumberRange(0.1, 0.1),
51 visibleRange: new NumberRange(-40.0, 140.0),
52 axisTitle: "Y Axis",
53 labelStyle: {
54 fontSize: 20,
55 },
56 axisBorder: {
57 borderLeft: 0,
58 color: appTheme.PaleSkyBlue + "33",
59 },
60 })
61 );
62
63 const xValues = [];
64 const yValues = [];
65 const y1Values = [];
66
67 for (let i = 0; i < 100; i += 0.1) {
68 xValues.push(i);
69 yValues.push(Math.tan(i));
70 y1Values.push(Math.cos(i * 100) * 5);
71 }
72
73 sciChartSurface.renderableSeries.add(
74 new FastLineRenderableSeries(wasmContext, {
75 drawNaNAs: ELineDrawMode.PolyLine,
76 strokeThickness: 5,
77 stroke: "rgba(255, 134, 72, .47)",
78 dataSeries: new XyDataSeries(wasmContext, { xValues, yValues }),
79 })
80 );
81
82 sciChartSurface.renderableSeries.add(
83 new FastLineRenderableSeries(wasmContext, {
84 drawNaNAs: ELineDrawMode.PolyLine,
85 strokeThickness: 3,
86 stroke: "rgba(50, 134, 72, .47)",
87 dataSeries: new XyDataSeries(wasmContext, { xValues, yValues: y1Values }),
88 })
89 );
90
91 sciChartSurface.chartModifiers.add(new ZoomPanModifier({ enableZoom: true }), new MouseWheelZoomModifier());
92
93 return { sciChartSurface, wasmContext };
94};
95This example demonstrates how to integrate SciChart.js into an Angular application using a standalone Angular component. The example shows how to render a high performance chart with series drawn behind the axes, and it provides interactive runtime updates to toggle between drawing series behind the axes or clipping them at the viewport edge.
The chart is initialized using an initChart callback which is passed to the ScichartAngularComponent. This callback sets up the SciChartSurface with customized NumericAxis, multiple FastLineRenderableSeries, and various chart modifiers such as ZoomPanModifier and MouseWheelZoomModifier. The implementation leverages the Angular integration of SciChart.js as demonstrated in the scichart-angular package, and follows patterns similar to those described in Tutorial 01 - Setting up a npm Project with SciChart.js. Additionally, the example sets the drawSeriesBehindAxis property of the SciChartSurface to control whether series are rendered behind the axes, as detailed in the SciChart.js Draw Behind Axes Documentation page.
The example provides real-time update capabilities through a toggle interface implemented with Material UI’s ToggleButtonGroup. Users can dynamically switch the rendering mode, which not only updates the chart title and the border properties of the axes, but also demonstrates advanced customization features such as axis formatting and series styling. The NumericAxis are configured with properties including growBy, visibleRange, and custom axisBorder, following guidelines similar to those found in the Numeric Axis Documentation.
By utilizing a standalone component design, the integration of SciChart.js is streamlined and optimized for Angular environments. The use of an initChart callback for initializing the chart enables clear separation of concerns, making it easier to manage complex chart configurations. Developers are encouraged to review the Getting Started guides for more information on how to integrate SciChart.js to Angular applications.

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

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

Demonstrates alignment of Axis to create a vertical chart with SciChart.js - JavaScript Charts.

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

Demonstrates isStaticAxis on a Angular Chart using SciChart.js.

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

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


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

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

Demonstrates outer, inner, central and stacked axes, and use of axis alignment to create vertical charts