Conditional Formatting for Candlestick

6 posts, 1 answers
  1. Mike
    Mike avatar
    9 posts
    Member since:
    Jun 2009

    Posted 01 Jul 2009 Link to this post

    I would imagine there is a generalized solution for conditionalformatting, but I am particularly interested in the candlestick chart.

    Is there a way to present the data such that a datapointwith a gain (close higher than open) is rendered in green, where a loss (closelower than open) is rendered in red.

     

    Thanks,

    Mike

  2. Answer
    Ves
    Admin
    Ves avatar
    2926 posts

    Posted 03 Jul 2009 Link to this post

    Hello Mike,

    The general approach to this task is shown in this example. However, it seems more likely that such request is placed for candlestick series, so with Q2 release (which should be available for download in your account by now) we have exposed a public API. You can create a style with two setters for Fill  and EmptyFill properties with the desired colors:

    <Style x:Key="MyStyle" TargetType="chart:CandleStick"
                    <Setter Property="EmptyFill" Value="Green" > 
                    </Setter> 
                    <Setter Property="Fill" Value="Red" > 
                    </Setter> 
                </Style> 

    Then set the CandleStickSeriesDefinition.ItemStyle property with that style:

    CandleStickSeriesDefinition def = new CandleStickSeriesDefinition(); 
    def.ItemStyle = LayoutRoot.Resources["MyStyle"as Style; 
    RadChart1.DefaultView.ChartArea.DataSeries[0].Definition = def; 
     


    Hope this helps.

    Regards,
    Ves
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Mike
    Mike avatar
    9 posts
    Member since:
    Jun 2009

    Posted 06 Jul 2009 Link to this post

    I wonder if I have missed something simple. I am getting an error "invalid attribute value Chart:CandleStick for property TargetType" on the line <Style x:Key="MyStyle" TargetType="chart:CandleStick">

    I did install the Q2 release.

  4. Ves
    Admin
    Ves avatar
    2926 posts

    Posted 08 Jul 2009 Link to this post

    Hi Mike,

    You need references to Telerik.Windows.Controls.dll, Telerik.Windows.Controls.Charting.dll and Telerik.Windows.Data.dll. In addition, you need to register the chart xml namespace as shown in this help topic, namely:

    xmlns:chart="clr-namespace:Telerik.Windows.Controls.Charting;assembly=Telerik.Windows.Controls.Charting"

    Best regards,
    Ves
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Mike
    Mike avatar
    9 posts
    Member since:
    Jun 2009

    Posted 08 Jul 2009 Link to this post

    That was it.

    I wasn't sure what namespace the "chart" was set to in XAML as different examples available on your website use different namespaces.

    As a followup question - is there a way to replace the programatic setting of the style definition you have shown with a declarative assignment in XAML?

    Thanks,
    Mike
  6. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 13 Jul 2009 Link to this post

    Hi Mike,

    Unfortunately, there is no way to declaratively set the style.

    Best wishes,
    Evtim
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top