Skip to content

Latest commit

 

History

History
480 lines (367 loc) · 16.7 KB

File metadata and controls

480 lines (367 loc) · 16.7 KB
layout post
title Stack area in
description Learn here all about Stack area in Syncfusion
platform ej2-javascript
control Stack area
publishingplatform
documentation ug
domainurl

Stack area Chart in ##Platform_Name## control

Stacked area

To render a stacked area series in your chart, you need to follow a few steps to configure it correctly. Here's a concise guide on how to do this:

  • Set the series type: Define the series type as StackingArea in your chart configuration. This indicates that the data should be represented as a stacked area chart, which is ideal for showing the contribution of each part to a total over time or across other categorical data.

{% if page.publishingplatform == "typescript" %}

  • Inject the StackingAreaSeries module: Use the Chart.Inject(StackingAreaSeries) method to inject the StackingAreaSeries module into your chart. This step is essential, as it ensures that the necessary functionalities for rendering stacked area series are available in your chart.

{% tabs %} {% highlight ts tabtitle="index.ts" %} {% include code-snippet/chart/chart-types-cs135/index.ts %} {% endhighlight %} {% highlight html tabtitle="index.html" %} {% include code-snippet/chart/chart-types-cs135/index.html %} {% endhighlight %} {% highlight ts tabtitle="datasource.ts" %} {% include code-snippet/chart/chart-types-cs135/datasource.ts %} {% endhighlight %} {% endtabs %}

{% previewsample "page.domainurl/code-snippet/chart/chart-types-cs135" %}

{% elsif page.publishingplatform == "javascript" %}

{% tabs %} {% highlight js tabtitle="index.js" %} {% include code-snippet/chart/chart-types-cs135/index.js %} {% endhighlight %} {% highlight html tabtitle="index.html" %} {% include code-snippet/chart/chart-types-cs135/index.html %} {% endhighlight %} {% endtabs %}

{% previewsample "page.domainurl/code-snippet/chart/chart-types-cs135" %} {% endif %}

Binding data with series

You can bind data to the chart using the dataSource property within the series configuration. This allows you to connect a JSON dataset or remote data to your chart. To display the data correctly, map the fields from the data to the chart series xName and yName properties.

{% if page.publishingplatform == "typescript" %}

{% tabs %} {% highlight ts tabtitle="index.ts" %} {% include code-snippet/chart/chart-types-cs237/index.ts %} {% endhighlight %} {% highlight html tabtitle="index.html" %} {% include code-snippet/chart/chart-types-cs237/index.html %} {% endhighlight %} {% highlight ts tabtitle="datasource.ts" %} {% include code-snippet/chart/chart-types-cs237/datasource.ts %} {% endhighlight %} {% endtabs %}

{% previewsample "page.domainurl/code-snippet/chart/chart-types-cs237" %}

{% elsif page.publishingplatform == "javascript" %}

{% tabs %} {% highlight js tabtitle="index.js" %} {% include code-snippet/chart/chart-types-cs237/index.js %} {% endhighlight %} {% highlight html tabtitle="index.html" %} {% include code-snippet/chart/chart-types-cs237/index.html %} {% endhighlight %} {% endtabs %}

{% previewsample "page.domainurl/code-snippet/chart/chart-types-cs237" %} {% endif %}

Series customization

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

Fill

The fill property determines the color applied to the series.

{% if page.publishingplatform == "typescript" %}

{% tabs %} {% highlight ts tabtitle="index.ts" %} {% include code-snippet/chart/chart-types-cs136/index.ts %} {% endhighlight %} {% highlight html tabtitle="index.html" %} {% include code-snippet/chart/chart-types-cs136/index.html %} {% endhighlight %} {% highlight ts tabtitle="datasource.ts" %} {% include code-snippet/chart/chart-types-cs136/datasource.ts %} {% endhighlight %} {% endtabs %}

{% previewsample "page.domainurl/code-snippet/chart/chart-types-cs136" %}

{% elsif page.publishingplatform == "javascript" %}

{% tabs %} {% highlight js tabtitle="index.js" %} {% include code-snippet/chart/chart-types-cs136/index.js %} {% endhighlight %} {% highlight html tabtitle="index.html" %} {% include code-snippet/chart/chart-types-cs136/index.html %} {% endhighlight %} {% endtabs %}

