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

Long Labels Problem

1 Answer 71 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
wj
Top achievements
Rank 1
wj asked on 03 Nov 2009, 06:46 PM

Hi,

I am implementing a horizontal bar chart drawing out how many times different links are clicked.
The problem is that the labels are not aligned properly. They show up in 2 or 3 columns and alternate between them.
Let say I have bars with equal length and it shows up as such:

bar 2
bar    2
bar 2
bar    2

I have tried setting labelLocation to inside or outside and other settings as well but it did not work.

Another problem is that I want to set the yAxis steps(now horizontal) to integer values because it does not make sense to have decimal places. How do I adjust the steps to jump by exactly 1 instead of 0.2 without specifying the maxvalues, min values etc because I do not know these values.  I tried setting LabelSteps to 5 but it only solves the problem for this chart. Is there a better way to do it?

Any help will be greatly appreciated.

My entire code is as such:

namespace TelerikTest  
{  
    public partial class _Default : System.Web.UI.Page  
    {  
        protected void Page_Load(object sender, EventArgs e)  
        {  
            //Chart Appearance   
            chartControl.PlotArea.Appearance.Border.Visible = false;  
          
            chartControl.IntelligentLabelsEnabled = true;  
            chartControl.AutoTextWrap = true;  
            chartControl.AutoLayout = true;  
            chartControl.SeriesOrientation = Telerik.Charting.ChartSeriesOrientation.Horizontal;  
 
            //Telerik bug: AutoScale will change xAxis Item label to 1.2.3.4.5....  
            chartControl.PlotArea.XAxis.AutoScale = false;  
 
            chartControl.Width = 800;  
            chartControl.Legend.Visible = false;  
            //chartControl.Legend.Appearance.Position.Auto = false;  
            chartControl.PlotArea.Appearance.Position.AlignedPosition = Telerik.Charting.Styles.AlignedPositions.Top;    
   
            Dictionary<string,int> items = new Dictionary<string,int>();  
            items.Add("First",1);  
            items.Add("Second",2);  
 
            for (int i = 0; i < 40; i++)  
            {  
                items.Add("http://testing1testing2testing3testing4.com" + i, 1);  
                int height = (int)chartControl.Height.Value;  
                chartControl.Height = height + 15;  
 
            }  
            loadBar("",items);  
        }  
 
        protected void loadBar(string seriesName, Dictionary<string,int> segments)  
        {  
            ChartSeries s = new ChartSeries(seriesName, ChartSeriesType.Bar);  
            int c = 0;  
            foreach (string segmentName in segments.Keys)  
            {  
                int segmentValue = segments[segmentName];  
                s.AddItem(segmentValue);  
                s.Items[c].Name = segmentName;  
                c++;  
            }  
            s.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.ItemLabels;  
            s.DefaultLabelValue = "#Y";  
            s.Appearance.LabelAppearance.Position.Auto = false;  
            s.Appearance.LabelAppearance.LabelLocation = Telerik.Charting.Styles.StyleSeriesItemLabel.ItemLabelLocation.Auto;  
            
            loadRadChart("chartTitle", s);  
        }  
 
        public void loadRadChart(string chartTitle, ChartSeries chartSeries)  
        {  
            chartControl.Clear();  
            chartControl.PlotArea.XAxis.Clear();  
 
            chartControl.ChartTitle.TextBlock.Text = chartTitle;  
 
            chartControl.Series.Add(chartSeries);  
 
            foreach (ChartSeriesItem item in chartSeries.Items)  
            {  
                if (item.YValue == 0.0) { item.Label.Visible = false; }  
                chartControl.PlotArea.XAxis.AddItem(item.Name);  
            }  
            chartControl.PlotArea.YAxis.LabelStep = 5;  
        }   
 
    }  
}  
 

1 Answer, 1 is accepted

Sort by
0
Velin
Telerik team
answered on 06 Nov 2009, 12:38 PM
Hi wj,

Please, remove the following line from your code. This should make your labels appear aligned to the right of the bars.
//RadChart1.IntelligentLabelsEnabled = true;
 
I'm afraid that you should configure all of the MaxValue, MinValue and Step properties in order to get the Y axis calculate the data range with the desired step.

Hope this helps.

Sincerely,
Velin
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Chart (Obsolete)
Asked by
wj
Top achievements
Rank 1
Answers by
Velin
Telerik team
Share this question
or