This SciChart demo demonstrates how to create a Angular Non Uniform Heatmap Chart using SciChart.js our High Performance JavaScript Chart component.
drawExample.ts
angular.ts
theme.ts
1import { appTheme } from "../../../theme";
2import {
3 HeatmapColorMap,
4 MouseWheelZoomModifier,
5 NumericAxis,
6 NonUniformHeatmapDataSeries,
7 NonUniformHeatmapRenderableSeries,
8 NumberRange,
9 PinchZoomModifier,
10 SciChartSurface,
11 ZoomExtentsModifier,
12 ZoomPanModifier,
13} from "scichart";
14
15export const drawExample = async (rootElement: string | HTMLDivElement) => {
16 // Create a SciChartSurface with Theme
17 const { sciChartSurface, wasmContext } = await SciChartSurface.create(rootElement, {
18 theme: appTheme.SciChartJsTheme,
19 });
20
21 // Create an X, Y Axis
22 sciChartSurface.xAxes.add(new NumericAxis(wasmContext, { growBy: new NumberRange(0.1, 0.1) }));
23 sciChartSurface.yAxes.add(new NumericAxis(wasmContext, { growBy: new NumberRange(0.1, 0.1) }));
24
25 // Create some data for the heatmap as a 2d array
26 const heatmapWidth = 7;
27 const heatmapHeight = 4;
28 const zValues = Array.from(Array(heatmapHeight));
29 zValues.forEach((row, index, collection) => {
30 collection[index] = Array.from(Array(heatmapWidth));
31 });
32 let maxValue = Number.MIN_VALUE;
33 for (let x = 0; x < heatmapWidth; x++) {
34 for (let y = 0; y < heatmapHeight; y++) {
35 zValues[y][x] = 3.5 * ((heatmapHeight - y) * (heatmapWidth - x));
36 maxValue = Math.max(maxValue, zValues[y][x]);
37 }
38 }
39
40 // arrays with cell offsets
41 const xRangeOffsetsSource = [0, 10, 20, 26, 36, 60, 72, 84];
42 const yRangeOffsetsSource = [100, 250, 390, 410, 600];
43
44 // mapping functions that will calculate cell offsets based on heatmap width and height (zValues dimension sizes)
45 const xCellOffsets = (i: number) => xRangeOffsetsSource[i];
46 const yCellOffsets = (i: number) => yRangeOffsetsSource[i];
47
48 // Create the NonUniform Heatmap Series
49 const heatmapSeries = new NonUniformHeatmapRenderableSeries(wasmContext, {
50 // DataSeries defines data. This contains zValues 2D array plus the x and y cell offsets
51 dataSeries: new NonUniformHeatmapDataSeries(wasmContext, { zValues, xCellOffsets, yCellOffsets }),
52 // Color map defines how heatmap cells map to colours between minimum & maximum
53 colorMap: new HeatmapColorMap({
54 minimum: 0,
55 maximum: 100,
56 gradientStops: [
57 { offset: 0, color: appTheme.DarkIndigo },
58 { offset: 0.2, color: appTheme.Indigo },
59 { offset: 0.3, color: appTheme.VividSkyBlue },
60 { offset: 0.5, color: appTheme.VividGreen },
61 { offset: 0.7, color: appTheme.MutedRed },
62 { offset: 0.9, color: appTheme.VividOrange },
63 { offset: 1, color: appTheme.VividPink },
64 ],
65 }),
66 // optional settings
67 opacity: 0.77,
68 // values outside of the colorMap.min/max will be filled with the colours at edge of the colormap
69 fillValuesOutOfRange: true,
70 // add datalabels to the cells of the heatmap
71 dataLabels: {
72 style: {
73 fontFamily: "Arial",
74 fontSize: 16,
75 },
76 color: appTheme.ForegroundColor,
77 },
78 });
79
80 sciChartSurface.renderableSeries.add(heatmapSeries);
81
82 // add some interactivity
83 sciChartSurface.chartModifiers.add(
84 new ZoomPanModifier({ enableZoom: true }),
85 new ZoomExtentsModifier(),
86 new MouseWheelZoomModifier()
87 );
88
89 return { sciChartSurface };
90};
91This example demonstrates how to integrate SciChart.js into an Angular application using a standalone Angular component. The chart visualizes data with a non uniform heatmap where each cell can have variable sizes and offsets. It leverages Angular’s input binding to pass an initialization function to the ScichartAngularComponent, ensuring a smooth integration and dynamic chart creation.
The implementation is centered around the drawExample function which creates a SciChartSurface with a specific theme and performance optimizations provided via the WebAssembly context (wasmContext). Within the function, NumericAxis are created and added to the SciChartSurface. A NonUniformHeatmapDataSeries is then constructed using custom mapping functions for x and y cell offsets, enabling each heatmap cell to be placed precisely on the grid. The example further configures a HeatmapColorMap with gradient stops and data labels to enhance the visual representation. For more detailed information on non uniform heatmap charts, refer to the Non-Uniform Heatmap Chart Type documentation.
The example provides several advanced features such as interactive zooming and panning using modifiers like ZoomPanModifier, ZoomExtentsModifier, and MouseWheelZoomModifier. It supports dynamic customization of visual elements including opacity and color mapping, and includes data labels for each heatmap cell for clearer data visualization. The use of custom cell offset mapping ensures that developers can precisely control the layout of the heatmap. Additional insights on interactive chart controls can be obtained from the Tutorial on Adding Zooming, Panning Behavior.
By using the ScichartAngularComponent, the example adheres to Angular best practices for component-based architecture and input binding as described in Accepting data with input properties - Angular. The drawExample function is passed directly to the component as an input, demonstrating a clean and modular approach to chart initialization. Performance optimization is achieved by leveraging the WebAssembly context to handle intensive rendering operations, which aligns with guidelines from Memory Best Practices | JavaScript Chart Documentation - SciChart. For further guidance on Angular integration, developers may also review the scichart-angular and the Getting Started with SciChart JS resources.

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

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

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

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

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.

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.

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.

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 demo by SciChart supports gradient fill and paletteproviders for more custom coloring options. Get your free demo now.

Population Pyramid of Europe and Africa

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

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

Create Angular Text Chart with high performance SciChart.js.

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.

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

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

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

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 design made easy. Use SciChart.js' JavaScript Charts for high performance, feature-rich designs. Get free demo now.

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 made easy. Add animated, real-time updates with SciChart.js - high performance JavaScript Charts. Get free trial now.

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

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

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

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

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

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.

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

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

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

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

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.

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.

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

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

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

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

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.

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