{% previewsample "page.domainurl/code-snippet/chart/chart-types-cs136" %} {% endif %}

The fill property can be used to apply a gradient color to the stacked area series. By configuring this property with gradient values, you can create a visually appealing effect in which the color transitions smoothly from one shade to another.

{% if page.publishingplatform == "typescript" %}

{% tabs %} {% highlight ts tabtitle="index.ts" %} {% include code-snippet/chart/chart-types-cs238/index.ts %} {% endhighlight %} {% highlight html tabtitle="index.html" %} {% include code-snippet/chart/chart-types-cs238/index.html %} {% endhighlight %} {% highlight ts tabtitle="datasource.ts" %} {% include code-snippet/chart/chart-types-cs238/datasource.ts %} {% endhighlight %} {% endtabs %}

{% previewsample "page.domainurl/code-snippet/chart/chart-types-cs238" %}

{% elsif page.publishingplatform == "javascript" %}

{% tabs %} {% highlight js tabtitle="index.js" %} {% include code-snippet/chart/chart-types-cs238/index.js %} {% endhighlight %} {% highlight html tabtitle="index.html" %} {% include code-snippet/chart/chart-types-cs238/index.html %} {% endhighlight %} {% endtabs %}

{% previewsample "page.domainurl/code-snippet/chart/chart-types-cs238" %} {% endif %}

Opacity

The opacity property specifies the transparency level of the fill. Adjusting this property allows you to control how opaque or transparent the fill color of the series appears.

{% if page.publishingplatform == "typescript" %}

{% tabs %} {% highlight ts tabtitle="index.ts" %} {% include code-snippet/chart/chart-types-cs239/index.ts %} {% endhighlight %} {% highlight html tabtitle="index.html" %} {% include code-snippet/chart/chart-types-cs239/index.html %} {% endhighlight %} {% highlight ts tabtitle="datasource.ts" %} {% include code-snippet/chart/chart-types-cs239/datasource.ts %} {% endhighlight %} {% endtabs %}

{% previewsample "page.domainurl/code-snippet/chart/chart-types-cs239" %}

{% elsif page.publishingplatform == "javascript" %}

{% tabs %} {% highlight js tabtitle="index.js" %} {% include code-snippet/chart/chart-types-cs239/index.js %} {% endhighlight %} {% highlight html tabtitle="index.html" %} {% include code-snippet/chart/chart-types-cs239/index.html %} {% endhighlight %} {% endtabs %}

{% previewsample "page.domainurl/code-snippet/chart/chart-types-cs239" %} {% endif %}

Border

Use the border property to customize the width, color and dasharray of the series border.

{% if page.publishingplatform == "typescript" %}

{% tabs %} {% highlight ts tabtitle="index.ts" %} {% include code-snippet/chart/chart-types-cs240/index.ts %} {% endhighlight %} {% highlight html tabtitle="index.html" %} {% include code-snippet/chart/chart-types-cs240/index.html %} {% endhighlight %} {% highlight ts tabtitle="datasource.ts" %} {% include code-snippet/chart/chart-types-cs240/datasource.ts %} {% endhighlight %} {% endtabs %}

{% previewsample "page.domainurl/code-snippet/chart/chart-types-cs240" %}

{% elsif page.publishingplatform == "javascript" %}

{% tabs %} {% highlight js tabtitle="index.js" %} {% include code-snippet/chart/chart-types-cs240/index.js %} {% endhighlight %} {% highlight html tabtitle="index.html" %} {% include code-snippet/chart/chart-types-cs240/index.html %} {% endhighlight %} {% endtabs %}

{% previewsample "page.domainurl/code-snippet/chart/chart-types-cs240" %} {% endif %}

Empty points

Data points with null or undefined values are considered empty. Empty data points are ignored and not plotted on the chart.

Mode

Use the mode property to define how empty or missing data points are handled in the series. The default mode for empty points is Gap.

{% if page.publishingplatform == "typescript" %}

{% tabs %} {% highlight ts tabtitle="index.ts" %} {% include code-snippet/chart/chart-types-cs241/index.ts %} {% endhighlight %} {% highlight html tabtitle="index.html" %} {% include code-snippet/chart/chart-types-cs241/index.html %} {% endhighlight %} {% highlight ts tabtitle="datasource.ts" %} {% include code-snippet/chart/chart-types-cs241/datasource.ts %} {% endhighlight %} {% endtabs %}

