Search results

Spline Area in JavaScript Chart control

08 May 2023 / 2 minutes to read

Spline area

To render a spline area series, use series type as SplineArea and inject SplineAreaSeries module using Chart.Inject(SplineAreaSeries) method.

Source
Preview
index.ts
index.html
Copied to clipboard
import { Chart, SplineAreaSeries, Category } from '@syncfusion/ej2-charts';
import { polarCategory } from './datasource.ts';
Chart.Inject(SplineAreaSeries, Category);

let chart: Chart = new Chart({
    primaryXAxis: {
        valueType: 'Category'
    },
    series:[{
        dataSource: polarCategory,
        xName: 'x', yName: 'y',
        // Series type as SplineArea
        type: 'SplineArea'
    }],
}, '#element');
Copied to clipboard
<!DOCTYPE html>
<html lang="en">

<head>
            
    <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="index.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
</head>

<body>
    <div id='loader'>Loading....</div>
    <div id='container'>
        <div id='element'></div>
    </div>
</body>

</html>

Series customization

The following properties can be used to customize the spline area series.

  • fill – Specifies the color of the area series.
  • opacity – Specifies the opacity of fill.
  • dashArray – Specifies the dashes of series.
Source
Preview
index.ts
index.html
Copied to clipboard
import {
  Chart, DateTime, SplineAreaSeries,
} from '@syncfusion/ej2-charts';
Chart.Inject(SplineAreaSeries, DateTime);

let chart: Chart = new Chart(
  {
series: [
  {
    type: 'SplineArea',
    dataSource: [
      { x: 2000, y: 416 }, { x: 2001, y: 490 }, { x: 2002, y: 470 },
      { x: 2003, y: 500 }, { x: 2004, y: 449 }, { x: 2005, y: 470 },
      { x: 2006, y: 437 }, { x: 2007, y: 458 }, { x: 2008, y: 500 },
      { x: 2009, y: 473 }, { x: 2010, y: 520 }, { x: 2011, y: 520 }
    ],
    fill: 'blue', xName: 'x', yName: 'y', opacity: 0.5, border: { width: 2, color: 'red'}, dashArray: '2.5', marker: { visible: true}
  },
],
  },
  '#element'
);
Copied to clipboard
<!DOCTYPE html>
<html lang="en">

<head>
            
    <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="index.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
</head>

<body>
    <div id='loader'>Loading....</div>
    <div id='container'>
        <div id='element'></div>
    </div>
</body>

</html>

See Also