Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
955
Best way to configure custom settings.
posted

Infragistics.Controls.Charts.ColorMapper can be set on a TreeMap instance in the xaml.

If I wanted to set properties on the ColorMapper object manually, what is the best way to do it.

It seems like it is all manual. I would have to read the ToColor, FromColor and then grab the configured Color mapper and set the custom values

ColorMapper cm = this.TreeMap.ValueMappers[0] as ColorMapper;
cm.From = (Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("Pink");
cm.To = (Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("Black");

Is this the best way to do it?

 

thanks

  • 895
    posted

    Here is a ColorMapper definition in XAML code:

    <ig:ColorMapper
        ValueTypeName="Product"
    ValuePath="StandardCost"
    TargetProperty="Fill"
    MappingMode="AllNodes"
    From="Pink"
    To="Black" />

    Usually the code-behind approach is used if the ColorMapper is going to change during runtime.

    Also in XAML you can use data binding more easily.

  • 605
    posted

    If you want to create a color mapper in the c# code you need to do something like this

    ColorMapper colorMapper = new ColorMapper() { ValueTypeName = "Order", TargetProperty = "Fill", ValuePath = "Value", From = Colors.Red, To = Colors.Yellow};

    this.myTreemap.ValueMappers.Add(colorMapper);

    If you already have a defined color mapper you may do something like this:

    ColorMapper colorMapper = this.myTreemap.ValueMappers[0] as ColorMapper;

    colorMapper.From = Colors.Orange;

    colorMapper.To = Colors.Purple;