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

How to set DataPoint YValue of StackedBar on xaml ?

1 Answer 50 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Watit
Top achievements
Rank 2
Watit asked on 09 Jan 2012, 10:54 AM
<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.

1 Answer, 1 is accepted

Sort by
0
Accepted
Petar Marchev
Telerik team
answered on 12 Jan 2012, 10:04 AM
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 >>
Tags
Chart
Asked by
Watit
Top achievements
Rank 2
Answers by
Petar Marchev
Telerik team
Share this question
or