putting strings in the Xaxis of the radChart

6 posts, 0 answers
  1. Iheb
    Iheb avatar
    12 posts
    Member since:
    Sep 2012

    Posted 27 Jan 2013 Link to this post

    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;
        }

  2. Iheb
    Iheb avatar
    12 posts
    Member since:
    Sep 2012

    Posted 29 Jan 2013 Link to this post

    Come on Telerik please. Its not a difficult question :(
  3. UI for WPF is Visual Studio 2017 Ready
  4. Petar Kirov
    Admin
    Petar Kirov avatar
    425 posts

    Posted 30 Jan 2013 Link to this post

    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.

  5. Filander
    Filander avatar
    5 posts
    Member since:
    Oct 2011

    Posted 10 Jul 2013 Link to this post

    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
  6. Nikolay
    Admin
    Nikolay avatar
    385 posts

    Posted 12 Jul 2013 Link to this post

    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 >>
  7. Filander
    Filander avatar
    5 posts
    Member since:
    Oct 2011

    Posted 16 Jul 2013 Link to this post

    Thanks a lot !! 

    Best Regards!

    Edax Ucles - Silverlight Developer
Back to Top
UI for WPF is Visual Studio 2017 Ready