Search results

Appearance

The appearance of the sparkline can be customized using margin, container Area border, and container Area background.

Sparkline border

The containerArea border of the sparkline is used to render border to cover sparkline area.

The following code example shows the sparkline with overall border.

Source
Preview
index.html
App.jsx
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Syncfusion React Chart-Category Axis</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Essential JS 2 for React Components" />
    <meta name="author" content="Syncfusion" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
     <style>
        #loader {
            color: #008cff;
            height: 40px;
            left: 45%;
            position: absolute;
            top: 45%;
            width: 30%;
        }
        #sparkline {
            height : 350px;
            display: block;
        }
    </style>
</head>

<body>
        <div id='root'>
            <div id='loader'>Loading....</div>
        </div>
        <script src="app/index.js"></script>
</body>
</html>
import * as React from 'react';
import { SparklineComponent } from '@syncfusion/ej2-react-charts';
export class App extends React.Component {
    render() {
        return (<SparklineComponent id='sparkline' height='200px' width='350px' containerArea={{
            border: { color: '#033e96', width: 2 }
        }} border={{
            color: '#033e96', width: 1
        }} type='Area' fill='#b2cfff' dataSource={[3, 6, 4, 1, 3, 2, 5]}>
</SparklineComponent>);
    }
}

Sparkline padding

Padding is used to specify padding value between container and sparkline. By default, padding value of the sparkline is 5. Sparkline padding values are specified by the left, right, top, and bottom.

The following code example shows the sparkline with overall padding is set to 20.

Source
Preview
index.html
App.jsx
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Syncfusion React Chart-Category Axis</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Essential JS 2 for React Components" />
    <meta name="author" content="Syncfusion" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
     <style>
        #loader {
            color: #008cff;
            height: 40px;
            left: 45%;
            position: absolute;
            top: 45%;
            width: 30%;
        }
        #sparkline {
            height : 350px;
            display: block;
        }
    </style>
</head>

<body>
        <div id='root'>
            <div id='loader'>Loading....</div>
        </div>
        <script src="app/index.js"></script>
</body>
</html>
import * as React from 'react';
import { SparklineComponent } from '@syncfusion/ej2-react-charts';
export class App extends React.Component {
    render() {
        return (<SparklineComponent id='sparkline' height='200px' width='350px' containerArea={{
            border: { color: '#033e96', width: 2 }
        }} 
        // To render sparkline with padding
        padding={{ left: 20, right: 20, bottom: 20, top: 20 }} border={{
            color: '#033e96', width: 1
        }} type='Area' fill='#b2cfff' dataSource={[3, 6, 4, 1, 3, 2, 5]}>
</SparklineComponent>);
    }
}

Sparkline area customization

The background color of the sparkline area can be customized using the containerArea background color. By default, the sparkline background color is transparent.

Source
Preview
index.html
App.jsx
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Syncfusion React Chart-Category Axis</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Essential JS 2 for React Components" />
    <meta name="author" content="Syncfusion" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
     <style>
        #loader {
            color: #008cff;
            height: 40px;
            left: 45%;
            position: absolute;
            top: 45%;
            width: 30%;
        }
        #sparkline {
            height : 350px;
            display: block;
        }
    </style>
</head>

<body>
        <div id='root'>
            <div id='loader'>Loading....</div>
        </div>
        <script src="app/index.js"></script>
</body>
</html>
import * as React from 'react';
import { SparklineComponent } from '@syncfusion/ej2-react-charts';
expport;
class App extends React.Component {
    render() {
        return (<SparklineComponent id='sparkline' height='200px' width='350px' containerArea={{
            border: { color: '#033e96', width: 2 },
            // To render sparkline with background
            background: '#eff1f4',
        }} padding={{ left: 20, right: 20, bottom: 20, top: 20 }} border={{
            color: '#033e96', width: 1
        }} type='Area' fill='#b2cfff' dataSource={[3, 6, 4, 1, 3, 2, 5]}>
</SparklineComponent>);
    }
}

Sparkline theme

Datalabel and track line colors of the sparkline will be changed based on theme. For example, for dark theme, the color of datalabel and track line should be white; for light theme, their value should be black. The possible values for sparkline theme are Material, Fabric, Bootstrap, and Highcontrast.

The following code example shows the color for datalabel and track line is set to white for dark theme.

Source
Preview
index.html
App.jsx
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Syncfusion React Chart-Category Axis</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Essential JS 2 for React Components" />
    <meta name="author" content="Syncfusion" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
     <style>
        #loader {
            color: #008cff;
            height: 40px;
            left: 45%;
            position: absolute;
            top: 45%;
            width: 30%;
        }
        #sparkline {
            height : 350px;
            display: block;
        }
    </style>
</head>

<body>
        <div id='root'>
            <div id='loader'>Loading....</div>
        </div>
        <script src="app/index.js"></script>
</body>
</html>
import * as React from 'react';
import { SparklineComponent, Inject, SparklineTooltip } from '@syncfusion/ej2-react-charts';
export class App extends React.Component {
    render() {
        return (<SparklineComponent id='sparkline' height='200px' width='350px' 
        // To specify theme
        theme='Highcontrast' dataLabelSettings={{ visible: ['All'] }} tooltipSettings={{
            trackLineSettings: { visible: true }
        }} axisSettings={{
            minX: -1, maxX: 7
        }} lineWidth={3} border={{
            color: 'transparent', width: 2
        }} type='Line' fill='#007dd1' dataSource={[3, 6, 4, 1, 3, 2, 5]}>
    <Inject services={[SparklineTooltip]}/>
</SparklineComponent>);
    }
}