Angular Waterfall Chart | Bridge Chart

Creates a Angular Waterfall Chart using SciChart.js's new FastRectangleRenderableSeries with the following features: a custom Treemap-like DataLabelProvider for rectangle labels and custom Fill PaletteProvider

Also Known As: Bridge Chart and Cascade Chart.

Fullscreen

Edit

 Edit

Docs

drawExample.ts

angular.ts

theme.ts

Copy to clipboard
Minimise
Fullscreen
1import {
2    NumericAxis,
3    ZoomPanModifier,
4    ZoomExtentsModifier,
5    MouseWheelZoomModifier,
6    SciChartSurface,
7    ENumericFormat,
8    FastRectangleRenderableSeries,
9    XyxyDataSeries,
10    EColumnYMode,
11    EColumnMode,
12    EDataPointWidthMode,
13    NumberRange,
14    EHorizontalTextPosition,
15    EVerticalTextPosition,
16    TextLabelProvider,
17    RectangleSeriesDataLabelProvider,
18    formatNumber,
19    IRectangleSeriesDataLabelProviderOptions,
20    EDataLabelSkipMode,
21    EMultiLineAlignment,
22    IPointMetadata,
23    IFillPaletteProvider,
24    EFillPaletteMode,
25    parseColorToUIntArgb,
26    ELabelAlignment,
27    Thickness,
28} from "scichart";
29import { appTheme } from "../../../theme";
30
31const data = [
32    { date: "Jan.", profit: 387264 },
33    { date: "Feb.", profit: 772096 },
34    { date: "Mar.", profit: 638075 },
35    { date: "Apr.", profit: -211386 },
36    { date: "May", profit: -138135 },
37    { date: "Jun.", profit: -267238 },
38    { date: "Jul.", profit: 431406 },
39    { date: "Aug.", profit: 363018 },
40    { date: "Sep.", profit: -224638 },
41    { date: "Oct.", profit: -299867 },
42    { date: "Nov.", profit: 607365 },
43    { date: "Dec.", profit: 1106986 },
44];
45
46const waterfall = function (numbers: { date: string; profit: number }[]) {
47    let last = 0,
48        accu = 0;
49    const waterfall = numbers.map((d, i) => {
50        last = accu;
51        accu += d.profit;
52        return {
53            date: d.date,
54            nextDay: i < numbers.length - 1 ? numbers[i + 1].date : "Total",
55            prior: last,
56            accu: accu,
57            profit: d.profit,
58        };
59    });
60
61    waterfall.push({
62        date: "Total",
63        nextDay: null,
64        prior: 0,
65        accu: accu,
66        profit: 0,
67    });
68
69    return waterfall;
70};
71
72const generatedData = waterfall(data);
73
74const labelProvider = new TextLabelProvider({
75    labels: [...generatedData.map((d) => d.date)],
76    maxLength: 15,
77});
78
79export const drawExample = async (rootElement: string | HTMLDivElement) => {
80    // Create a SciChartSurface
81    const { sciChartSurface, wasmContext } = await SciChartSurface.create(rootElement, {
82        theme: appTheme.SciChartJsTheme,
83    });
84
85    const growBy = new NumberRange(0.05, 0.05);
86
87    // Create an XAxis with a TextLabelProvider
88    const xAxis = new NumericAxis(wasmContext, {
89        // labelprovider maps Xaxis values (in this case index) to labels (in this case manufacturer name)
90        labelProvider,
91        labelStyle: {
92            alignment: ELabelAlignment.Center,
93            padding: new Thickness(2, 1, 2, 1),
94            fontSize: 11,
95        },
96        maxAutoTicks: 15,
97        growBy: new NumberRange(0.05, 0.05), // add some horizontal padding
98    });
99
100    sciChartSurface.xAxes.add(xAxis);
101
102    // Create a YAxis
103    sciChartSurface.yAxes.add(new NumericAxis(wasmContext, { growBy, labelFormat: ENumericFormat.Engineering }));
104
105    class CustomFillProvider implements IFillPaletteProvider {
106        public readonly fillPaletteMode = EFillPaletteMode.SOLID;
107
108        public onAttached(): void {}
109        public onDetached(): void {}
110
111        public overrideFillArgb(
112            _xValue: number,
113            _yValue: number,
114            _index: number,
115            _opacity?: number,
116            metadata?: IPointMetadata
117        ): number {
118            const profit = (metadata as unknown as { profit: number })?.profit;
119
120            if (profit > 0) {
121                return parseColorToUIntArgb(appTheme.VividTeal, 255);
122            }
123
124            if (profit < 0) {
125                return parseColorToUIntArgb(appTheme.VividPink, 255);
126            }
127
128            return parseColorToUIntArgb(appTheme.VividBlue, 128);
129        }
130    }
131
132    class TreemapDataLabelProvider extends RectangleSeriesDataLabelProvider {
133        constructor(options?: IRectangleSeriesDataLabelProviderOptions) {
134            super(options);
135        }
136
137        // Override "getText" method to provide dynamic text based on rectangle size
138        getText(state: any): string {
139            const metadata = state.getMetaData() as any;
140
141            return (
142                `${formatNumber(metadata.accu, ENumericFormat.Engineering, 2)}$` +
143                (metadata.profit === 0
144                    ? ""
145                    : `\n${metadata.profit > 0 ? "+" : ""}${formatNumber(
146                        metadata.profit,
147                        ENumericFormat.Engineering,
148                        this.precision
149                    )}$`)
150            );
151        }
152    }
153
154    // Prepare data and create rectangle series
155
156    const rectangleSeries = new FastRectangleRenderableSeries(wasmContext, {
157        dataSeries: new XyxyDataSeries(wasmContext, {
158            xValues: generatedData.map((d, i) => i),
159            yValues: generatedData.map((d) => d.prior),
160            x1Values: generatedData.map((d, i) => i),
161            y1Values: generatedData.map((d) => d.accu),
162            metadata: generatedData as any[],
163        }),
164        columnXMode: EColumnMode.Mid,
165        columnYMode: EColumnYMode.TopBottom,
166        dataPointWidthMode: EDataPointWidthMode.Range,
167        stroke: "black",
168        strokeThickness: 1,
169        opacity: 0.5,
170        fill: appTheme.DarkIndigo,
171        dataLabelProvider: new TreemapDataLabelProvider({
172            skipMode: EDataLabelSkipMode.ShowAll,
173            color: "white",
174            style: {
175                fontSize: 11,
176                multiLineAlignment: EMultiLineAlignment.Center,
177                lineSpacing: 5,
178            },
179            horizontalTextPosition: EHorizontalTextPosition.Center,
180            verticalTextPosition: EVerticalTextPosition.Center,
181            metaDataSelector: (md: unknown) => {
182                return (md as { profit: string }).profit;
183            },
184        }),
185        paletteProvider: new CustomFillProvider(),
186    });
187    sciChartSurface.renderableSeries.add(rectangleSeries);
188
189    // Add interactivity modifiers
190    sciChartSurface.chartModifiers.add(
191        new ZoomPanModifier({ enableZoom: true }),
192        new ZoomExtentsModifier(),
193        new MouseWheelZoomModifier()
194    );
195
196    return { sciChartSurface, wasmContext };
197};
198

