Angular Fan Chart

Here we demonstrate how to create a Angular Fan Chart using SciChart.js. Zoom in and out to see the detail you can go to using our JavaScript Charts

Fullscreen

Edit

 Edit

Docs

drawExample.ts

angular.ts

RandomWalkGenerator.ts

theme.ts

Copy to clipboard
Minimise
Fullscreen
1import { appTheme } from "../../../theme";
2import { RandomWalkGenerator } from "../../../ExampleData/RandomWalkGenerator";
3
4import {
5    MouseWheelZoomModifier,
6    ZoomExtentsModifier,
7    ZoomPanModifier,
8    XyyDataSeries,
9    NumericAxis,
10    SciChartSurface,
11    XyDataSeries,
12    ENumericFormat,
13    WaveAnimation,
14    SplineLineRenderableSeries,
15    TextAnnotation,
16    EVerticalAnchorPoint,
17    SplineBandRenderableSeries,
18} from "scichart";
19// tslint:disable:max-line-length
20
21const animation = new WaveAnimation({ duration: 700, fadeEffect: true });
22
23export type TVarPoint = {
24    date: number;
25    actual: number;
26    varMax: number;
27    var4: number;
28    var3: number;
29    var2: number;
30    var1: number;
31    varMin: number;
32};
33
34export function getVarianceData(): TVarPoint[] {
35    const varianceData: TVarPoint[] = [];
36    const startDate = 1546300800; // 1st Jan 2019
37    const dateStep = 1546387200 - startDate; // one day;
38
39    const length: number = 10;
40    const yValues: number[] = new RandomWalkGenerator().Seed(923478).getRandomWalkSeries(length).yValues;
41    for (let i = 0; i < length; i++) {
42        const date = startDate + dateStep * i;
43
44        let varMax: number = NaN;
45        let var4: number = NaN;
46        let var3: number = NaN;
47        let var2: number = NaN;
48        let var1: number = NaN;
49        let varMin: number = NaN;
50
51        if (i > 4) {
52            varMax = yValues[i] + (i - 5) * 0.3;
53            var4 = yValues[i] + (i - 5) * 0.2;
54            var3 = yValues[i] + (i - 5) * 0.1;
55            var2 = yValues[i] - (i - 5) * 0.1;
56            var1 = yValues[i] - (i - 5) * 0.2;
57            varMin = yValues[i] - (i - 5) * 0.3;
58        }
59
60        varianceData.push({ date, actual: yValues[i], varMax, var4, var3, var2, var1, varMin });
61    }
62
63    return varianceData;
64}
65
66export const drawExample = async (rootElement: string | HTMLDivElement) => {
67    // Create a SciChartSurface
68    const { wasmContext, sciChartSurface } = await SciChartSurface.create(rootElement, {
69        theme: appTheme.SciChartJsTheme,
70    });
71
72    // Add an XAxis, YAxis
73    sciChartSurface.xAxes.add(new NumericAxis(wasmContext, { labelFormat: ENumericFormat.Date_DDMMYYYY }));
74    sciChartSurface.yAxes.add(new NumericAxis(wasmContext));
75
76    // Generates some data for the example as an array of TVarPoint: {
77    //     date: number;
78    //     actual: number;
79    //     varMax: number;
80    //     var4: number;
81    //     var3: number;
82    //     var2: number;
83    //     var1: number;
84    //     varMin: number;
85    // }
86    const varianceData = getVarianceData();
87
88    // To render the fan chart, we use a Line Chart with XyDataSeries
89    // and three Band charts with XyyDataSeries
90    const actualDataSeries = new XyDataSeries(wasmContext);
91    const variance3DataSeries = new XyyDataSeries(wasmContext);
92    const variance2DataSeries = new XyyDataSeries(wasmContext);
93    const variance1DataSeries = new XyyDataSeries(wasmContext);
94
95    actualDataSeries.appendRange(
96        varianceData.map((v) => v.date),
97        varianceData.map((v) => v.actual)
98    );
99    variance3DataSeries.appendRange(
100        varianceData.map((v) => v.date),
101        varianceData.map((v) => v.varMin),
102        varianceData.map((v) => v.varMax)
103    );
104    variance2DataSeries.appendRange(
105        varianceData.map((v) => v.date),
106        varianceData.map((v) => v.var1),
107        varianceData.map((v) => v.var4)
108    );
109    variance1DataSeries.appendRange(
110        varianceData.map((v) => v.date),
111        varianceData.map((v) => v.var2),
112        varianceData.map((v) => v.var3)
113    );
114
115    // Add a line series with the Xy data (the actual data)
116    // Note use FastLineRenderableSeries for non-spline version
117    sciChartSurface.renderableSeries.add(
118        new SplineLineRenderableSeries(wasmContext, {
119            strokeThickness: 2,
120            dataSeries: actualDataSeries,
121            stroke: appTheme.VividPink,
122            animation,
123        })
124    );
125
126    // Add band series with progressively higher opacity for the fan variance data
127    // Note use FastBandRenderableSeries for non-spline version
128    sciChartSurface.renderableSeries.add(
129        new SplineBandRenderableSeries(wasmContext, {
130            dataSeries: variance3DataSeries,
131            opacity: 0.15,
132            fill: appTheme.VividPink,
133            strokeY1: "#00000000",
134            animation,
135        })
136    );
137    sciChartSurface.renderableSeries.add(
138        new SplineBandRenderableSeries(wasmContext, {
139            dataSeries: variance2DataSeries,
140            opacity: 0.33,
141            fill: appTheme.VividPink,
142            strokeY1: "#00000000",
143            animation,
144        })
145    );
146    sciChartSurface.renderableSeries.add(
147        new SplineBandRenderableSeries(wasmContext, {
148            dataSeries: variance1DataSeries,
149            opacity: 0.5,
150            fill: appTheme.VividPink,
151            strokeY1: "#00000000",
152            animation,
153        })
154    );
155
156    // Optional: Add some interactivity modifiers
157    sciChartSurface.chartModifiers.add(
158        new ZoomExtentsModifier(),
159        new ZoomPanModifier({ enableZoom: true }),
160        new MouseWheelZoomModifier(),
161        new ZoomExtentsModifier()
162    );
163
164    // Optional: Add some annotations (text) to show detail
165    sciChartSurface.annotations.add(
166        new TextAnnotation({
167            x1: varianceData[0].date,
168            y1: varianceData[0].actual,
169            verticalAnchorPoint: EVerticalAnchorPoint.Bottom,
170            yCoordShift: -50,
171            text: "Actual data",
172            opacity: 0.45,
173            textColor: appTheme.ForegroundColor,
174        })
175    );
176
177    sciChartSurface.annotations.add(
178        new TextAnnotation({
179            x1: varianceData[5].date,
180            y1: varianceData[5].actual,
181            text: "Forecast Variance",
182            verticalAnchorPoint: EVerticalAnchorPoint.Top,
183            yCoordShift: 50,
184            opacity: 0.45,
185            textColor: appTheme.ForegroundColor,
186        })
187    );
188
189    sciChartSurface.zoomExtents();
190    return { wasmContext, sciChartSurface };
191};
192

