Selecting brush color based on value in item

4 posts, 0 answers
  1. Peter
    Peter avatar
    10 posts
    Member since:
    Oct 2011

    Posted 20 Oct 2011 Link to this post

     

     

     

     

    <

     

     

    telerik:RadTreeMap.TypeDefinitions>

     

     

     

     

     

     

     

     

     

    <telerik:TypeDefinition TargetTypeName="StepData" ValuePath="totalTime" ChildrenPath="Children"

     

     

     

    LabelPath="stepName" ToolTipPath="totalTime" ToolTipFormat="totalTime: {0:N0} ms">

     

     

     

     

     

     

     

     

     

    <telerik:TypeDefinition.Mappings>

     

     

     

     

     

     

     

     

     

    <telerik:BrushColorizer Brush="{StaticResource folderBackground}" />

     

     

     

     

     

     

     

     

     

    <telerik:BrushColorizer Brush="{Binding Path=Color}" TargetPropertyName="BorderBrush" />

     

     

     

     

     

     

     

     

     

    <telerik:BrushColorizer Brush="{StaticResource folderBorder}" TargetPropertyName="BorderBrush" />

     

     

     

     

     

     

     

     

     

    </telerik:TypeDefinition.Mappings>

     

     

     

     

     

     

     

     

     

    </telerik:TypeDefinition>

     

     

     

     

     

     

     

     

     

    <telerik:TypeDefinition TargetTypeName="Measurement" ValuePath="Total"

     

     

     

     

     

     

     

     

    LabelPath="stepName" ToolTipPath="totalTime" ToolTipFormat="totalTime: {0:N0} ms" >

     

     

     

     

     

     

     

     

     

    <telerik:TypeDefinition.Mappings>

     

     

     

     

     

     

     

     

     

    <!--example:FileCustomMapping -->

     

     

     

     

     

     

     

     

     

    <telerik:BrushColorizer Brush="{StaticResource folderBorder}" TargetPropertyName="BorderBrush" />

     

     

     

     

     

     

     

     

     

    </telerik:TypeDefinition.Mappings>

     

     

     

     

     

     

     

     

     

    </telerik:TypeDefinition>

     

     

     

     

     

     

     

     

     

    </telerik:RadTreeMap.TypeDefinitions>

     

     

     

     

     

     

     

     

     

    </telerik:RadTreeMap>

     

    I would like to select my brush color based on the value "Status" in the targettype stepdata.

  2. Yavor
    Admin
    Yavor avatar
    401 posts

    Posted 21 Oct 2011 Link to this post

    Hi Peter,

    By default all colorizers use the value of the rectangle (RadTreeMapItem) to do their color calculations. You can change this easily by specifying a new property for the colorizer to use with the ValuePath property like this:

    <telerik:AbsoluteValueBrushColorizer ValuePath="ChangeRate" Brushes="{StaticResource ColorizerBrushes}" RangeMinimum="-10" RangeMaximum="10" >
    </telerik:AbsoluteValueBrushColorizer>
    This approach is demonstrated in our AbsoluteValueBrush colorizer demo here.

    Another approach could be to use a custom mapping. Custom Mappings work the same way like Style and Template selectors. Take a look at CustomMapping online demo that applies an icon depending on the file type.

    Hope this information helps!

    Greetings,
    Yavor
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. Peter
    Peter avatar
    10 posts
    Member since:
    Oct 2011

    Posted 31 Oct 2011 Link to this post

    Yavor,
    Thanks for the suggestion. I tried both of your suggestions but they did not work because of the underlying problem with the data structure that was behind the treemap. In the custom mapping the I was not hiiting the event that allowed me to select the color. Eventually, I took the radfolder data structure that was working and transformed into my structure and then the events in the custom mapping was being processed.
    Because of how I resolved the problem, I have no idea what was the issue.
  5. Yavor
    Admin
    Yavor avatar
    401 posts

    Posted 02 Nov 2011 Link to this post

    Hello Peter,

    The colorizers look for properties whose name matches the one specified by the *Path property in your business object. Also check that you are binding to properties, not fields. If you want changes made to your business objects to update the treemap you have to implement INotifyPropertyChanged interface.

    Regards,
    Yavor
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top