Waterfall Chart - Angular

Overview

This Angular example demonstrates how to create a Waterfall Chart using the scichart-angular package. The standalone component integrates SciChart.js while maintaining Angular's component architecture.

Technical Implementation

The chart is initialized through the <scichart-angular> component, which accepts the drawExample function as input. The implementation uses FastRectangleRenderableSeries with EColumnYMode.TopBottom to define rectangle heights. Custom palette providers and label formatters enhance the visualization.

Features and Capabilities

Key features include profit/loss coloring, engineering notation formatting, and interactive zoom/pan behavior. The chart efficiently handles data transformation from raw values to waterfall format while maintaining high performance through WebAssembly rendering.

Integration and Best Practices

The example follows Angular best practices by using standalone components and proper TypeScript typing. The async initialization pattern ensures smooth integration with Angular's change detection.

angular Chart Examples & Demos

See Also: JavaScript Chart Types (40 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 Fan Chart | Angular Charts | SciChart.js Demo

Angular Fan Chart

Discover how to create Angular Fan Chart with SciChart. Zoom in to see the detail you can go to using our JavaScript Charts. Get your free demo today.

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.

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

NEW!
Angular Force Directed Graph | Angular Charts | SciChart.js

Angular Force Directed Graph

Angular Force Directed Graph demo by SciChart.js. Visualize network graphs with physics simulation, interactive node dragging, and hover tooltips.

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