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

Display Series Name & Value in the Bar for a Bar Chart

3 Answers 292 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Vamsi Pulavarthi
Top achievements
Rank 1
Vamsi Pulavarthi asked on 17 Jun 2012, 07:25 PM
Hello -
I am trying to display information in a Horizontal Bar chart. The Y axis information is a list of series that we care about. The names of the series are quite long as you will see from the screen shot.

I would like to display the Series Name along with the value where the actual value is currently displaying. Is that possible. If yes, can someone tell me how to do that?

Also is it possible to make the Chart move a little to the right and make sure the Legend space is utilized by the chart. Sometime I don't need a legend and would like to use that space instead.

thanks
Vamsi

In the picture, I would like to replace '38' with 'Determine ... Decision - 38'

3 Answers, 1 is accepted

Sort by
0
Evgenia
Telerik team
answered on 20 Jun 2012, 11:33 AM
Hello Vamsi,

You can achieve this as shown in the sample below:

protected void Page_Load(object sender, EventArgs e)
   {
       List<Product> products = new List<Product>();
       products.Add(new Product("Parka L", 120));
       products.Add(new Product("Parka M", 100));
       products.Add(new Product("Parka S", 132));
       products.Add(new Product("Wool Cap", 45));
       products.Add(new Product("Mittens", 67));
       ChartSeries serie = new ChartSeries();
       serie.Type = ChartSeriesType.Bar;
       foreach (Product product in products)
       {
           ChartSeriesItem item = new ChartSeriesItem();
           item.YValue = (double)product.QuantityInStock;
           item.Name = (string)product.Name;
           item.Label.TextBlock.Text = (string)product.Name + " - #Y";
           serie.Items.Add(item);
       }
       RadChart1.Series.Add(serie);
   }
   public class Product
   {
       public Product(string name, int quantityInStock)
       {
           _name = name;
           _quantityInStock = quantityInStock;
       }
       private string _name;
       public string Name
       {
           get { return _name; }
           set { _name = value; }
       }
       private int _quantityInStock;
       public int QuantityInStock
       {
           get { return _quantityInStock; }
           set { _quantityInStock = value; }
       }
   }

As to your second questions - turn on the AutoLayout property of the chart as it will automatically rearrange chart elements to be fully readable.

Regards,
Evgenia
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.
0
Vamsi Pulavarthi
Top achievements
Rank 1
answered on 20 Jun 2012, 12:44 PM
Thank You for your respnose Evgenia.

I finally did figure out last night how to do it. But I did it in a slightly different way.
Do you know of any pit falls of doing it this way?

Protected Sub decisionChart_ItemDataBound(sender As Object, e As Telerik.Charting.ChartItemDataBoundEventArgs) Handles decisionChart.ItemDataBound

        decisionChart.Legend.Visible = False
        e.SeriesItem.Name = CType(e.DataItem, DataRowView)("DecisionName").ToString()
        For Each item In decisionChart.Series(0).Items
            item.Label.Appearance.LabelLocation = Telerik.Charting.Styles.StyleSeriesItemLabel.ItemLabelLocation.Inside
            Dim str1 As String = item.Name()
            str1 = item.YValue & " - " & str1
            item.Label.TextBlock.Text = str1
            'item.YValue = str1
        Next

    End Sub


thanks
Vamsi
0
Evgenia
Telerik team
answered on 21 Jun 2012, 10:30 AM
Hello Vamsi,

 I'm glad that you managed to do this on your own. The approach you used is absolutely valid and it is up to you to pick up which one is more suitable for you.

All the best,
Evgenia
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 (Obsolete)
Asked by
Vamsi Pulavarthi
Top achievements
Rank 1
Answers by
Evgenia
Telerik team
Vamsi Pulavarthi
Top achievements
Rank 1
Share this question
or