RadCartesianChart CandleSticks color not working

6 posts, 0 answers
  1. Davor
    Davor avatar
    5 posts
    Member since:
    Oct 2014

    Posted 05 Nov 2014 Link to this post

    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

  2. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 07 Nov 2014 Link to this post

    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.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Davor
    Davor avatar
    5 posts
    Member since:
    Oct 2014

    Posted 07 Nov 2014 in reply to Peshito Link to this post

    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
  5. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 10 Nov 2014 Link to this post

    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.

     
  6. Davor
    Davor avatar
    5 posts
    Member since:
    Oct 2014

    Posted 11 Nov 2014 in reply to Peshito Link to this post

    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
  7. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 12 Nov 2014 Link to this post

    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.

     
Back to Top
UI for WPF is Visual Studio 2017 Ready