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

Position of Bars

2 Answers 54 Views
Chart
This is a migrated thread and some comments may be shown as answers.
NickZ
Top achievements
Rank 1
NickZ asked on 23 Feb 2011, 06:25 AM
Hello, 
I created a simple bar series chart.  Every looks fine except the postion of bars.  There are three bars, the middle one is centered, the left one is aligned to left and right one is aligned to right.  How can I put left and right bars in the center of its own section.  I attach an image of my chart. 
Thank a lot for your help.
Nick

2 Answers, 1 is accepted

Sort by
0
Accepted
Evgenia
Telerik team
answered on 28 Feb 2011, 03:33 PM
Hi Shilong,

The issue with Bars alignment occurs because you created 3 Series with single Bar in each. When the ChartArea is populated with 3 series for example, RadChart makes each Bar with Width = 1/3 of the space between each two Major Tickpoints. This way the three Bar items (from the three series) which have XAxis=1 will be positioned accordingly.
What I can suggest is that you create single DataSerie with 3 items instead of 3 DataSeries with 1 item. To make them colored differently just set the LegendDisplayMode property of the SeriesDefinition  to DataPointLabel and set LegendLabel for each of the DataPoints as shown in our help topic
Here is how you can achieve this declaratively:
<control:RadChart x:Name="chart">
            <control:RadChart.DefaultView>
                <chart:ChartDefaultView>
  
                    <!--ChartArea-->
                    <chart:ChartDefaultView.ChartArea>
  
                        <chart:ChartArea LegendName="CustomLegend">
                            <chart:ChartArea.DataSeries>
                                <chart:DataSeries LegendLabel="Store Sales">
                                    <chart:DataSeries.Definition>
                                        <chart:BarSeriesDefinition LegendDisplayMode="DataPointLabel" />
                                    </chart:DataSeries.Definition>
                                    <chart:DataPoint YValue="15" LegendLabel="Telerik" />
                                    <chart:DataPoint YValue="5" LegendLabel="Microsoft"/>
                                    <chart:DataPoint YValue="11" LegendLabel="Others"/>
                                </chart:DataSeries>
                            </chart:ChartArea.DataSeries>
                        </chart:ChartArea>
  
                    </chart:ChartDefaultView.ChartArea>
  
                    <!--ChartLegend-->
                    <chart:ChartDefaultView.ChartLegend>
                        <chart:ChartLegend x:Name="CustomLegend" />
                    </chart:ChartDefaultView.ChartLegend>
  
                    <!--ChartTitle-->
                    <chart:ChartDefaultView.ChartTitle>
                        <chart:ChartTitle Content="Sales Summary" />
                    </chart:ChartDefaultView.ChartTitle>
  
                </chart:ChartDefaultView>
            </control:RadChart.DefaultView>
        </control:RadChart>

Kind regards,
Evgenia
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
NickZ
Top achievements
Rank 1
answered on 28 Feb 2011, 04:09 PM
Thanks a lot, Evgenia.  This solved my problem.
Tags
Chart
Asked by
NickZ
Top achievements
Rank 1
Answers by
Evgenia
Telerik team
NickZ
Top achievements
Rank 1
Share this question
or