Angular Gantt Chart Example

Creates a Angular Gantt Chart using SciChart.js, using the new FastRectangleSeries to draw horizontal bars, with rounded corners and data labels coming from metadata

Fullscreen

Edit

 Edit

Docs

drawExample.ts

angular.ts

theme.ts

Copy to clipboard
Minimise
Fullscreen
1import {
2    ZoomPanModifier,
3    ZoomExtentsModifier,
4    SciChartSurface,
5    ENumericFormat,
6    EAxisAlignment,
7    FastRectangleRenderableSeries,
8    XyxyDataSeries,
9    EColumnYMode,
10    EColumnMode,
11    EDataPointWidthMode,
12    NumberRange,
13    EHorizontalTextPosition,
14    EVerticalTextPosition,
15    SeriesInfo,
16    EXyDirection,
17    DateTimeNumericAxis,
18    CategoryAxis,
19    ELabelAlignment,
20    CursorModifier,
21    TCursorTooltipDataTemplate,
22} from "scichart";
23import { appTheme } from "../../../theme";
24
25const PROJECT_STAGES = [
26    "Project Planning",
27    "Requirements",
28    "System Design",
29    "Database Design",
30    "Front-end dev",
31    "Back-end dev",
32    "Integration",
33    "Unit Testing",
34    "System Testing",
35    "Deployment",
36];
37
38const PROJECT_TASKS = [
39    {
40        name: PROJECT_STAGES[0],
41        startDate: new Date(2025, 0, 1),
42        endDate: new Date(2025, 0, 15),
43        percentComplete: 100,
44    },
45    {
46        name: PROJECT_STAGES[1],
47        startDate: new Date(2025, 0, 10),
48        endDate: new Date(2025, 0, 25),
49        percentComplete: 100,
50    },
51    {
52        name: PROJECT_STAGES[2],
53        startDate: new Date(2025, 0, 20),
54        endDate: new Date(2025, 1, 15),
55        percentComplete: 90,
56    },
57    {
58        name: PROJECT_STAGES[3],
59        startDate: new Date(2025, 1, 5),
60        endDate: new Date(2025, 1, 20),
61        percentComplete: 85,
62    },
63    {
64        name: PROJECT_STAGES[4],
65        startDate: new Date(2025, 1, 15),
66        endDate: new Date(2025, 2, 25),
67        percentComplete: 70,
68    },
69    {
70        name: PROJECT_STAGES[5],
71        startDate: new Date(2025, 1, 15),
72        endDate: new Date(2025, 3, 5),
73        percentComplete: 60,
74    },
75    {
76        name: PROJECT_STAGES[6],
77        startDate: new Date(2025, 2, 25),
78        endDate: new Date(2025, 3, 15),
79        percentComplete: 30,
80    },
81    {
82        name: PROJECT_STAGES[7],
83        startDate: new Date(2025, 3, 1),
84        endDate: new Date(2025, 3, 20),
85        percentComplete: 20,
86    },
87    {
88        name: PROJECT_STAGES[8],
89        startDate: new Date(2025, 3, 15),
90        endDate: new Date(2025, 4, 5),
91        percentComplete: 0,
92    },
93    {
94        name: PROJECT_STAGES[9],
95        startDate: new Date(2025, 4, 1),
96        endDate: new Date(2025, 4, 15),
97        percentComplete: 0,
98    },
99];
100
101function prepareGanttData() {
102    // Prepare data for rect series
103    const xValues: number[] = []; // Start dates
104    const yValues: number[] = []; // Task positions (rows)
105    const x1Values: number[] = []; // End dates
106    const y1Values: number[] = []; // Task heights
107
108    // Task metadata for coloring and labels
109    const metaData: { name: string; percentComplete: number; isSelected: boolean; startDate: Date; endDate: Date }[] =
110        [];
111
112    // Convert Date objects to timestamps for rendering
113    PROJECT_TASKS.forEach((task, index) => {
114        const rowPosition = PROJECT_TASKS.length - index - 1; // Reverse order for display
115        const rowHeight = 0.8; // Height of each task bar
116
117        xValues.push(task.startDate.getTime() / 1000);
118        yValues.push(rowPosition);
119        x1Values.push(task.endDate.getTime() / 1000);
120        y1Values.push(rowPosition + rowHeight);
121
122        metaData.push({
123            name: task.name,
124            percentComplete: task.percentComplete,
125            isSelected: false,
126            startDate: task.startDate,
127            endDate: task.endDate,
128        });
129    });
130
131    return { xValues, yValues, x1Values, y1Values, metaData, taskCount: PROJECT_TASKS.length };
132}
133
134export const drawExample = async (rootElement: string | HTMLDivElement) => {
135    // Create a SciChartSurface
136    const { sciChartSurface, wasmContext } = await SciChartSurface.create(rootElement, {
137        theme: appTheme.SciChartJsTheme,
138    });
139
140    const yAxis = new CategoryAxis(wasmContext, {
141        axisAlignment: EAxisAlignment.Left,
142        drawMajorBands: false,
143        drawLabels: true,
144        drawMinorGridLines: false,
145        drawMajorGridLines: false,
146        drawMinorTickLines: false,
147        drawMajorTickLines: false,
148        keepLabelsWithinAxis: false,
149        autoTicks: false,
150        majorDelta: 1,
151        growBy: new NumberRange(0.02, 0.02),
152        labels: PROJECT_STAGES.reverse(),
153        labelStyle: {
154            fontSize: 14,
155            fontWeight: "bold",
156            color: appTheme.MutedOrange,
157            alignment: ELabelAlignment.Right,
158            padding: { top: 0, right: 0, bottom: 40, left: 0 },
159        },
160    });
161
162    const xAxis = new DateTimeNumericAxis(wasmContext, {
163        axisAlignment: EAxisAlignment.Bottom,
164        drawMinorGridLines: false,
165        growBy: new NumberRange(0.02, 0.02),
166        // axisTitleStyle: {
167        //     fontSize: 14,
168        //     fontFamily: "Arial",
169        //     color: appTheme.MutedOrange,
170        //     // fontStyle: "italic",
171        // },
172        labelFormat: ENumericFormat.Date_DDMM,
173    });
174
175    sciChartSurface.xAxes.add(xAxis);
176    sciChartSurface.yAxes.add(yAxis);
177
178    sciChartSurface.yAxes.get(0).axisRenderer.hideOverlappingLabels = false;
179
180    const { xValues, yValues, x1Values, y1Values, metaData, taskCount } = prepareGanttData();
181
182    const rectangleGanttSeries = new FastRectangleRenderableSeries(wasmContext, {
183        dataSeries: new XyxyDataSeries(wasmContext, {
184            xValues,
185            yValues,
186            y1Values,
187            x1Values,
188            dataSeriesName: "Project Tasks",
189            metadata: metaData,
190        }),
191        columnXMode: EColumnMode.StartEnd,
192        columnYMode: EColumnYMode.TopBottom,
193        dataPointWidthMode: EDataPointWidthMode.Range,
194        stroke: appTheme.MutedRed,
195        strokeThickness: 2,
196        fill: appTheme.MutedBlue,
197        dataPointWidth: 0.9,
198        topCornerRadius: 4,
199        opacity: 0.5,
200        bottomCornerRadius: 4,
201        dataLabels: {
202            color: appTheme.ForegroundColor,
203            style: {
204                fontSize: 14,
205            },
206            numericFormat: ENumericFormat.Engineering,
207            verticalTextPosition: EVerticalTextPosition.Center,
208            horizontalTextPosition: EHorizontalTextPosition.Center,
209            metaDataSelector: (md) => {
210                const metadata = md as { name: string; percentComplete: number; isSelected: boolean };
211                return `${metadata.percentComplete.toString()} %`;
212            },
213        },
214    });
215
216    sciChartSurface.renderableSeries.add(rectangleGanttSeries);
217
218    const tooltipDataTemplate: TCursorTooltipDataTemplate = (seriesInfos: SeriesInfo[]) => {
219        const valuesWithLabels: string[] = [];
220
221        seriesInfos.forEach((si) => {
222            const xySI = si;
223            if (xySI.isWithinDataBounds) {
224                if (!isNaN(xySI.yValue) && xySI.isHit) {
225                    valuesWithLabels.push(
226                        `Start: ${new Date(
227                            (xySI.pointMetadata as { startDate: number }).startDate
228                        ).toLocaleDateString()}, End: ${new Date(
229                            (xySI.pointMetadata as { endDate: number }).endDate
230                        ).toLocaleDateString()}`
231                    );
232                }
233            }
234        });
235        return valuesWithLabels;
236    };
237
238    // Add interactivity modifiers
239    sciChartSurface.chartModifiers.add(
240        new ZoomPanModifier({
241            enableZoom: true,
242            xyDirection: EXyDirection.XDirection, // Only zoom horizontally
243        }),
244        new ZoomExtentsModifier(),
245        new CursorModifier({
246            showTooltip: true,
247            tooltipDataTemplate,
248            showXLine: false,
249            showYLine: false,
250            tooltipContainerBackground: appTheme.MutedRed + 55,
251        })
252    );
253
254    return {
255        sciChartSurface,
256        wasmContext,
257    };
258};
259

Angular Gantt Chart Example

Overview

This Angular example creates a Gantt Chart using the ScichartAngularComponent to visualize project timelines. The standalone component approach demonstrates clean integration with Angular's architecture.

Technical Implementation

The chart configuration is delegated to the drawExample function which sets up the SciChartSurface with DateTimeNumericAxis and customized CategoryAxis. The FastRectangleRenderableSeries displays tasks with completion percentage labels.

Features and Capabilities

The implementation includes horizontal zooming via ZoomPanModifier, task tooltips, and automatic axis ranging. The use of EColumnMode.StartEnd ensures accurate task duration representation.

Integration and Best Practices

The example follows Angular best practices by using standalone components and property binding. Developers can extend this by adding @Input properties for dynamic data or implementing Angular services for data management while maintaining high rendering performance.

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

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.