Version

Styling the Chart Series ( XamDataChart)

Topic Overview

Purpose

This topic provides a brief overview on how to style the series of the XamDataChart™ 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:

Topic Purpose

This topic demonstrates how to create an instance of the XamDataChart control and set data binding.

This topic introduces the concept of chart Series and guides you to the discussion of series types, series data binding, and series legend.

Introduction

Chart series styling summary

The series XamDataChart 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 Opacity properties of the series.

Applying effects to chart series

Because the Series class used for the XamDataChart XamDataChart.Series collection is inherited from the Control class, it, too, exposes an Effect property. The property applies a visual effect to the series visual. The following table maps supported visual effects to the Effect property settings that configure them.

Effect name Looks like: Effect property setting

no effect

xamDataChart Styling the Chart Series 1.png

Not set

Blur

xamDataChart Styling the Chart Series 2.png

BlurEffect

Drop-shadow

xamDataChart Styling the Chart Series 3.png

DropShadowEffect

Each of the effects can be configured by changing the settings of the effect’s properties. The blur effect can be configured in terms of radius of the blur and the curve used to calculate the blur. The drop-shadow effect can be customized by changing the shadow color, its opacity, direction, offset and blur.

Styling the Chart Series by Applying Drop-Shadow Effect

Overview

There are two alternative ways to apply drop-shadow effect to the series:

Applying drop-shadow through the Effect property of the Series class

Set the Effect property of the Series class to a DropShadowEffect instance. The drop-shadow effect is applied out-of-the-box and further customization is possible through customizing the DropShadowEffect instance.

Applying drop-shadow through the IsDropShadowEnabled property of the series

Set the IsDropShadowEnabled property of the series to "true" . Customization of the effect in terms of changing its blur radius, color, direction, depth, and opacity is supported through the respective shadow-related properties of the Series (See Property settings and the example for details.).

Note
Note:

The Effect property, when set, overrides the settings of the IsDropShadowEnabled property and the shadow-related properties of the series and renders them ineffective.

The default drop-shadow effect differs depending on the series type.

Property settings

The following table lists the configurable aspects of the drop-shadow effect (when applied through the IsDropShadowEnabled property of the series) to their respective property settings. Note that for these settings to be effective, the Effect property of the series must not be set.

In order to configure: Use this property: And set it to:

The effect for the series as drop-shadow

"true"

The color of the shadow

The desired color

The offset of the shadow from the series visual

A double value indicating the offset in pixels.

The direction of the shadow

The desired direction in degrees as an angle from the series visual with 0 meaning the shadow being cast straight to the right, 90 – to the top, 180 – straight to the left and so on.

The opacity of the shadow

The desired double value in the range 0 to 1 with 0 meaning the shadow is transparent and 1 – the shadow is fully opaque

The definition level of the edges of the shadow (sharp/blurry)

The desired pixel double value representing the blur level. 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.

Example

This example demonstrates applying drop-shadow through the IsDropShadowEnabled property of the series. The screenshot below demonstrates how a line series in a XamDataChart control looks as a result of the following shadow-related settings:

xamDataChart Styling the Chart Series 3.png

Following is the code snippet for setting the shadow related properties of a chart’s line series:

In XAML:

…
<ig:LineSeries IsDropShadowEnabled="True"
               ShadowBlur="20"
               ShadowColor="DarkBlue"
               ShadowDepth="15"
               ShadowDirection="90"
               ShadowOpacity="0.8"
               Thickness="5"
               …
>
…

In Visual Basic:

…
Dim lineSeries = New LineSeries()
lineSeries.IsDropShadowEnabled = True
lineSeries.ShadowBlur = 20
lineSeries.ShadowColor = new SolidColorBrush("DarkBlue")
lineSeries.ShadowDepth = 15
lineSeries.ShadowDirection = 90
lineSeries.ShadowOpacity = 0.8
lineSeries.Thickness = 5
…

In C#:

…
LineSeries lineSeries = New LineSeries();
lineSeries.IsDropShadowEnabled = True;
lineSeries.ShadowBlur = 20;
lineSeries.ShadowColor = new SolidColorBrush("DarkBlue");
lineSeries.ShadowDepth = 15;
lineSeries.ShadowDirection = 90;
lineSeries.ShadowOpacity = 0.8;
lineSeries.Thickness = 5;
…

Related Content

Resources

The following material (available outside the Infragistics family of content) provides additional information related to this topic.

Resource Purpose

A bitmap effect that paints a drop shadow around the target texture.