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

putting strings in the Xaxis of the radChart

5 Answers 90 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Iheb
Top achievements
Rank 1
Iheb asked on 27 Jan 2013, 04:50 PM
when my X Axis is of a time int it works perfectly. But when i put it as a string an error occurs("Input string was not in a correct format")

My XAML is like this
<telerik:RadChart Name="radChartCAMois">
                        <telerik:RadChart.SeriesMappings>
                            <telerik:SeriesMapping LegendLabel="Chiffre d'affaire en DT">
                                <telerik:SeriesMapping.SeriesDefinition>
                                    <telerik:Area3DSeriesDefinition/>
                                </telerik:SeriesMapping.SeriesDefinition>
                                <telerik:SeriesMapping.ItemMappings>
                                    <telerik:ItemMapping DataPointMember="XValue" FieldName="IntValue"></telerik:ItemMapping>
                                    <telerik:ItemMapping DataPointMember="YValue" FieldName="StringValue"></telerik:ItemMapping>
                                </telerik:SeriesMapping.ItemMappings>
                            </telerik:SeriesMapping>
                        </telerik:RadChart.SeriesMappings>
                    </telerik:RadChart>

and my code behing is like this
List<MyClass> a = new List<MyClass>{new MyClass{intValue = 1,stringValue = "s1"},new MyClass{intValue = 2,stringValue = "s2"}};
radChartCAMois.ItemsSource = a;

where MyClass is like this
class MyClass
    {
        public int intValue;
        public string stringValue;
    }

5 Answers, 1 is accepted

Sort by
0
Iheb
Top achievements
Rank 1
answered on 29 Jan 2013, 10:10 AM
Come on Telerik please. Its not a difficult question :(
0
Petar Kirov
Telerik team
answered on 30 Jan 2013, 12:19 PM
Hi Iheb,

The reason for the exception you are getting is that a YValue ItemMapping should always map to a numeric value. If you need to create a categorical chart (map numeric values to strings) then you need to use XCategory (instead of XValue) ItemMapping to the" StringValue" property of your "MyClass" class and YValue ItemMapping to the "intValue".
 
Regards,
Petar Kirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Filander
Top achievements
Rank 1
answered on 10 Jul 2013, 11:31 PM
Hi! i have the same property but miy propertys are fine.

I have this in XAML : 

<telerik:RadChart x:Name="RadChartCel1" Margin="766,162,10,70">
                    <telerik:RadChart.SeriesMappings>
                        <telerik:SeriesMapping LegendLabel="Maquinas">
                            <telerik:SeriesMapping.SeriesDefinition>
                                <telerik:BarSeriesDefinition></telerik:BarSeriesDefinition>
                            </telerik:SeriesMapping.SeriesDefinition>
                            <telerik:SeriesMapping.ItemMappings>
                                <telerik:ItemMapping DataPointMember="XValue" FieldName="Machine"></telerik:ItemMapping>
                                <telerik:ItemMapping DataPointMember="YValue" FieldName="Produced"></telerik:ItemMapping>
                            </telerik:SeriesMapping.ItemMappings>
                        </telerik:SeriesMapping>
                    </telerik:RadChart.SeriesMappings>
                </telerik:RadChart>

And i have that in code behind:

RadChartCel1.ItemsSource = ColeccionMaquinas.Where(r => r.SubGroup == 1 && r.Tipo == 1).Select(t => new MyClass { Machine = t.Machine, Produced= (int)t.Produced}).ToList();
 
 public class MyClass
 {
     public string Machine{ get; set; }
     public int Produced{ get; set; }
 }

And i try just

RadChartCel1.ItemsSource = new  { Maquina = "Machine", Producido = 9000 };


And Nothing !! help me Please, i dont know how to solve this issue.

i hope your help,

Edax Ucles - Silverlight Developer
0
Nikolay
Telerik team
answered on 12 Jul 2013, 05:19 AM
Hello,

 You should map your string property to XCategory, this is how the mapping should look : 

<telerik:SeriesMapping.ItemMappings>
                                <telerik:ItemMapping DataPointMember="XCategory" FieldName="Machine"></telerik:ItemMapping>
                                <telerik:ItemMapping DataPointMember="YValue" FieldName="Produced"></telerik:ItemMapping>
                            </telerik:SeriesMapping.ItemMappings>

Regards,
Nikolay
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Filander
Top achievements
Rank 1
answered on 16 Jul 2013, 04:36 PM
Thanks a lot !! 

Best Regards!

Edax Ucles - Silverlight Developer
Tags
Chart
Asked by
Iheb
Top achievements
Rank 1
Answers by
Iheb
Top achievements
Rank 1
Petar Kirov
Telerik team
Filander
Top achievements
Rank 1
Nikolay
Telerik team
Share this question
or