Our Contours Chart example demonstrates how to create a Angular Contour-map Chart using our powerful JavaScript Chart Library.
drawExample.ts
angular.ts
theme.ts
1import {
2 HeatmapColorMap,
3 HeatmapLegend,
4 MouseWheelZoomModifier,
5 NumericAxis,
6 SciChartSurface,
7 UniformContoursRenderableSeries,
8 UniformHeatmapDataSeries,
9 UniformHeatmapRenderableSeries,
10 zeroArray2D,
11 ZoomExtentsModifier,
12 ZoomPanModifier,
13} from "scichart";
14import { appTheme } from "../../../theme";
15
16export const drawExample = async (rootElement: string | HTMLDivElement) => {
17 // Create a SciChartSurface
18 const { sciChartSurface, wasmContext } = await SciChartSurface.create(rootElement, {
19 theme: appTheme.SciChartJsTheme,
20 });
21
22 // Create an X & Y Axis
23 sciChartSurface.xAxes.add(new NumericAxis(wasmContext, { isVisible: false }));
24 sciChartSurface.yAxes.add(new NumericAxis(wasmContext, { isVisible: false }));
25
26 const heatmapWidth = 300;
27 const heatmapHeight = 200;
28
29 const colorPaletteMin = 0;
30 const colorPaletteMax = 200;
31
32 // Create a Heatmap Data-series. Pass heatValues as a number[][] to the UniformHeatmapDataSeries
33 const initialZValues = generateExampleData(3, heatmapWidth, heatmapHeight, colorPaletteMax);
34 const heatmapDataSeries = new UniformHeatmapDataSeries(wasmContext, {
35 zValues: initialZValues,
36 xStart: 0,
37 xStep: 1,
38 yStart: 0,
39 yStep: 1,
40 });
41
42 // Add the contours series and add to the chart
43 sciChartSurface.renderableSeries.add(
44 new UniformContoursRenderableSeries(wasmContext, {
45 dataSeries: heatmapDataSeries,
46 zMin: 20,
47 zMax: colorPaletteMax,
48 zStep: 20,
49 strokeThickness: 1,
50 stroke: appTheme.PaleSkyBlue,
51 })
52 );
53
54 // Create a background heatmap series with the same data and add to the chart
55 sciChartSurface.renderableSeries.add(
56 new UniformHeatmapRenderableSeries(wasmContext, {
57 dataSeries: heatmapDataSeries,
58 useLinearTextureFiltering: false,
59 opacity: 0.5,
60 colorMap: new HeatmapColorMap({
61 minimum: colorPaletteMin,
62 maximum: colorPaletteMax,
63 gradientStops: [
64 { offset: 1, color: appTheme.VividPink },
65 { offset: 0.9, color: appTheme.VividOrange },
66 { offset: 0.7, color: appTheme.MutedRed },
67 { offset: 0.5, color: appTheme.VividGreen },
68 { offset: 0.3, color: appTheme.VividSkyBlue },
69 { offset: 0.2, color: appTheme.Indigo },
70 { offset: 0, color: appTheme.DarkIndigo },
71 ],
72 }),
73 })
74 );
75
76 // Add interaction
77 sciChartSurface.chartModifiers.add(new ZoomPanModifier({ enableZoom: true }));
78 sciChartSurface.chartModifiers.add(new ZoomExtentsModifier());
79 sciChartSurface.chartModifiers.add(new MouseWheelZoomModifier());
80
81 return { sciChartSurface };
82};
83
84export const drawHeatmapLegend = async (rootElement: string | HTMLDivElement) => {
85 const { heatmapLegend, wasmContext } = await HeatmapLegend.create(rootElement, {
86 theme: {
87 ...appTheme.SciChartJsTheme,
88 sciChartBackground: appTheme.DarkIndigo + "BB",
89 loadingAnimationBackground: appTheme.DarkIndigo + "BB",
90 },
91 yAxisOptions: {
92 isInnerAxis: true,
93 labelStyle: {
94 fontSize: 12,
95 color: appTheme.ForegroundColor,
96 },
97 axisBorder: {
98 borderRight: 1,
99 color: appTheme.ForegroundColor + "77",
100 },
101 majorTickLineStyle: {
102 color: appTheme.ForegroundColor,
103 tickSize: 6,
104 strokeThickness: 1,
105 },
106 minorTickLineStyle: {
107 color: appTheme.ForegroundColor,
108 tickSize: 3,
109 strokeThickness: 1,
110 },
111 },
112 colorMap: {
113 minimum: 0,
114 maximum: 200,
115 gradientStops: [
116 { offset: 1, color: appTheme.VividPink },
117 { offset: 0.9, color: appTheme.VividOrange },
118 { offset: 0.7, color: appTheme.MutedRed },
119 { offset: 0.5, color: appTheme.VividGreen },
120 { offset: 0.3, color: appTheme.VividSkyBlue },
121 { offset: 0.2, color: appTheme.Indigo },
122 { offset: 0, color: appTheme.DarkIndigo },
123 ],
124 },
125 });
126
127 return { sciChartSurface: heatmapLegend.innerSciChartSurface.sciChartSurface };
128};
129
130// This function generates data for the heatmap with contours series example
131function generateExampleData(index: number, heatmapWidth: number, heatmapHeight: number, colorPaletteMax: number) {
132 const zValues = zeroArray2D([heatmapHeight, heatmapWidth]);
133
134 const angle = (Math.PI * 2 * index) / 30;
135 let smallValue = 0;
136 for (let x = 0; x < heatmapWidth; x++) {
137 for (let y = 0; y < heatmapHeight; y++) {
138 const v =
139 (1 + Math.sin(x * 0.04 + angle)) * 50 +
140 (1 + Math.sin(y * 0.1 + angle)) * 50 * (1 + Math.sin(angle * 2));
141 const cx = heatmapWidth / 2;
142 const cy = heatmapHeight / 2;
143 const r = Math.sqrt((x - cx) * (x - cx) + (y - cy) * (y - cy));
144 const exp = Math.max(0, 1 - r * 0.008);
145 const zValue = v * exp;
146 zValues[y][x] = zValue > colorPaletteMax ? colorPaletteMax : zValue;
147 zValues[y][x] += smallValue;
148 }
149
150 smallValue += 0.001;
151 }
152
153 return zValues;
154}
155
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.
Create Angular Non Uniform Chart using high performance SciChart.js. Display Heatmap with variable cell sizes. Get free demo now.
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