Angular Chart Title

A Chart Title can be placed above, below, or either side of the chart, and be left, center or right aligned.

Fullscreen

Edit

 Edit

Docs

index.tsx

RandomWalkGenerator.ts

theme.ts

Copy to clipboard
Minimise
Fullscreen
1import { IThemeProvider, SciChartJsNavyTheme } from "scichart";
2
3const getCssColor = (cssVar: string, fallback: string): string => {
4    if (typeof document === "undefined") {
5        return fallback;
6    }
7    const cssValue = getComputedStyle(document.documentElement).getPropertyValue(cssVar).trim();
8    return cssValue || fallback;
9};
10
11export interface AppThemeBase {
12    SciChartJsTheme: IThemeProvider;
13
14    // general colors
15    ForegroundColor: string;
16    Background: string;
17
18    // Series colors
19    VividSkyBlue: string;
20    VividPink: string;
21    VividTeal: string;
22    VividOrange: string;
23    VividBlue: string;
24    VividPurple: string;
25    VividGreen: string;
26    VividRed: string;
27
28    MutedSkyBlue: string;
29    MutedPink: string;
30    MutedTeal: string;
31    MutedOrange: string;
32    MutedBlue: string;
33    MutedPurple: string;
34    MutedRed: string;
35
36    PaleSkyBlue: string;
37    PalePink: string;
38    PaleTeal: string;
39    PaleOrange: string;
40    PaleBlue: string;
41    PalePurple: string;
42}
43
44export class SciChart2022AppTheme implements AppThemeBase {
45    SciChartJsTheme = new SciChartJsNavyTheme();
46
47    // Dynamic colors
48    get TextColor() { return this.ForegroundColor; }
49    get ForegroundColor() {
50        return getCssColor("--text", "#F5F5F5");
51    }
52    get Background() {
53        return getCssColor("--bg-chart", this.SciChartJsTheme.sciChartBackground);
54    }
55
56    // Series colors
57    VividSkyBlue = "#50C7E0";
58    VividPink = "#EC0F6C";
59    VividTeal = "#30BC9A";
60    VividOrange = "#F48420";
61    VividBlue = "#364BA0";
62    VividPurple = "#882B91";
63    VividGreen = "#67BDAF";
64    VividRed = "#C52E60";
65
66    DarkIndigo = "#14233C";
67    Indigo = "#264B93";
68
69    MutedSkyBlue = "#83D2F5";
70    MutedPink = "#DF69A8";
71    MutedTeal = "#7BCAAB";
72    MutedOrange = "#E7C565";
73    MutedBlue = "#537ABD";
74    MutedPurple = "#A16DAE";
75    MutedRed = "#DC7969";
76
77    PaleSkyBlue = "#E4F5FC";
78    PalePink = "#EEB3D2";
79    PaleTeal = "#B9E0D4";
80    PaleOrange = "#F1CFB5";
81    PaleBlue = "#B5BEDF";
82    PalePurple = "#CFB4D5";
83}
84
85export const appTheme = new SciChart2022AppTheme();
86

ChartTitle - Angular

Overview

This example demonstrates the integration of SciChart.js within an Angular application to dynamically manage and update a chart title. The chart title is highly configurable, allowing placement above, below, or to either side of the chart, with flexible alignment options such as left, center, or right. By leveraging Angular’s modular architecture, this example ensures a responsive and maintainable charting solution.

Technical Implementation

The implementation encapsulates the SciChart.js initialization logic within Angular services, employing dependency injection as outlined in the Introduction to services and dependency injection documentation. Angular lifecycle hooks, such as ngOnInit, are used to initialize the chart and manage real-time updates using JSON-driven configuration, in line with the guidelines provided by Getting Started with SciChart JS.

Features and Capabilities

This example offers several advanced features including dynamic updates that reflect immediate changes in the chart title; advanced customization of title properties such as alignment, position, and multiline configurations; and efficient handling of WebGL rendering for optimal performance. These capabilities ensure that dynamic data binding and event handling are integrated seamlessly into the Angular framework.

Integration and Best Practices

The solution follows Angular best practices for third-party library integration. It makes extensive use of dependency injection to encapsulate SciChart.js logic and lifecycle hooks to manage component initialization and updates, as documented in Component Lifecycle - Angular. Performance optimizations are achieved by integrating Angular change detection techniques along with efficient WebGL canvas management, reflecting insights from Angular Performance Optimization - Dave Bush. This structured approach facilitates scalable and maintainable charting applications within the Angular ecosystem.

angular Chart Examples & Demos

See Also: Styling and Theming (11 Demos)

Chart Background Image with Transparency | SciChart.js

Chart Background Image with Transparency

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

Styling a Angular Chart in Code | Angular Charts | SciChart.js

Styling a Angular Chart in Code

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

Using Theme Manager in Angular Chart | SciChart.js Demo

Using Theme Manager in Angular Chart

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

Create a Custom Theme for Angular Chart | SciChart.js

Create a Custom Theme for Angular Chart

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

Coloring Series per-point using the PaletteProvider

Coloring Series per-point using the PaletteProvider

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

Angular Point-Markers Chart | Angular Charts | SciChart.js

Angular Point-Markers Chart

Demonstrates the different point-marker types for Angular Scatter charts (Square, Circle, Triangle and Custom image point-marker)

Dashed Line Styling | Angular Charts | SciChart.js Demo

Dashed Line Styling

Demonstrates dashed line series in Angular Charts with SciChart.js

Data Labels | Angular Charts | SciChart.js Demo

Data Labels

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

Angular Chart with Multi-Style Series | SciChart.js Demo

Angular Chart with Multi-Style Series

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

Angular Chart with lines split by thresholds | SciChart

Angular Chart with lines split by thresholds

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

NEW!
Angular Order of Rendering | Angular Charts | SciChart.js

Angular Order of Rendering Example

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.

SciChart Ltd, 16 Beaufort Court, Admirals Way, Docklands, London, E14 9XL.