Angular Fan Chart

Overview

This Angular example demonstrates how to implement a fan chart using SciChart.js within a standalone Angular component. The chart visualizes both actual data and forecast variance by combining a SplineLineRenderableSeries with multiple SplineBandRenderableSeries. The integration leverages the scichart-angular component to dynamically render advanced charts in an Angular environment.

Technical Implementation

In this example, the Angular standalone component makes use of asynchronous initialization through its input binding; the component passes the drawExample function to the scichart-angular component. Inside drawExample, the chart is set up using SciChartSurface.create() which not only initializes the WebGL-based rendering engine but also returns a WebAssembly context for high performance rendering. Developers can consult the Getting Started with SciChart JS guide as well as the Deploying Wasm (WebAssembly) and Data Files with your app documentation to understand these core concepts.

Features and Capabilities

The fan chart combines a spline line series for actual data with three spline band series that provide progressively higher opacity bands to visualize forecast variance. Interactive modifiers such as ZoomExtentsModifier, ZoomPanModifier, and MouseWheelZoomModifier are integrated for intuitive chart interactions like zooming and panning. These interactive features enhance the user experience and allow detailed inspection of the data.

Integration and Best Practices

This example makes efficient use of Angular’s data binding and asynchronous patterns to manage chart initialization as highlighted in discussions like How to deal with async initialized data in Angular component?. In addition, the approach emphasizes proper resource management by encapsulating chart creation within a standalone component, facilitating easy integration and cleanup in Angular applications. The use of WebAssembly for rendering underscores performance optimization, ensuring smooth animations and rendering with minimal overhead. For further best practices in Angular component design and lifecycle management, developers are encouraged to review Angular’s official Component Lifecycle documentation.

angular Chart Examples & Demos

See Also: JavaScript Chart Types (39 Demos)

Angular Line Chart | Angular Charts | SciChart.js Demo