{% previewsample "page.domainurl/code-snippet/chart/chart-types-cs241" %}

{% elsif page.publishingplatform == "javascript" %}

{% tabs %} {% highlight js tabtitle="index.js" %} {% include code-snippet/chart/chart-types-cs241/index.js %} {% endhighlight %} {% highlight html tabtitle="index.html" %} {% include code-snippet/chart/chart-types-cs241/index.html %} {% endhighlight %} {% endtabs %}

{% previewsample "page.domainurl/code-snippet/chart/chart-types-cs241" %} {% endif %}

Fill

Use the fill property to customize the fill color of empty points in the series.

{% if page.publishingplatform == "typescript" %}

{% tabs %} {% highlight ts tabtitle="index.ts" %} {% include code-snippet/chart/chart-types-cs242/index.ts %} {% endhighlight %} {% highlight html tabtitle="index.html" %} {% include code-snippet/chart/chart-types-cs242/index.html %} {% endhighlight %} {% highlight ts tabtitle="datasource.ts" %} {% include code-snippet/chart/chart-types-cs242/datasource.ts %} {% endhighlight %} {% endtabs %}

{% previewsample "page.domainurl/code-snippet/chart/chart-types-cs242" %}

{% elsif page.publishingplatform == "javascript" %}

{% tabs %} {% highlight js tabtitle="index.js" %} {% include code-snippet/chart/chart-types-cs242/index.js %} {% endhighlight %} {% highlight html tabtitle="index.html" %} {% include code-snippet/chart/chart-types-cs242/index.html %} {% endhighlight %} {% endtabs %}

{% previewsample "page.domainurl/code-snippet/chart/chart-types-cs242" %} {% endif %}

Border

Use the border property to customize the width and color of the border for empty points.

{% if page.publishingplatform == "typescript" %}

{% tabs %} {% highlight ts tabtitle="index.ts" %} {% include code-snippet/chart/chart-types-cs243/index.ts %} {% endhighlight %} {% highlight html tabtitle="index.html" %} {% include code-snippet/chart/chart-types-cs243/index.html %} {% endhighlight %} {% highlight ts tabtitle="datasource.ts" %} {% include code-snippet/chart/chart-types-cs243/datasource.ts %} {% endhighlight %} {% endtabs %}

{% previewsample "page.domainurl/code-snippet/chart/chart-types-cs243" %}

{% elsif page.publishingplatform == "javascript" %}

{% tabs %} {% highlight js tabtitle="index.js" %} {% include code-snippet/chart/chart-types-cs243/index.js %} {% endhighlight %} {% highlight html tabtitle="index.html" %} {% include code-snippet/chart/chart-types-cs243/index.html %} {% endhighlight %} {% endtabs %}

{% previewsample "page.domainurl/code-snippet/chart/chart-types-cs243" %} {% endif %}

Events

Series render

The seriesRender event allows you to customize series properties, such as data, fill, and name, before they are rendered on the chart.

{% if page.publishingplatform == "typescript" %}

{% tabs %} {% highlight ts tabtitle="index.ts" %} {% include code-snippet/chart/chart-types-cs413/index.ts %} {% endhighlight %} {% highlight html tabtitle="index.html" %} {% include code-snippet/chart/chart-types-cs413/index.html %} {% endhighlight %} {% highlight ts tabtitle="datasource.ts" %} {% include code-snippet/chart/chart-types-cs413/datasource.ts %} {% endhighlight %} {% endtabs %}

{% previewsample "page.domainurl/code-snippet/chart/chart-types-cs413" %}

{% elsif page.publishingplatform == "javascript" %}

{% tabs %} {% highlight js tabtitle="index.js" %} {% include code-snippet/chart/chart-types-cs413/index.js %} {% endhighlight %} {% highlight html tabtitle="index.html" %} {% include code-snippet/chart/chart-types-cs413/index.html %} {% endhighlight %} {% endtabs %}

{% previewsample "page.domainurl/code-snippet/chart/chart-types-cs413" %} {% endif %}

Point render

The pointRender event allows you to customize each data point before it is rendered on the chart.

