How to set DataPoint YValue of StackedBar on xaml ?

2 posts, 1 answers
  1. Watit
    Watit avatar
    37 posts
    Member since:
    Oct 2011

    Posted 09 Jan 2012 Link to this post

    <telerik:RadChart x:Name="chartBuySell"
                                  Width="100"
                                  Height="15"
                                  x:FieldModifier="public">
                    <telerik:RadChart.SeriesMappings>
                        <!--  Series 1  -->
                        <telerik:SeriesMapping LegendLabel="Series 1">
                            <!--  ItemsSource="{Binding pSell}"  -->
                            <telerik:SeriesMapping.SeriesDefinition>
                                <telerik:HorizontalStackedBar100SeriesDefinition ShowItemLabels="True">
                                    <telerik:HorizontalStackedBar100SeriesDefinition.Appearance>
                                        <telerik:SeriesAppearanceSettings Stroke="Firebrick" StrokeThickness="1">
                                            <telerik:SeriesAppearanceSettings.Fill>
                                                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                                    <GradientStop Offset="0" Color="Red" />
                                                    <GradientStop Offset="1" Color="DarkRed" />
                                                </LinearGradientBrush>
                                            </telerik:SeriesAppearanceSettings.Fill>
                                        </telerik:SeriesAppearanceSettings>
                                    </telerik:HorizontalStackedBar100SeriesDefinition.Appearance>
                                </telerik:HorizontalStackedBar100SeriesDefinition>
                            </telerik:SeriesMapping.SeriesDefinition>
                            <telerik:ItemMapping DataPointMember="YValue" FieldName="pSell" />
    <Charting:DataPoint YValue="0.5"/>  

                        </telerik:SeriesMapping>
                        <telerik:SeriesMapping LegendLabel="Series 2">
                            <!--  ItemsSource="{Binding pBuy}"  -->
                            <telerik:SeriesMapping.SeriesDefinition>
                                <telerik:HorizontalStackedBar100SeriesDefinition ShowItemLabels="True">
                                    <telerik:HorizontalStackedBar100SeriesDefinition.Appearance>
                                        <telerik:SeriesAppearanceSettings Stroke="SeaGreen" StrokeThickness="1">
                                            <telerik:SeriesAppearanceSettings.Fill>
                                                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                                    <GradientStop Offset="0" Color="LightGreen" />
                                                    <GradientStop Offset="1" Color="Green" />
                                                </LinearGradientBrush>
                                            </telerik:SeriesAppearanceSettings.Fill>
                                        </telerik:SeriesAppearanceSettings>
                                    </telerik:HorizontalStackedBar100SeriesDefinition.Appearance>
                                </telerik:HorizontalStackedBar100SeriesDefinition>
                            </telerik:SeriesMapping.SeriesDefinition>
                            <telerik:ItemMapping DataPointMember="YValue" FieldName="pBuy" />
    <Charting:DataPoint YValue="0.5"/>  

                        </telerik:SeriesMapping>
                    </telerik:RadChart.SeriesMappings>
     
                    <telerik:RadChart.DefaultView>
                        <telerik:ChartDefaultView>
                            <telerik:ChartDefaultView.ChartArea>
                                <telerik:ChartArea Height="20"
                                                   Margin="0"
                                                   EnableAnimations="False"
                                                   ItemOverlapPercent="0"
                                                   ItemWidthPercent="300"
                                                   Padding="0">
                                    <telerik:ChartArea.AxisX>
                                        <telerik:AxisX AutoRange="False"
                                                       DefaultLabelFormat="0"
                                                       MaxValue="2"
                                                       MinValue="0"
                                                       PlotAreaAxisLabelsVisibility="Collapsed"
                                                       PlotAreaAxisVisibility="Collapsed"
                                                       Visibility="Collapsed" />
                                    </telerik:ChartArea.AxisX>
                                    <telerik:ChartArea.AxisY>
                                        <telerik:AxisY AutoRange="False"
                                                       DefaultLabelFormat="0"
                                                       MaxValue="100"
                                                       MinValue="0"
                                                       PlotAreaAxisLabelsVisibility="Collapsed"
                                                       PlotAreaAxisVisibility="Collapsed"
                                                       Step="1"
                                                       Visibility="Collapsed" />
                                    </telerik:ChartArea.AxisY>
                                </telerik:ChartArea>
                            </telerik:ChartDefaultView.ChartArea>
                            <telerik:ChartDefaultView.ChartLegend>
                                <telerik:ChartLegend Visibility="Collapsed" />
                            </telerik:ChartDefaultView.ChartLegend>
                        </telerik:ChartDefaultView>
                    </telerik:RadChart.DefaultView>
                </telerik:RadChart>


    I Need to set default value on xaml page
    <!--  Series 1  --> 
    <Charting:DataPoint YValue="0.5"/> 
    <!--  Series 2  --> 
    <Charting:DataPoint YValue="0.5"/>  

    How can i do?
    Thank You.

  2. Answer
    Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 12 Jan 2012 Link to this post

    Hi,

    You need to add the data points in the chart area's data series, as shown here.
    <telerik:RadChart.DefaultView>
     <telerik:ChartDefaultView>
      <telerik:ChartDefaultView.ChartArea>
       <telerik:ChartArea>                                                                                             
        <telerik:ChartArea.DataSeries>
         <telerik:DataSeries>
            <telerik:DataPoint XCategory="C1" YValue="5" />
            <telerik:DataPoint XCategory="C2" YValue="10" />
            <telerik:DataPoint XCategory="C3" YValue="8" />

    Note that these data points will be taken into account only if items source is not set.

    Greetings,
    Petar Marchev
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  3. DevCraft banner
Back to Top