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};
91
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.
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.
Demonstrates how to color areas of the chart surface using background Annotations using SciChart.js Annotations API