Demonstrates how to create custom data-point markers on scatter/line charts using SciChart.js, High Performance Angular Charts
drawExample.ts
angular.ts
theme.ts
1import { appTheme } from "../../../theme";
2
3import {
4 SciChartSurface,
5 XyDataSeries,
6 NumericAxis,
7 NumberRange,
8 EllipsePointMarker,
9 SquarePointMarker,
10 CrossPointMarker,
11 SpritePointMarker,
12 TrianglePointMarker,
13 createImageAsync,
14 ZoomPanModifier,
15 ZoomExtentsModifier,
16 MouseWheelZoomModifier,
17 SplineLineRenderableSeries,
18 LegendModifier,
19 ELegendOrientation,
20 ELegendPlacement,
21 TSciChart,
22} from "scichart";
23
24function createData(wasmContext: TSciChart) {
25 // Create some dataseries
26 const dataSeries1 = new XyDataSeries(wasmContext, { dataSeriesName: "Ellipse Marker" });
27 const dataSeries2 = new XyDataSeries(wasmContext, { dataSeriesName: "Square Marker" });
28 const dataSeries3 = new XyDataSeries(wasmContext, { dataSeriesName: "Triangle Marker" });
29 const dataSeries4 = new XyDataSeries(wasmContext, { dataSeriesName: "Cross Marker" });
30 const dataSeries5 = new XyDataSeries(wasmContext, { dataSeriesName: "Custom Marker" });
31
32 // Append values
33 const dataSize = 30;
34 for (let i = 0; i < dataSize; i++) {
35 dataSeries1.append(i, Math.random());
36 dataSeries2.append(i, Math.random() + 1);
37 dataSeries3.append(i, Math.random() + 1.8);
38 dataSeries4.append(i, Math.random() + 2.5);
39 dataSeries5.append(i, Math.random() + 3.6);
40 }
41
42 // Insert a break into th eline = we do this to test double.NaN for the point marker types
43 dataSeries1.update(15, NaN);
44 dataSeries2.update(15, NaN);
45 dataSeries3.update(15, NaN);
46 dataSeries4.update(15, NaN);
47 dataSeries5.update(15, NaN);
48
49 return [dataSeries1, dataSeries2, dataSeries3, dataSeries4, dataSeries5];
50}
51
52export const drawExample = (customPointImage: string) => async (rootElement: string | HTMLDivElement) => {
53 const { sciChartSurface, wasmContext } = await SciChartSurface.create(rootElement, {
54 theme: appTheme.SciChartJsTheme,
55 });
56
57 const dataSeriesArr = createData(wasmContext);
58
59 sciChartSurface.xAxes.add(new NumericAxis(wasmContext));
60 sciChartSurface.yAxes.add(new NumericAxis(wasmContext, { growBy: new NumberRange(0.1, 0.1) }));
61
62 // Add a line series with EllipsePointMarker
63 sciChartSurface.renderableSeries.add(
64 new SplineLineRenderableSeries(wasmContext, {
65 stroke: appTheme.VividSkyBlue,
66 strokeThickness: 3,
67 pointMarker: new EllipsePointMarker(wasmContext, {
68 width: 13,
69 height: 13,
70 strokeThickness: 2,
71 fill: appTheme.VividSkyBlue,
72 stroke: appTheme.ForegroundColor,
73 }),
74 dataSeries: dataSeriesArr[0],
75 })
76 );
77
78 // Add a scatter series with SquarePointMarker
79 sciChartSurface.renderableSeries.add(
80 new SplineLineRenderableSeries(wasmContext, {
81 stroke: appTheme.VividPink,
82 strokeThickness: 3,
83 pointMarker: new SquarePointMarker(wasmContext, {
84 width: 11,
85 height: 11,
86 strokeThickness: 2,
87 fill: appTheme.MutedPink,
88 stroke: appTheme.VividPink,
89 }),
90 dataSeries: dataSeriesArr[1],
91 })
92 );
93
94 // Add a scatter series with TrianglePointMarker
95 sciChartSurface.renderableSeries.add(
96 new SplineLineRenderableSeries(wasmContext, {
97 stroke: appTheme.VividOrange,
98 strokeThickness: 3,
99 pointMarker: new TrianglePointMarker(wasmContext, {
100 width: 13,
101 height: 13,
102 strokeThickness: 2,
103 fill: appTheme.VividOrange,
104 stroke: appTheme.VividOrange,
105 }),
106 dataSeries: dataSeriesArr[2],
107 })
108 );
109
110 // Add a scatter series with CrossPointMarker
111 sciChartSurface.renderableSeries.add(
112 new SplineLineRenderableSeries(wasmContext, {
113 stroke: appTheme.VividPurple,
114 strokeThickness: 3,
115 pointMarker: new CrossPointMarker(wasmContext, {
116 width: 13,
117 height: 13,
118 strokeThickness: 3,
119 stroke: appTheme.VividPurple,
120 }),
121 dataSeries: dataSeriesArr[3],
122 })
123 );
124
125 // Add a scatter series with Custom Image using SpritePointMarker
126 const imageBitmap = await createImageAsync(customPointImage);
127
128 sciChartSurface.renderableSeries.add(
129 new SplineLineRenderableSeries(wasmContext, {
130 stroke: appTheme.MutedOrange,
131 strokeThickness: 2,
132 pointMarker: new SpritePointMarker(wasmContext, {
133 image: imageBitmap,
134 }),
135 dataSeries: dataSeriesArr[4],
136 })
137 );
138
139 sciChartSurface.chartModifiers.add(new ZoomPanModifier({ enableZoom: true }));
140 sciChartSurface.chartModifiers.add(new ZoomExtentsModifier());
141
142 sciChartSurface.chartModifiers.add(new MouseWheelZoomModifier());
143 sciChartSurface.chartModifiers.add(
144 new LegendModifier({
145 orientation: ELegendOrientation.Horizontal,
146 placement: ELegendPlacement.TopLeft,
147 })
148 );
149
150 sciChartSurface.zoomExtents();
151
152 return { sciChartSurface, wasmContext };
153};
154This example demonstrates how to render custom data-point markers using SciChart.js within an Angular standalone component. It showcases a range of marker types including ellipse, square, triangle, cross, and a custom image marker, each applied to separate data series. Gaps in the data are intentionally introduced to demonstrate how the markers handle missing values.
The chart is initialized asynchronously using SciChartSurface.create(), which loads necessary WebAssembly resources as detailed in the Getting Started with SciChart JS guide. The component employs the scichart-angular package to integrate SciChart.js with Angular, binding the asynchronous initialization function directly in the template. Multiple renderable series are instantiated using SplineLineRenderableSeries, each with its own point marker set via classes such as EllipsePointMarker, SquarePointMarker, TrianglePointMarker, CrossPointMarker, and SpritePointMarker.
This example illustrates the ability to render high-performance charts with custom visual styles for each data series. Advanced features include real-time update capabilities supported by smooth WebGL rendering and interactive modifications through built-in modifiers like ZoomPanModifier and MouseWheelZoomModifier. The implementation further demonstrates handling asynchronous image loading for custom markers. For detailed marker configuration, refer to the SciChart.js PointMarkers Documentation.
By leveraging Angular’s component architecture, this example shows best practices for importing and configuring third-party libraries. It emphasizes asynchronous chart initialization and effective data binding within Angular standalone components. Developers interested in integrating SciChart to Angular can use the ScichartAngularComponent from the scichart-angular package on npm.

Demonstrates how to create a Angular Chart with background image using transparency in SciChart.js

Demonstrates how to style a Angular Chart entirely in code with SciChart.js themeing API

Demonstrates our Light and Dark Themes for Angular Charts with SciChart.js ThemeManager API

Demonstrates how to create a Custom Theme for a SciChart.js Angular Chart using our Theming API

Demonstrates per-point coloring in JavaScript chart types with SciChart.js PaletteProvider API

Demonstrates dashed line series in Angular Charts with SciChart.js

Show data labels on Angular Chart. Get your free demo now.

Demonstrates how to apply multiple different styles to a single series using RenderDataTransform

Demonstrates how to use a RenderDataTransform to split lines into multiple segments so they can be individually colored according to thresholds

Demonstrates chart title with different position and alignment options

The Angular Order of Rendering example gives you full control of the draw order of series and annotations for charts. Try SciChart's advanced customizations.