How to define candlestick template?

4 posts, 0 answers
  1. Shantimohan
    Shantimohan avatar
    42 posts
    Member since:
    Jul 2012

    Posted 29 Oct 2012 Link to this post

    For the candlestick being displayed, I want to:
    1. Thicken the lines.
    2. Fill the rectangle with red or green colors.
    3. Change the color of the lines.

    How to get it?

  2. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 01 Nov 2012 Link to this post

    Hello Shantimohan,

    Currently the CandlestickSeries class does not support  dynamic choice of styles. You can only set the DefaultVisualStyle property to specify the visual style of the candle sticks. For example:

    <chart:CandlestickSeries.DefaultVisualStyle>
        <Style TargetType="chart:Candlestick">
            <Setter Property="StrokeThickness" Value="2" />
            <Setter Property="UpStroke" Value="{StaticResource PhoneForegroundBrush}" />
            <Setter Property="DownStroke" Value="{StaticResource PhoneForegroundBrush}" />
            <Setter Property="UpFill" Value="Green" />
            <Setter Property="DownFill" Value="Transparent"/>
        </Style>
    </chart:CandlestickSeries.DefaultVisualStyle>

    This XAML snippet assumes that this namespace is declared:
    xmlns:chart="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Chart"

    Please write again if you have other questions.

    Regards,
    Victor
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Shantimohan
    Shantimohan avatar
    42 posts
    Member since:
    Jul 2012

    Posted 01 Nov 2012 Link to this post

    Yes, I was looking for this. But unfortunately, none of the properties have any effect on rendering of CandleStick except for the "StrokeThickness".  What am I missing?
  5. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 06 Nov 2012 Link to this post

    Hello Shantimohan,

    Thanks for writing.
    I am afraid that I can not tell what is missing in your XAML since I haven't seen it. However, here is another XAML snippet that you can use to figure out what is different in your project.

    <chart:RadCartesianChart x:Name="chart">
        <chart:RadCartesianChart.Grid>
            <chart:CartesianChartGrid MajorLinesVisibility="XY" MajorXLineDashArray="5, 5" MajorYLineDashArray="5, 5">
                <chart:CartesianChartGrid.MajorXLineStyle>
                    <Style TargetType="Line">
                        <Setter Property="Shape.Stroke" Value="Gray" />
                    </Style>
                </chart:CartesianChartGrid.MajorXLineStyle>
                <chart:CartesianChartGrid.MajorYLineStyle>
                    <Style TargetType="Line">
                        <Setter Property="Shape.Stroke" Value="Gray" />
                    </Style>
                </chart:CartesianChartGrid.MajorYLineStyle>
            </chart:CartesianChartGrid>
        </chart:RadCartesianChart.Grid>
        <chart:RadCartesianChart.VerticalAxis>
            <chart:LinearAxis LineStroke="{StaticResource PhoneDisabledBrush}" LineThickness="2" Maximum="10" />
        </chart:RadCartesianChart.VerticalAxis>
        <chart:RadCartesianChart.HorizontalAxis>
            <chart:CategoricalAxis LineStroke="{StaticResource PhoneDisabledBrush}" LineThickness="2" />
        </chart:RadCartesianChart.HorizontalAxis>
        <chart:CandlestickSeries>
            <chart:CandlestickSeries.DefaultVisualStyle>
                <Style TargetType="chart: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>
            </chart:CandlestickSeries.DefaultVisualStyle>
             
            <my:OhlcDataPoint Category="Mon" Close="5" High="6" Low="3" Open="3.5" />
            <my:OhlcDataPoint Category="Tue" Close="5" High="8" Low="4" Open="6" />
            <my:OhlcDataPoint Category="Wed" Close="2.5" High="4" Low="2" Open="3.7" />
            <my:OhlcDataPoint Category="Thu" Close="7" High="9" Low="6" Open="8.8" />
            <my:OhlcDataPoint Category="Fri" Close="6" High="7" Low="2" Open="3" />
        </chart:CandlestickSeries>
    </chart:RadCartesianChart>

    Please write again if you have other questions.

    Regards,
    Victor
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top