This section explains how to add markers to the sparkline.
To add marker to the sparkline, specify the visible
of markerSettings
as following values. The visible
will accept multiple values too.
The following code example shows enabling markers for all points.
[app.component.ts
]
import { Component } from '@angular/core';
@Component({
selector: 'app-container',
template: `<ejs-sparkline id='container' width='350px' height='200px' [markerSettings] ='markerSettings' [axisSettings] ='axisSettings' [dataSource]="data" >
</ejs-sparkline>`
})
export class AppComponent {
public data: object[] = [0, 6, 4, 1, 3, 2, 5];
public markerSettings: object= {
visible: ['All']
};
public axisSettings: object ={
minX: -1, maxX: 7, maxY: 7, minY: -1
};
};
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { SparklineModule, SparklineTooltipService } from '@syncfusion/ej2-angular-charts';
/**
* Module
*/
@NgModule({
imports: [
BrowserModule, SparklineModule
],
declarations: [AppComponent],
bootstrap: [AppComponent],
providers: [SparklineTooltipService]
})
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);
In sparkline, markers can be enabled for particular points such as the start, end, low, high, or negative. The following code examples shows enabling markers for the high and low points.
[app.component.ts
]
import { Component } from '@angular/core';
@Component({
selector: 'app-container',
template: `<ejs-sparkline id='container' width='350px' height='200px' [axisSettings]='axisSettings' [markerSettings]='markerSettings' lowPointColor= 'red' highPointColor= 'blue' [dataSource]="data" >
</ejs-sparkline>`
})
export class AppComponent {
public data: object[] = [3, 6, 4, 1, 3, 2, 5];
public axisSettings: object ={
minX: -1, maxX: 7, maxY: 7, minY: -1
};
public markerSettings: object ={
visible: ['High', 'Low']
};
};
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { SparklineModule, SparklineTooltipService } from '@syncfusion/ej2-angular-charts';
/**
* Module
*/
@NgModule({
imports: [
BrowserModule, SparklineModule
],
declarations: [AppComponent],
bootstrap: [AppComponent],
providers: [SparklineTooltipService]
})
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);
Sparkline markers can be customized in terms of fill color, border color, width, opacity, and size. The following code example shows customizing marker’s fill, border, and size.
[app.component.ts
]
import { Component } from '@angular/core';
@Component({
selector: 'app-container',
template: `<ejs-sparkline id='container' width='350px' height='200px' [axisSettings]='axisSettings' [markerSettings]='markerSettings' [dataSource]="data" >
</ejs-sparkline>`
})
export class AppComponent {
public data: object[] = [3, 6, 4, 1, 3, 2, 5];
public markerSettings: object= {
visible: ['All'],
size: 5, fill: 'white', border: { color: 'blue', width: 2}
};
public axisSettings: object= {
minX: -1, maxX: 7, maxY: 7, minY: -1
};
};
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { SparklineModule, SparklineTooltipService } from '@syncfusion/ej2-angular-charts';
/**
* Module
*/
@NgModule({
imports: [
BrowserModule, SparklineModule
],
declarations: [AppComponent],
bootstrap: [AppComponent],
providers: [SparklineTooltipService]
})
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);