Angular Triangle Series | Triangle Mesh Chart

Creates a Angular Triangle Series Chart using SciChart.js, with the following features: drawing triangles in strip mode (for letter "S"), drawing triangles in list mode (for letter "c") and drawing polygons (for letter "i").

Fullscreen

Edit

 Edit

Docs

drawExample.ts

angular.ts

theme.ts

Copy to clipboard
Minimise
Fullscreen
1import {
2    EAxisAlignment,
3    NumberRange,
4    NumericAxis,
5    SciChartSurface,
6    XyDataSeries,
7    FastTriangleRenderableSeries,
8    ETriangleSeriesDrawMode,
9    CursorModifier,
10    IFillPaletteProvider,
11    EFillPaletteMode,
12    parseColorToUIntArgb,
13    IRenderableSeries,
14    MouseWheelZoomModifier,
15    ZoomExtentsModifier,
16    ZoomPanModifier,
17} from "scichart";
18import { appTheme } from "../../../theme";
19
20class SPaletteProvider implements IFillPaletteProvider {
21    public readonly fillPaletteMode = EFillPaletteMode.SOLID;
22    private readonly palettedRed = parseColorToUIntArgb(appTheme.VividRed);
23    private readonly palettedGreen = parseColorToUIntArgb(appTheme.MutedBlue);
24
25    // tslint:disable-next-line:no-empty
26    public onAttached(parentSeries: IRenderableSeries): void {}
27    // tslint:disable-next-line:no-empty
28    public onDetached(): void {}
29
30    public overrideFillArgb(xValue: number, yValue: number, index: number): number {
31        if (index % 3 === 0) {
32            // or index % 2 === 0 to make a nice graident
33            return this.palettedRed;
34        } else {
35            return this.palettedGreen;
36        }
37    }
38}
39
40function generateScaledAndRotatedEquilateralTriangles(centers: number[][]) {
41    const xCoordinates = [];
42    const yCoordinates = [];
43    const numTriangles = centers.length;
44
45    for (let i = 0; i < numTriangles; i++) {
46        const [centerX, centerY] = centers[i];
47        const side = 20 + (i / (numTriangles - 1)) * 20;
48        const angle = (i / (numTriangles - 1)) * 60 * (Math.PI / 180);
49        const height = (Math.sqrt(3) / 2) * side;
50        const vertices = [
51            [0, -height / 2],
52            [-side / 2, height / 2],
53            [side / 2, height / 2],
54        ];
55
56        const rotatedVertices = vertices.map(([x, y]) => {
57            const rotatedX = x * Math.cos(angle) - y * Math.sin(angle);
58            const rotatedY = x * Math.sin(angle) + y * Math.cos(angle);
59            return [rotatedX + centerX, rotatedY + centerY];
60        });
61
62        const xCoords = rotatedVertices.map((vertex) => vertex[0]);
63        const yCoords = rotatedVertices.map((vertex) => vertex[1]);
64
65        xCoordinates.push(xCoords);
66        yCoordinates.push(yCoords);
67    }
68    return { xCoordinates, yCoordinates };
69}
70
71export const drawExample = async (rootElement: string | HTMLDivElement) => {
72    const { sciChartSurface, wasmContext } = await SciChartSurface.create(rootElement, {
73        theme: appTheme.SciChartJsTheme,
74    });
75
76    sciChartSurface.debugRendering = false;
77    const xAxis = new NumericAxis(wasmContext, {
78        visibleRange: new NumberRange(0, 800),
79        flippedCoordinates: false,
80        axisAlignment: EAxisAlignment.Bottom,
81        labelPrecision: 2,
82        useNativeText: true,
83        drawMajorBands: false,
84    });
85    sciChartSurface.xAxes.add(xAxis);
86
87    const yAxis = new NumericAxis(wasmContext, {
88        visibleRange: new NumberRange(0, 500),
89        axisAlignment: EAxisAlignment.Left,
90        labelPrecision: 2,
91        flippedCoordinates: false,
92        useNativeText: true,
93        drawMajorBands: false,
94    });
95    sciChartSurface.yAxes.add(yAxis);
96
97    // Series 1 - The "S"
98    const sSeries = new FastTriangleRenderableSeries(wasmContext, {
99        dataSeries: new XyDataSeries(wasmContext, {
100            xValues: [
101                329, 300, 264, 234, 195, 174, 134, 136, 87, 106, 61, 103, 74, 115, 92, 129, 116, 164, 156, 193, 208,
102                247, 242, 286, 273, 321, 286, 327, 283, 321, 282, 308, 262, 280, 239, 213, 175, 144, 111, 82, 64,
103            ],
104            yValues: [
105                426, 411, 446, 415, 446, 417, 446, 414, 426, 396, 385, 370, 338, 341, 309, 313, 275, 295, 255, 284, 232,
106                264, 225, 248, 209, 212, 190, 174, 159, 136, 134, 102, 104, 75, 99, 68, 103, 76, 111, 83, 127,
107            ],
108        }),
109        fill: appTheme.MutedBlue,
110        drawMode: ETriangleSeriesDrawMode.Strip,
111        paletteProvider: new SPaletteProvider(),
112    });
113    sciChartSurface.renderableSeries.add(sSeries);
114
115    // Series 2 - The "C"
116    const triangleCenters = [
117        [566, 279],
118        [529, 292],
119        [483, 292],
120        [445, 274],
121        [409, 250],
122        [399, 208],
123        [401, 167],
124        [412, 129],
125        [437, 91],
126        [473, 77],
127        [527, 77],
128        [574, 90],
129    ];
130    const { xCoordinates, yCoordinates } = generateScaledAndRotatedEquilateralTriangles(triangleCenters);
131
132    const cSeries = new FastTriangleRenderableSeries(wasmContext, {
133        dataSeries: new XyDataSeries(wasmContext, {
134            xValues: xCoordinates.reduce((a, b) => a.concat(b), []),
135            yValues: yCoordinates.reduce((a, b) => a.concat(b), []),
136        }),
137        fill: appTheme.MutedBlue,
138        drawMode: ETriangleSeriesDrawMode.List,
139    });
140    sciChartSurface.renderableSeries.add(cSeries);
141
142    // Series 3 - The "I"
143    const pentagonsX = [
144        [696.0, 679.82, 686.0, 706.0, 712.18],
145        [696.0, 679.82, 686.0, 706.0, 712.18],
146        [696.0, 679.82, 686.0, 706.0, 712.18],
147        [696.0, 679.82, 686.0, 706.0, 712.18],
148        [696.0, 679.82, 686.0, 706.0, 712.18],
149        [696.0, 679.82, 686.0, 706.0, 712.18],
150        [696.0, 679.82, 686.0, 706.0, 712.18],
151    ];
152    const pentagonsY = [
153        [388.01, 376.26, 357.24, 357.24, 376.26],
154        [307.01, 295.26, 276.24, 276.24, 295.26],
155        [271.01, 259.26, 240.24, 240.24, 259.26],
156        [231.01, 219.26, 200.24, 200.24, 219.26],
157        [188.01, 176.26, 157.24, 157.24, 176.26],
158        [144.01, 132.26, 113.24, 113.24, 132.26],
159        [106.01, 94.26, 75.24, 75.24, 94.26],
160    ];
161
162    const iSeries = new FastTriangleRenderableSeries(wasmContext, {
163        dataSeries: new XyDataSeries(wasmContext, {
164            xValues: pentagonsX.reduce((a, b) => a.concat(b), []),
165            yValues: pentagonsY.reduce((a, b) => a.concat(b), []),
166        }),
167        fill: appTheme.VividRed,
168        drawMode: ETriangleSeriesDrawMode.Polygon,
169        polygonVertices: 5,
170    });
171    sciChartSurface.renderableSeries.add(iSeries);
172
173    sciChartSurface.chartModifiers.add(
174        new CursorModifier({
175            showTooltip: true,
176            crosshairStroke: "white",
177            tooltipContainerBackground: appTheme.DarkIndigo,
178            tooltipTextStroke: "white",
179            tooltipShadow: "transparent",
180            crosshairStrokeThickness: 1,
181            showAxisLabels: false,
182        }),
183        new MouseWheelZoomModifier(),
184        new ZoomExtentsModifier(),
185        new ZoomPanModifier()
186    );
187    return { sciChartSurface, wasmContext };
188};
189