Angular Line Chart

Discover how to create a high performance Angular Line Chart with SciChart - the leading JavaScript library. Get your free demo now.

Angular Spline Line Chart | Angular Charts | SciChart.js Demo

Angular Spline Line Chart

Discover how to create a Angular Spline Line Chart with SciChart. Demo includes algorithm for smoother lines. Get your free trial now.

Angular Digital Line Chart | Angular Charts | SciChart.js

Angular Digital Line Chart

Discover how to create a Angular Digital Line Chart with SciChart - your feature-rich JavaScript Chart Library. Get your free demo now.

Angular Band Chart | Angular Charts | SciChart.js Demo

Angular Band Chart

Easily create a Angular Band Chart or High-Low Fill with SciChart - high performance JavaScript Chart Library. Get your free trial now.

Angular Spline Band Chart | Angular Charts | SciChart.js Demo

Angular Spline Band Chart

SciChart's Angular Spline Band Chart makes it easy to draw thresholds or fills between two lines on a chart. Get your free demo today.

Angular Digital Band Chart | Angular Charts | SciChart.js

Angular Digital Band Chart

Learn how to create a Angular Digital Band Chart or High-Low Fill Chart with SciChart's easy-to-follow demos. Get your free trial today.

Angular Bubble Chart | Online JavaScript Chart Examples

Angular Bubble Chart

Create a high performance Angular Bubble Chart with Sci-Chart. Demo shows how to draw point-markers at X,Y locations. Get your free demo now.

Angular Candlestick Chart | Online JavaScript Chart Examples

Angular Candlestick Chart

Discover how to create a Angular Candlestick Chart or Stock Chart using SciChart.js. For high Performance JavaScript Charts, get your free demo now.

Angular Column Chart | Angular Charts | SciChart.js Demo

Angular Column Chart

Angular Column Chart demo by SciChart supports gradient fill and paletteproviders for more custom coloring options. Get your free demo now.

Angular Population Pyramid | Angular Charts | SciChart.js

Angular Population Pyramid

Population Pyramid of Europe and Africa

Angular Error Bars Char | Angular Charts | SciChart.js Demo

Angular Error Bars Chart

Create Angular Error Bars Chart using high performance SciChart.js. Display uncertainty or statistical confidence of a data-point. Get free demo now.

Angular Impulse Chart | Angular Charts | SciChart.js Demo

Angular Impulse Chart

Easily create Angular Impulse Chart or Stem Chart using SciChart.js - our own high performance JavaScript Chart Library. Get your free trial now.

Angular Text Chart | Angular Charts | SciChart.js Demo

Angular Text Chart

Create Angular Text Chart with high performance SciChart.js.

Angular Heatmap Chart | Angular Charts | SciChart.js Demo

Angular Heatmap Chart

Easily create a high performance Angular Heatmap Chart with SciChart. Get your free trial of our 5-star rated JavaScript Chart Component today.

Angular Non Uniform Heatmap Chart | SciChart.js Demo

Angular Non Uniform Heatmap Chart

Create Angular Non Uniform Chart using high performance SciChart.js. Display Heatmap with variable cell sizes. Get free demo now.

Angular Heatmap Chart With Contours | SciChart.js Demo

Angular Heatmap Chart With Contours Example

Design a highly dynamic Angular Heatmap Chart With Contours with SciChart's feature-rich JavaScript Chart Library. Get your free demo today.

NEW!
Angular Map Chart with Heatmap overlay | SciChart.js Demo

Angular Map Chart with Heatmap overlay

Design a highly dynamic Angular Map Chart with Heatmap overlay with SciChart's feature-rich JavaScript Chart Library. Get your free demo today.

Angular Mountain Chart | Angular Charts | SciChart.js Demo

Angular Mountain Chart

Create Angular Mountain Chart with SciChart.js. Zero line can be zero or a specific value. Fill color can be solid or gradient as well. Get a free demo now.

Angular Spline Mountain Chart | Angular Charts | SciChart.js

Angular Spline Mountain Chart

Angular Spline Mountain Chart design made easy. Use SciChart.js' JavaScript Charts for high performance, feature-rich designs. Get free demo now.

Angular Digital Mountain Chart | Angular Charts | SciChart.js

Angular Digital Mountain Chart

Create Angular Digital Mountain Chart with a stepped-line visual effect. Get your free trial of SciChart's 5-star rated JavaScript Chart Component now.

Angular Realtime Mountain Chart | View Online At SciChart

Angular Realtime Mountain Chart