{% if page.publishingplatform == "typescript" %}

{% tabs %} {% highlight ts tabtitle="index.ts" %} {% include code-snippet/chart/chart-types-cs414/index.ts %} {% endhighlight %} {% highlight html tabtitle="index.html" %} {% include code-snippet/chart/chart-types-cs414/index.html %} {% endhighlight %} {% highlight ts tabtitle="datasource.ts" %} {% include code-snippet/chart/chart-types-cs414/datasource.ts %} {% endhighlight %} {% endtabs %}

{% previewsample "page.domainurl/code-snippet/chart/chart-types-cs414" %}

{% elsif page.publishingplatform == "javascript" %}

{% tabs %} {% highlight js tabtitle="index.js" %} {% include code-snippet/chart/chart-types-cs414/index.js %} {% endhighlight %} {% highlight html tabtitle="index.html" %} {% include code-snippet/chart/chart-types-cs414/index.html %} {% endhighlight %} {% endtabs %}

{% previewsample "page.domainurl/code-snippet/chart/chart-types-cs414" %} {% endif %}

Stack labels

The stackLabels in stacked charts display cumulative total values for stack segments directly using data labels. If a stacked point has negative values, the stack labels are displayed below the point.

{% if page.publishingplatform == "typescript" %}

{% tabs %} {% highlight ts tabtitle="index.ts" %} {% include code-snippet/chart/chart-types-cs491/index.ts %} {% endhighlight %} {% highlight html tabtitle="index.html" %} {% include code-snippet/chart/chart-types-cs491/index.html %} {% endhighlight %} {% highlight ts tabtitle="datasource.ts" %} {% include code-snippet/chart/chart-types-cs491/datasource.ts %} {% endhighlight %} {% endtabs %}

{% previewsample "page.domainurl/code-snippet/chart/chart-types-cs491" %}

{% elsif page.publishingplatform == "javascript" %}

{% tabs %} {% highlight js tabtitle="index.js" %} {% include code-snippet/chart/chart-types-cs491/index.js %} {% endhighlight %} {% highlight html tabtitle="index.html" %} {% include code-snippet/chart/chart-types-cs491/index.html %} {% endhighlight %} {% endtabs %}

{% previewsample "page.domainurl/code-snippet/chart/chart-types-cs491" %} {% endif %}

Stack labels customization

Stack labels have various properties for customization to enhance the visual based on your requirements:

  • visible - Specifies whether stack labels are visible. Setting to true will display the labels. Default is false.
  • fill - Defines the background color of the stack labels. Accepts valid CSS color strings (hex, RGBA, etc.). Default is transparent.
  • format - Formats the text displayed in the stack labels. Supports placeholders like {value}. Default is null.
  • angle - Specifies the rotation angle for stack labels in degrees. Default is 0.
  • rx - Defines the rounded corner radius along the X-axis (horizontal direction) for the stack label background. Default is 5.
  • ry - Defines the rounded corner radius along the Y-axis (vertical direction) for the stack label background. Default is 5.
  • margin - Configures the margin around the stack label (left, right, top, and bottom).
  • border - Configures the appearance of the stack label's border.
  • font - Customizes the stack label text, including font size, color, style, weight, and family.

{% if page.publishingplatform == "typescript" %}

{% tabs %} {% highlight ts tabtitle="index.ts" %} {% include code-snippet/chart/chart-types-cs491A/index.ts %} {% endhighlight %} {% highlight html tabtitle="index.html" %} {% include code-snippet/chart/chart-types-cs491A/index.html %} {% endhighlight %} {% highlight ts tabtitle="datasource.ts" %} {% include code-snippet/chart/chart-types-cs491A/datasource.ts %} {% endhighlight %} {% endtabs %}

{% previewsample "page.domainurl/code-snippet/chart/chart-types-cs491A" %}

{% elsif page.publishingplatform == "javascript" %}

{% tabs %} {% highlight js tabtitle="index.js" %} {% include code-snippet/chart/chart-types-cs491A/index.js %} {% endhighlight %} {% highlight html tabtitle="index.html" %} {% include code-snippet/chart/chart-types-cs491A/index.html %} {% endhighlight %} {% endtabs %}

{% previewsample "page.domainurl/code-snippet/chart/chart-types-cs491A" %} {% endif %}

See also