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

RadCartesianChart CandleSticks color not working

5 Answers 137 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Davor
Top achievements
Rank 1
Davor asked on 05 Nov 2014, 01:34 PM
Hello, I am trying to color the CandleSticks within a RadCartesianChart but the code does not seem to be working. This is the code:

<telerik:RadCartesianChart.Series>

    <telerik:CandlestickSeries ItemsSource="{Binding currentDataSource}"
           OpenBinding="Open"
           HighBinding="High"
           LowBinding="Low"
           CloseBinding="Close" 
           CategoryBinding="FromDate"
           TrackBallInfoTemplate="{StaticResource trackBallInfoTemplate}">

        <telerik:CandlestickSeries.DefaultVisualStyle>
            <Style TargetType="telerik:Candlestick">
                <Setter Property="StrokeThickness" Value="2" />
                <Setter Property="UpStroke" Value="Yellow" />
                <Setter Property="DownStroke" Value="Cyan" />
                <Setter Property="UpFill" Value="Green" />
                <Setter Property="DownFill" Value="Red"/>
            </Style>
        </telerik:CandlestickSeries.DefaultVisualStyle>
    </telerik:CandlestickSeries>

</telerik:RadCartesianChart.Series>

Also, is it possible to have different color for some of the candlesticks according to a custom logic? For example, if the value == 200, the candlesticks should be green, otherwise red. Thanks

5 Answers, 1 is accepted

Sort by
0
Peshito
Telerik team
answered on 07 Nov 2014, 11:30 AM
Hello Davor,

Please refer to our online help topic about Customizing Cartesian Chart Series. Using DeafultVisualStyleSelector will further help you customize the series in a way you would like.

Attached is a sample project demonstrating how to use the DefaultVisualStyleSelector.

Hope this helps.

Regards,
Peshito
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Davor
Top achievements
Rank 1
answered on 07 Nov 2014, 12:05 PM
Hello Peshito,
Thanks for the reply, but it didn't solve my problem.

The copy-paste code I posted in my first post was from the  Customizing Cartesian Chart Series guide you have sent me in the reply. 
Although I can not build your project, I get the code, except why are the SharpDX references. Also, your project uses OhlcDataPoint and I need CandleSticks.

So again, how can I get the code from my first post working?

Thanks,
Davor
0
Peshito
Telerik team
answered on 10 Nov 2014, 01:43 PM
Hi Davor,

Please excuse me for the unnecessary SharpDX assemblies included in the project. They are not needed for the sample project. It is a draft one. I should have forgotten them in there.

Onto your question about the CandleStickSeries. it uses OhlcDataPoints and once you run the project you will get the result you were asking for. I have attached the project once again(without the SharpDX assemblies), so you will simply have to run it. An image of the result I get is also attached to this thread.

Hope this helps.

Regards,
Peshito
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Davor
Top achievements
Rank 1
answered on 11 Nov 2014, 12:02 PM
Thanks Peshito,
I solved my problem, but I need to ask you one more question.
I change the style in runtime, on a click of a button. The color does not change unless I do this (in pseudo code):

var source = chart.currentSource;
chart.currentSource = null;
chart.currentSource = source;

Is this the right way or is there another, faster way (I mean already implemented function that I need to call)?

Thanks,
Davor
0
Peshito
Telerik team
answered on 12 Nov 2014, 08:45 AM
Hello,

You are probably hitting this kind of issue, because of the DefaultVisualStyleSelector. It has higher priority over the DefaultVisualStyle, which leads to the chart not being able to apply your new style. Simply remove the selector and the style should apply properly.

Regards,
Peshito
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Chart
Asked by
Davor
Top achievements
Rank 1
Answers by
Peshito
Telerik team
Davor
Top achievements
Rank 1
Share this question
or