Horizontal Stacked Bar Chart Y axis

2 posts, 0 answers
  1. Joe Lozina
    Joe Lozina avatar
    25 posts
    Member since:
    Jun 2010

    Posted 01 Aug 2010 Link to this post

    Hi

    Ive created a Horizontal Stacked Bar Chart and it looks fine whn I follow the example and only use and array of double.

    The problem is when I want to use a y axis value and Id like the Z axis to be a string.

    I created a  Class ChartResults to hold the values
    public ChartResults(double total, string typeValue)
    {
        this.Total = total;
        this.TypeValue = typeValue;
    }


    When I try to fill the sample data. Ive only put one SeriesMapping in the below example to make it easier to read
    private void FillSampleChartData()
      {
          SeriesMapping sm1 = new SeriesMapping();
          StackedBarSeriesDefinition d1 = new HorizontalStackedBarSeriesDefinition();
          d1.StackGroupName = "Stack1";
          sm1.SeriesDefinition = d1;
          sm1.LegendLabel = "One";
          sm1.CollectionIndex = 0;
     
                     .............................................
     
          ItemMapping im1a = new ItemMapping("TypeValue", DataPointMember.YValue);
          ItemMapping im1b = new ItemMapping("Total", DataPointMember.XValue);
          sm1.ItemMappings.Add(im1a);
          sm1.ItemMappings.Add(im1b);
     
     
          RadChart1.SeriesMappings.Add(sm1);
                    ..........................................................   
                   
     
     
          List<ChartResults[]> itemsSource = new List<ChartResults[]>();
          ChartResults[] one= new ChartResults[] { new ChartResults(83, "a"), new ChartResults(75, "a"), new ChartResults(80, "a") };
          itemsSource.Add(one);
     
          RadChart1.ItemsSource = itemsSource;
     
      }

    I get the follwoing error
    unhandled exception in Silverlight Application
    System.FormatException:Input string was not in a correct format

    Can you let me know what I am doing wrong?

    Regards,
    Joe
  2. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 03 Aug 2010 Link to this post

    Hi Joe Lozina,

    You should map the string field TypeValue to DataPointMember.XCategory and the double field Total to DataPointMember.YValue. You can find more information on enabling the categorical axis mode here as well.

    Hope this helps.


    Best wishes,
    Freddie
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top