Search results

Footer and Watermark in JavaScript Chart control

06 Jun 2023 / 2 minutes to read

By using annotation, you can place any html elements to chart in a desired view.

To create footer and watermark for chart, follow the given steps:

Step 1:

Initialize the custom elements by using the annotation property.

By using the content option of the annotation object, you can specify the id of the element that needs to be displayed in the chart area as follow,

Copied to clipboard
import { Chart, SplineSeries, ChartAnnotation, Category, Legend } from '@syncfusion/ej2-charts';
Chart.Inject(SplineSeries, Category, Legend, ChartAnnotation);
let chart: Chart = new Chart({
        //Initializing Primary X Axis
        primaryXAxis: {
            valueType: 'Category',
            interval: 1, majorGridLines: { width: 0 },
            labelIntersectAction: 'Rotate90'
        //Initializing Annotations
        annotations: [{ // watermark for chart
            content: '<div id="chart_cloud" style="font-size:450%; opacity: 0.3;" >syncfusion</div>',
            x: 'Wed', y: 20, coordinateUnits: 'Point', horizontalAlignment: 'Center'
        },{ //footer for chart
            content: '<div id="chart" > <a href="" target="_blank"></a></div>',
            x: 400, y: 340, coordinateUnits: 'Pixel', horizontalAlignment: 'Center'
        //Initializing Primary Y Axis
            minimum: 0,
            maximum: 40,
            interval: 10,
        //Initializing Chart Series
        series: [
                type: 'Spline',
                dataSource: [
                    { x: 'Sun', y: 15 }, { x: 'Mon', y: 5 },{ x: 'Tue', y: 32 },
                    { x: 'Wed', y: 15 },{ x: 'Thu', y: 29 }, { x: 'Fri', y: 24 },
                    { x: 'Sat', y: 18 },
                xName: 'x', width: 2, marker: {
                    visible: true
                yName: 'y', name: 'Max Temp',

        //Initializing Chart title
        title: 'NC Weather Report - 2016',
        height: '350px'
Copied to clipboard
<!DOCTYPE html>
<html lang="en">

    <title>EJ2 Animation</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Typescript UI Controls" />
    <meta name="author" content="Syncfusion" />
    <link href="" rel="stylesheet" rel="stylesheet">
    <link href="" rel="stylesheet">
    <script src=""></script>
    <script src="systemjs.config.js"></script>

    <div id='loader'>Loading....</div>
    <div id='container'>
        <div id='element'></div>
    <script id="Female-Material" type="text/x-template">
      <div id='templateWrap'>
     <table style="width:100%;  border: 1px solid black;">
     <tr><th colspan="2" bgcolor="#00FFFF">Female</th></tr>
     <tr><td bgcolor="#00FFFF">${x}:</td><td bgcolor="#00FFFF">${y}</td></tr>