This is a migrated thread and some comments may be shown as answers.

Conditional Formatting for Candlestick

5 Answers 86 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 01 Jul 2009, 03:30 PM

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

5 Answers, 1 is accepted

Sort by
0
Accepted
Ves
Telerik team
answered on 03 Jul 2009, 03:08 PM
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.
0
Mike
Top achievements
Rank 1
answered on 06 Jul 2009, 06:07 PM

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.

0
Ves
Telerik team
answered on 08 Jul 2009, 08:55 AM
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.
0
Mike
Top achievements
Rank 1
answered on 08 Jul 2009, 03:14 PM
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
0
Dwight
Telerik team
answered on 13 Jul 2009, 11:59 AM
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.
Tags
Chart
Asked by
Mike
Top achievements
Rank 1
Answers by
Ves
Telerik team
Mike
Top achievements
Rank 1
Dwight
Telerik team
Share this question
or