Back to Devexpress

ChartStyleBase Class

mobilecontrols-devexpress-dot-xamarinforms-dot-charts-80415222.md

latest2.7 KB
Original Source

ChartStyleBase Class

The base class for all chart styles.

Namespace : DevExpress.XamarinForms.Charts

Assembly : DevExpress.XamarinForms.Charts.dll

NuGet Package : DevExpress.XamarinForms.Charts

Declaration

csharp
public abstract class ChartStyleBase :
    StyledElement

Remarks

The ChartStyleBase class contains appearance settings common to all types of charts. For example, you can use properties of this class to specify a chart background color, palette, or padding.

Example

This example demonstrates how to customize the appearance and layout of a chart.

xaml
<ContentPage>
    <ContentPage.BindingContext>
        <local:ViewModel/>
    </ContentPage.BindingContext>
    <dxc:ChartView>
        <!--...-->
        <dxc:ChartView.ChartStyle>
            <dxc:ChartStyle Palette="{Binding Palette}"
                            BackgroundColor="#bcebf7"
                            Padding="100, 50, 50, 50"
                            BorderColor="#800404"
                            BorderThickness="10"/>
            </dxc:ChartStyle>
        </dxc:ChartView.ChartStyle>
    </dxc:ChartView>
</ContentPage>
csharp
using Xamarin.Forms;
// ...
class ViewModel {
    // ...
    readonly Color[] palette;
    public Color[] Palette => palette;

    public ViewModel() {
        // ...
        palette = PaletteLoader.LoadPalette("#975ba5", "#03bfc1", "#800404");}
}

static class PaletteLoader {
    public static Color[] LoadPalette(params string[] values) {
        Color[] colors = new Color[values.Length];
        for (int i = 0; i < values.Length; i++)
            colors[i] = Color.FromHex(values[i]);
        return colors;
    }
}

Implements

INotifyPropertyChanged

Inheritance

Object ChartElement StyledElement ChartStyleBase ChartStyle

PieChartStyle

See Also

ChartStyleBase Members

DevExpress.XamarinForms.Charts Namespace