Name xaxis labels within my series

Thread is closed for posting
6 posts, 0 answers
  1. David
    David avatar
    8 posts
    Member since:
    Sep 2011

    Posted 03 Feb 2012 Link to this post

    ChartSeries objSeriesActual = new ChartSeries("Actual", ChartSeriesType.Bar);
    foreach (FinanceData objFinanceData in actualFinanceDataList)
    {
        objSeriesActual.AddItem(objFinanceData.Revenue, objFinanceData.Revenue.ToString());
    }
     
     
    ChartSeries objSeriesBudget = new ChartSeries("Budget", ChartSeriesType.Bar);
    foreach (FinanceData objFinanceData in budgetFinanceDataList)
    {
        objSeriesBudget.AddItem(objFinanceData.Revenue, objFinanceData.Revenue.ToString());
    }
     
     
    revenueFinanceChart.Series.Add(objSeriesActual);
    revenueFinanceChart.Series.Add(objSeriesBudget);
    revenueFinanceChart.DataBind();

    Dear Telerik,

    I have made a chart that displays two series of actual and budget finance data for some companies. I would like to now replace the xaxis labels 1, 2, 3 etc underneath the bars with the name of the companies. I want this to be picked up from the financedata lists such as
    using objSeriesActual.PlotArea.XAxis.AxisLabel.TextBlock.Text = objFinanceData.Name but this does not work; reference to object not found.
    How can I accomplish this?
  2. Evgenia
    Admin
    Evgenia avatar
    1406 posts

    Posted 08 Feb 2012 Link to this post

    Hello David,

    You can review this help topic where it is shown how to bind the Axis Labels to a property ofyour business object. For the purpose RadChart exposes the DataLabelsColumn property of the XAxis.

    Kind regards,
    Evgenia
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. David
    David avatar
    8 posts
    Member since:
    Sep 2011

    Posted 08 Feb 2012 Link to this post

    Thank you for your response.

    I am still not able to implement this after reading your link. As you can see by my example I am itterating through actualFinanceDataList  and budgetFinanceDataList and adding the items to the series. So I need to name my xaxis labels at that time right?

    Thanks

  5. Evgenia
    Admin
    Evgenia avatar
    1406 posts

    Posted 13 Feb 2012 Link to this post

    Hello David,

     As reviewing your code snippet again I saw that you are binding the two series to two collections of one and the same business object (FinanceData object). Do you really need this? I suggest that you create two properties in your FinanceData class for each series. Something like RevenueSeries1 and RevenueSeries2. Then you may easily bind the DataLabelsColumn property of the XAxis to a common property of your business object.

    Let me know if you need a sample for the described approach.

    All the best,
    Evgenia
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  6. David
    David avatar
    8 posts
    Member since:
    Sep 2011

    Posted 13 Feb 2012 Link to this post

    Thank you for your response.

    I would really appreciate a sample. Thanks again.
  7. Evgenia
    Admin
    Evgenia avatar
    1406 posts

    Posted 16 Feb 2012 Link to this post

    Hi David,

    You may find the sample project attached. I hope it helps.

    All the best,
    Evgenia
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017