Angular Realtime Mountain Chart made easy. Add animated, real-time updates with SciChart.js - high performance JavaScript Charts. Get free trial now.

Angular Scatter Chart | Angular Charts | SciChart.js Demo

Angular Scatter Chart

Create Angular Scatter Chart with high performance SciChart.js. Easily render pre-defined point types. Supports custom shapes. Get your free trial now.

Angular Stacked Column Chart | Online JavaScript Charts

Angular Stacked Column Chart

Discover how to create a Angular Stacked Column Chart using our feature-rich JavaScript Chart Library, SciChart.js. Get your free demo today!

Angular Stacked Group Column Chart | View Examples Now

Angular Stacked Column Side by Side

Design Angular Stacked Group Column Chart side-by-side using our 5-star rated JavaScript Chart Framework, SciChart.js. Get your free demo now.

Angular Stacked Mountain Chart | Angular Charts | SciChart.js

Angular Stacked Mountain Chart

Design a high performance Angular Stacked Mountain Chart with SciChart.js - your one-stop JavaScript chart library. Get free demo now to get started.

Angular Smooth Stacked Mountain Chart | SciChart.js Demo

Angular Smooth Stacked Mountain Chart

Design a high performance Angular Stacked Mountain Chart with SciChart.js - your one-stop JavaScript chart library. Get free demo now to get started.

Angular Pie Chart | Angular Charts | SciChart.js Demo

Angular Pie Chart

Easily create and customise a high performance Angular Pie Chart with 5-star rated SciChart.js. Get your free trial now to access the whole library.

Angular Donut Chart | Angular Charts | SciChart.js Demo

Angular Donut Chart

Create Angular Donut Chart with 5-star rated SciChart.js chart library. Supports legends, text labels, animated updates and more. Get free trial now.

Angular Linear Gauges | Angular Charts | SciChart.js Demo

Angular Linear Gauges Example

View the Angular Linear Gauge Chart example to combine rectangles & annotations. Create a linear gauge dashboard with animated indicators and custom scales.

Angular Quadrant Chart using Background Annotations

Angular Quadrant Chart using Background Annotations

Demonstrates how to color areas of the chart surface using background Annotations using SciChart.js Annotations API

Angular Histogram Chart | Angular Charts | SciChart.js Demo

Angular Histogram Chart

Create an Angular Histogram Chart with custom texture fills and patterns. Try the SciChartAngular wrapper component for seamless Angular integration today.

Angular Gantt Chart | Angular Charts | SciChart.js Demo

Angular Gantt Chart Example

Build an Angular Gantt Chart with SciChart. View the demo for horizontal bars, rounded corners and data labels to show project timelines and task completion.

Angular Choropleth Map | Angular Charts | SciChart.js Demo

Angular Choropleth Map Example

Create an Angular Choropleth map, a type of thematic map where areas are shaded or patterned in proportion to the value of a variable being represented.

Angular Multi-Layer Map | Angular Charts | SciChart.js Demo

Angular Multi-Layer Map Example

Create a Angular Multi-Layer Map Example, using FastTriangleRenderableSeries with GeoJSON data-points using a constrained delaunay triangulation algorithm.

Angular Vector Field Plot | Angular Charts | SciChart.js Demo

Angular Vector Field Plot

View the Angular Vector Field Plot example from SciChart, including dynamic vector generation, gradient-colored segments, and interactive zoom/pan. Try demo.

Angular Waterfall Chart | Bridge Chart | SciChart.js Demo

Angular Waterfall Chart | Bridge Chart

Build an Angular Waterfall Chart with dynamic coloring, multi-line data labels & responsive design, using ScichartAngular component for seamless integration

Angular Box Plot Chart | Angular Charts | SciChart.js Demo

Angular Box Plot Chart

Try the Angular Box Plot Chart example for Angular-friendly chart lifecycle management, dynamic sub-surface positioning, and custom styling. Try the demo now.

Angular Triangle Series | Triangle Mesh Chart | SciChart

Angular Triangle Series | Triangle Mesh Chart

Create Angular Triangle Meshes with the Triangle Series from SciChart. This demo supports strip mode, list mode and the drawing of polygons. View the example.

Angular Treemap Chart | Angular Charts | SciChart.js Demo

Angular Treemap Chart

Create an Angular Treemap Chart to define rectangle positions based on total value. Use SciChart FastRectangleRenderableSeries and d3-hierarchy.js layouts.

SciChart Ltd, 16 Beaufort Court, Admirals Way, Docklands, London, E14 9XL.