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

[Solved] Bar label positioning issue

1 Answer 40 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Zeno
Top achievements
Rank 1
Zeno asked on 05 Oct 2011, 10:04 AM
Hi team,

i m having some problem with the chart label top positioning
here is my code...
ChartSeries series = new ChartSeries();
series.Name = legendLabel;
series.Type = charttype;
series.DefaultLabelValue = "";
series.Appearance.Border.Visible = true;
series.Appearance.Border.Width = 1;
series.Appearance.Border.Color = Color.Gray;
series.Appearance.FillStyle.FillType = Telerik.Charting.Styles.FillType.Solid;
series.Appearance.Corners.TopLeft = Telerik.Charting.Styles.CornerType.Round;
series.Appearance.Corners.TopRight = Telerik.Charting.Styles.CornerType.Round;
series.Appearance.Corners.BottomLeft = Telerik.Charting.Styles.CornerType.Round;
series.Appearance.Corners.BottomRight = Telerik.Charting.Styles.CornerType.Round;
series.Appearance.FillStyle.MainColor = chartcolor;
series.Appearance.TextAppearance.TextProperties.Color = Color.Gray;
//series.Appearance.LabelAppearance.LabelLocation = Telerik.Charting.Styles.StyleSeriesItemLabel.ItemLabelLocation.Outside;
 
string axiscategory = string.Empty;
 
series.YAxisType = ChartYAxisType.Primary;
series.DefaultLabelValue = "#Y{C0}";
 
ch1.PlotArea.XAxis.AddRange(1, vals.Count, 1);
 
for (int i = 0; i < vals.Count; i++)
{
    switch (i)
    {
        case 0:
            axiscategory = "Client HW + MS VDA";
            break;
        case 1:
            axiscategory = "Server HW";
            break;
        case 2:
            axiscategory = "Storage HW";
            break;
        case 3:
            axiscategory = "Networking & Security HW";
            break;
        case 4:
            axiscategory = "VMW SW + SnS";
            break;
        case 5:
            axiscategory = "Infrastructure Admin";
            break;
        case 6:
            axiscategory = "Power & Cooling";
            break;
        case 7:
            axiscategory = "Rack Space & Office Space";
            break;
        case 8:
            axiscategory = "Services + Training";
            break;
        case 9:
            axiscategory = "Planned Downtime";
            break;
        case 10:
            axiscategory = "Unplanned Downtime";
            break;
        case 11:
            axiscategory = "Business Downtime";
            break;
        case 12:
            axiscategory = "Other + Tax";
            break;
        default:
            axiscategory = string.Empty;
            break;
    }
    ch1.PlotArea.XAxis[i].TextBlock.Text = axiscategory;
    ChartSeriesItem item = new ChartSeriesItem();
    item.XValue = i + 1;
    item.YValue = (Convert.ToDouble(Utility.CurrenyMultiplier(vals[i]))) / 1000;
    //item.Label.TextBlock.Text = "";
    item.Name = axiscategory;
    if (!string.IsNullOrEmpty(format))
        item.ActiveRegion.Tooltip = item.YValue.ToString(format);
    if (item.YValue == 0)
        item.Visible = false;
    series.Items.Add(item);
}
// This logic used for seriesitem label text will nevere hide or overlap     
ChartSeriesItem dummyitem = new ChartSeriesItem();
dummyitem.XValue = vals.Count + 1;// last item
dummyitem.YValue = (vals.Max() + (vals.Average() / 2)) / 1000;
dummyitem.Visible = false;
series.Items.Add(dummyitem);
return series;

1 Answer, 1 is accepted

Sort by
0
Peshito
Telerik team
answered on 07 Oct 2011, 03:27 PM
Hi Zeno,

Try setting the chart's IntelligentLabelsEnabled to false.

If this does not help, could you send us a runnable copy of your project, so we could further assist you and be able to better investigate what causes your issue.

Best wishes,
Peshito
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Chart
Asked by
Zeno
Top achievements
Rank 1
Answers by
Peshito
Telerik team
Share this question
or