Trends and signals
Control Chart <smart-control-chart>
ControlChart is a Shewhart control chart for statistical process control.
Angular ControlChart - Setup
The Smart.Industrial Angular modules are compiled for Angular 13 and later. An NgModule application needs Angular 13 or later. A standalone component that imports ControlChartModule needs Angular 14 or later.
Each component has its own Angular module. ControlChartModule declares and exports ControlChartComponent, which is not a standalone component. A standalone component lists the module in its imports, and an NgModule application lists it in the imports of its module. Steps 1 to 5 build a standalone application. Step 6 covers an NgModule application.
The complete demo in Angular is on the demo page, file by file.
1 NPM Install
The Angular modules are in the smart-industrial package:
npm install smart-industrial
2 Register styles
The stylesheets go into the styles of the build options in angular.json, next to the existing entries:
"styles": [ "node_modules/smart-industrial/source/styles/smart.default.css", "node_modules/smart-industrial/source/styles/smart.industrial-elements.css", "node_modules/smart-industrial/source/styles/smart.industrial.css" ]
smart.default.css is the base theme and smart.industrial-elements.css styles the Industrial components. smart.industrial.css is the Industrial theme, which applies to components with theme="industrial". For theme="industrial-dark", the package also has smart.industrial-dark.css.
3 Import the Angular module
The application imports ControlChartModule from the component's entry point. ControlChartComponent reaches a template through this module. A standalone component that lists ControlChartComponent itself in its imports does not compile (NG2011).
import { ControlChartModule } from 'smart-industrial/angular/controlchart';
Each component has an entry point of its own, and an application imports from those. The entry point with all the components, smart-industrial/angular, puts every component into the bundle. In a production build of the Faceplate sample, the main bundle is 274 kB with FaceplateModule and 8.9 MB with SmartIndustrialModule.
4 Root component (standalone)
The sample has three files: the component, its template in step 5, and src/main.ts. They replace the files of the same name that the CLI generated.
src/app/app.ts
import { Component } from '@angular/core';
import { ControlChartModule } from 'smart-industrial/angular/controlchart';
@Component({
selector: 'app-root',
standalone: true,
imports: [ControlChartModule],
templateUrl: './app.html'
})
export class App {
// Raised when the set of offending points changes, after new data, new limits
// or a different rule set, and not on every redraw.
onViolation(event: CustomEvent): void {
const { violations, count } = event.detail;
console.log('violation', violations, count);
}
}
src/main.ts
import { bootstrapApplication } from '@angular/platform-browser';
import { App } from './app/app';
bootstrapApplication(App).catch((err) => console.error(err));
A project from Angular CLI 20 or later already has these files. Its src/main.ts also passes an appConfig, which can stay. An older project names its root component AppComponent, in app.component.ts, and the sample does not use it.
5 Template (standalone)
src/app/app.html holds the markup. Strings are plain attributes. Numbers and booleans are property bindings, such as [precisionDigits]="3", so that they reach the component with their type and strictTemplates checks them. Each event of the component is an output named after it, such as (onViolation), and $event is the CustomEvent.
<smart-control-chart theme="industrial" type="xbar-r" label="Shaft diameter" unit="mm" [precisionDigits]="3" (onViolation)="onViolation($event)" ></smart-control-chart>
6 NgModule application
An NgModule application uses the same package and styles. Its module lists ControlChartModule in imports and declares the component that uses the template from step 5. src/main.ts starts the module with bootstrapModule. This works on Angular 13 and later. From Angular 19, a component declared in a module needs standalone: false.
Run
ng serve or npm start starts the development server at http://localhost:4200/.
Production build
A project created with ng new has an error budget of 1 MB for the initial bundle. The stylesheets alone come to 1.69 MB in a production build, because smart.default.css carries the base styles of the suite components that the Industrial components are built on. The initial bundle of the Faceplate sample is 2.00 MB, and ng build stops with a budget error. A higher initial budget in the production configuration of angular.json lets it pass:
"budgets": [
{ "type": "initial", "maximumWarning": "3MB", "maximumError": "4MB" },
{ "type": "anyComponentStyle", "maximumWarning": "4kB", "maximumError": "8kB" }
]
Each further component adds its module to the main bundle, so the budget grows with the number of components on the screen.
Smart UI for Angular - full documentation
Accessibility
The keyboard interaction, roles and announcements of the component are on its accessibility page; they are the same in Angular.