Version

Styling the Chart Series (igDataChart)

Topic Overview

Purpose

This topic provides a brief overview on how to style the series of the igDataChart™ control and demonstrates, as an example, how to apply drop-shadow effect to the series.

Required background

The following topics are prerequisites to understanding this topic:

This topic demonstrates how to add the igDataChart control to a page and bind it to data.

In this topic

This topic contains the following sections:

Introduction

Chart series styling summary

The igDataChart's series can be styled in many aspects, the main of which are applying different fill and outline brushes to the series. This is managed by the brush and outline properties of the series. Some other aspects of the series’ look-and-fill, such as the thickness of the outline and the opacity of the series, are configurable, too through the thickness and areaFillOpacity properties of the series.

In addition to managing the styling described above, drop-shadow effect can be applied to the chart series by setting the isDropShadowEnabled property.

Styling the Chart Series by Applying Linear Gradient Colors

The linear gradient effect is achieved, by setting the type of the brush or outline to "linearGradient" and providing an array of colorStops (at least two) with color and offset for each.

The following sample defines the chart configuration needed to achieve that effect:

Styling the Chart Series by Applying Drop-Shadow Effect

Drop-shadow effect configuration summary

With the drop-shadow effect, the series appear as if casting a shadow.

Applying the drop-shadow effect to the series is done by setting the isDropShadowEnabled property of the series to “true”. Customization of the effect in terms of configurable shadow type, blur radius, color, direction, and opacity is supported through the respective shadow-related properties of the series (See Drop-shadow effect configuration summary chart, Property settings, and the examples.).

Shadow types

Two types of shadows are available for the drop-shadow effect depending on whether the fill shape and the outline shape of a series cast separate shadows each or the series cast single monolith shadow:

  • Monolith shadow – one shadow is displayed for the visual of the series
  • Compound shadow – the fill part and outline part of the series each cast a separate shadow

The default schedule type is Monolith. The benefit of using the Compound shadow type is in the capability to visually fine-tune the drop-shadow effect.

Note: Currently, blur can be applied only to Compound shadows. For details on this limitation, see this note.

The shadow type is controlled by the useSingleShadow property. When this property is set to “true” (default), Monolith shadow is applied; when set to “false”, the shadow will be Compound.

Drop-shadow effect configuration summary chart

The following table explains briefly the configurable aspects of the chart drop-shadow effect and maps them to properties that configure them. The default drop-shadow effect styling differs depending on the series type. Further details and examples about configuring the shadow type after the table.

Configurable aspect Details Properties
Configurable type of the shadow Specifies whether the shadow can be configured (styled) individually for each series or only for the series visual as whole
Direction and offset The direction at which the shadow is cast as well as the horizontal and vertical offset from the series specified as X,Y offset co-ordinates relative to the top-left edge of the series’ bounds rectangle.
Color / Opacity The color of the shadow. If a semi-transparent color is specified, a semi-transparent shadow is rendered.
Blur The definition level of the edges of the shadow (sharp/blurry). The blur level is defined by the number of pixels throughout which the contour spreads and fades out. The higher the value, the blurrier the shadow.

Property settings

The following table lists the configurable aspects of the drop-shadow effect to their respective property settings.

In order to configure: Use this property: And set it to:
Drop-shadow effect to be used isDropShadowEnabled “true”
The type of the shadow useSingleShadow “true” or “false”
The color/opacity of the shadow shadowColor The desired color HTML name, HEX color code or RGBA color definition
The direction and offset The horizontal offset of the shadow from the series visual shadowOffsetX A double value indicating the offset in pixels
The vertical offset of the shadow from the series visual shadowOffsetY A double value indicating the offset in pixels
The blur level shadowBlur The desired pixel double value representing the blur level. The higher the value, the blurrier the shadow.
Note: Monolith shadows do not allow for the blur effect to be applied to them: when the useSingleShadow property is set to “true”, the shadowBlur setting is disregarded and no blur is applied to the shadow. This is a deliberate limitation due to a Google® Chrome™ bug and extended to all major browsers thus ensuring consistent behavior across all of them. This behavior is subject to change once the aforementioned Chrome issue is resolved. In the meantime, if you need to apply blur to the shadow, use the Compound type of shadow (useSingleShadow:"true").

Example – drop-shadow effect with Monolith shadow

This example demonstrates applying and styling a Monolith drop-shadow. Since the useSingleShadow property is "true" by default, setting it explicitly in the code is not necessary.

The screenshot below demonstrates how a line series in an igDataChart control looks as a result of the following shadow-related settings:

Property Value
isDropShadowEnabled true
shadowBlur 20
shadowColor "darkBlue"
shadowOffsetX 10
shadowOffsetY -15

Following is the code that implements this example.

In JavaScript:

series: [
    {
        type: "column",
        isDropShadowEnabled: true,
        shadowBlur: 20,
        shadowColor: "darkBlue",
        shadowOffsetX: 10,
        shadowOffsetY: -15
    }

Example – drop-shadow effect with Compound shadow

This example demonstrates applying a Compound drop-shadow with a blur.

The screenshot below demonstrates how a column series in a igDataChart control looks as a result of the following shadow-related settings:

Property Value
isDropShadowEnabled true
useSingleShadow false
shadowBlur 20
shadowColor “darkBlue”
shadowOffsetX 10
shadowOffsetY -15

Following is the code that implements this example.

In JavaScript:

series: [
    {
        type: "column",
        isDropShadowEnabled: true,
        useSingleShadow: false,
        shadowBlur: 20,
        shadowColor: "darkBlue",
        shadowOffsetX: 10,
        shadowOffsetY: -15,
      }

Related Content

Topics

The following topics provide additional information related to this topic.

General information and a procedure for updating styles and themes in Ignite UI for jQuery™ library.

View on GitHub