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

Horizontal Stacked Bar Chart Y axis

1 Answer 79 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Joe Lozina
Top achievements
Rank 1
Joe Lozina asked on 01 Aug 2010, 11:17 AM
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

1 Answer, 1 is accepted

Sort by
0
Giuseppe
Telerik team
answered on 03 Aug 2010, 04:41 PM
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
Tags
Chart
Asked by
Joe Lozina
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Share this question
or