Triangle Series Chart Example (Angular)

Overview

This example demonstrates how to create Triangle Series Chart using SciChart.js in a Angular environment. The chart illustrates key features such as different drawing modes, palette providers, and gradient palette fills, providing a high-performance real-time data visualization solution.

Technical Implementation

The chart is initialized by creating a SciChartSurface via the asynchronous call to SciChartSurface.create(), a method detailed in the Tutorial 01 - Including SciChart.js in an HTML Page using CDN. The implementation sets up numeric axes using the NumericAxis class and populates the chart with a FastTriangleRenderableSeries, which uses an XyDataSeries to manage the data points. Advanced customizations include setting rounded corners, a gradient fill created with IFillPaletteProvider. For more details on these aspects, refer to the The Triangle Series Type documentation.

Features and Capabilities

Key technical features of this example include interactive modifiers such as ZoomPanModifier, ZoomExtentsModifier, and MouseWheelZoomModifier which enhance user interaction by providing seamless zooming and panning capabilities. The series is further enhanced with data labels that are styled and positioned above each column for improved readability. The use of gradient fills via PaletteFactory not only enhances visual appeal but also demonstrates advanced customization options, aligning with best practices for high-performance WebGL rendering. Details on gradient customization can be found in the The PaletteFactory Helper Class documentation.

Integration and Best Practices

In a JavaScript integration, the chart is created and managed by directly invoking the drawExample function. Resource management is handled by returning a destructor function that calls sciChartSurface.delete(), ensuring that resources are properly freed when the chart is no longer needed. This approach aligns with recommended practices for WebAssembly integration and efficient memory management as explained in the Getting Started with SciChart JS guide. Additionally, the direct method of instantiating and disposing of the chart ensures optimal performance in high-frequency data scenarios.

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