Creates a Angular Polar Scatter Chart using SciChart.js, with the PolarXyScatterRenderableSeries and custom legend-markers.
import {
PolarMouseWheelZoomModifier,
PolarZoomExtentsModifier,
PolarPanModifier,
XyDataSeries,
PolarNumericAxis,
SciChartPolarSurface,
EPolarAxisMode,
NumberRange,
EAxisAlignment,
EPolarLabelMode,
PolarXyScatterRenderableSeries,
SweepAnimation,
PolarLegendModifier,
ELegendOrientation,
TLegendItem,
EActionType,
EllipsePointMarker,
TrianglePointMarker,
} from "scichart";
import { appTheme } from "./appTheme";
export const drawExample = async (rootElement: string | HTMLDivElement) => {
const { sciChartSurface, wasmContext } = await SciChartPolarSurface.create(rootElement, {
theme: appTheme.SciChartJsTheme,
});
const radialYAxis = new PolarNumericAxis(wasmContext, {
polarAxisMode: EPolarAxisMode.Radial,
axisAlignment: EAxisAlignment.Right,
visibleRange: new NumberRange(0, 1400),
zoomExtentsToInitialRange: true,
drawMinorTickLines: false,
drawMajorTickLines: false,
drawMinorGridLines: false,
startAngle: Math.PI / 2,
drawLabels: false, // no radial labels
});
sciChartSurface.yAxes.add(radialYAxis);
const polarXAxis = new PolarNumericAxis(wasmContext, {
polarAxisMode: EPolarAxisMode.Angular,
axisAlignment: EAxisAlignment.Top,
polarLabelMode: EPolarLabelMode.Parallel,
visibleRange: new NumberRange(0, 360),
startAngle: Math.PI / 2, // start at 12 o'clock
flippedCoordinates: true, // go clockwise
zoomExtentsToInitialRange: true,
autoTicks: false,
majorDelta: 30,
drawMinorTickLines: false,
drawMajorTickLines: false,
drawMinorGridLines: false,
useNativeText: true,
labelPrecision: 0,
labelPostfix: "°",
});
sciChartSurface.xAxes.add(polarXAxis);
const xValues = Array.from({ length: 540 }, (_, i) => i);
const SCATTER_DATA = [
{
yVals: xValues.map((x) => 2 * x + x * Math.random() * 0.5),
color: appTheme.VividOrange,
name: "Circle Series",
pointMarkerType: EllipsePointMarker,
},
{
yVals: xValues.map((x) => x + x * Math.random() * 0.5),
color: appTheme.VividSkyBlue,
name: "Triangular Series",
pointMarkerType: TrianglePointMarker,
},
];
SCATTER_DATA.forEach(({ yVals, color, name, pointMarkerType }) => {
const polarScatter = new PolarXyScatterRenderableSeries(wasmContext, {
dataSeries: new XyDataSeries(wasmContext, {
xValues: xValues,
yValues: yVals,
dataSeriesName: name,
}),
opacity: 0.7,
stroke: color, // set stroke color for Legend modifier markers
pointMarker: new pointMarkerType(wasmContext, {
width: 10,
height: 10,
stroke: color,
strokeThickness: 1,
fill: color + "88",
}),
animation: new SweepAnimation({ duration: 800 }),
});
sciChartSurface.renderableSeries.add(polarScatter);
});
// Extra feature -> Custom legend marker with SVG shapes
const customMarkerLegendModifier = new PolarLegendModifier({
showCheckboxes: true,
showSeriesMarkers: true,
backgroundColor: "#66666633",
});
// override "getLegendItemHTML" to add custom SVG shapes
customMarkerLegendModifier.sciChartLegend.getLegendItemHTML = (
orientation: ELegendOrientation,
showCheckboxes: boolean,
showSeriesMarkers: boolean,
item: TLegendItem
): string => {
const display = orientation === ELegendOrientation.Vertical ? "flex" : "inline-flex";
let str = `<span class="scichart__legend-item" style="display: ${display}; align-items: center; margin-right: 4px; padding: 0 4px 0 5px; white-space: nowrap; gap: 5px">`;
if (showCheckboxes) {
const checked = item.checked ? "checked" : "";
str += `<input ${checked} type="checkbox" id="${item.id}">`;
}
if (showSeriesMarkers) {
str += `<svg
xmlns="http://www.w3.org/2000/svg"
for="${item.id}"
style="width: 15px; height: 15px;"
viewBox="0 0 24 24"
stroke-width="2"
>
${(() => {
switch (item.name) {
case SCATTER_DATA[0].name: // Circle
return `<circle cx="12" cy="12" r="9" fill="${item.color + "88"}" stroke="${item.color}"/>`;
case SCATTER_DATA[1].name: // Triangle
return `<polygon points="12,2 22,22 2,22" fill="${item.color + "88"}" stroke="${
item.color
}"/>`;
default: // Others
return `<rect x="2" y="2" width="20" height="20" fill="${item.color + "88"}" stroke="${
item.color
}"/>`;
}
})()}
</svg>`;
}
str += `<label for="${item.id}">${item.name}</label>`;
str += `</span>`;
return str;
};
sciChartSurface.chartModifiers.add(
customMarkerLegendModifier,
new PolarPanModifier(),
new PolarZoomExtentsModifier(),
new PolarMouseWheelZoomModifier({
defaultActionType: EActionType.Zoom,
})
);
return { sciChartSurface, wasmContext };
};
This standalone Angular component renders a Polar Scatter Chart using SciChart.js. It demonstrates embedding drawExample within a ScichartAngularComponent to initialize radial and angular axes and plot multiple scatter series.
In the Angular component, drawExample calls SciChartPolarSurface.create to initialize the chart surface and WASM context. Radial and Angular axes are configured via PolarNumericAxis, including angle modes, visible ranges, and grid styling. PolarXyScatterRenderableSeries is used for each series, with SweepAnimation to animate points.
Key features include:
PolarLegendModifier, allowing checkboxes and series markersPolarPanModifier, PolarZoomExtentsModifier, PolarMouseWheelZoomModifierEmbed the chart by binding initChart to drawExample in the template. Use Angular’s lifecycle hooks to handle asynchronous initialization and call sciChartSurface.delete() in ngOnDestroy for cleanup. Follow Angular best practices for standalone components and async operations.




















