Setting DisplayMember has no effect

3 posts, 1 answers
  1. OLIVER
    OLIVER avatar
    4 posts
    Member since:
    Aug 2012

    Posted 22 Aug 2012 Link to this post

    Hello Telerik,

    I`m currently evaluating wether the ChartView could fit our needs.

    Now I got stuck when trying to give the Y-values displayed in the Chart another format (currency):
    I`m setting LineSeries instance properties "DisplayMember" without achieving an effect i.e. the values are displayed the same way as if DisplayMember  was not set (f.e. 4995148.92 instead of 4.995.148.92 €).

    This is the code:

    public partial class Form1 : Form
    {
     
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            InitChartView();
        }       
     
        private void InitChartView()
        {
            var series1 = new LineSeries();
            series1.DisplayMember = "ValueFormatted";
            series1.ValueMember = "Value";
            series1.CategoryMember = "Category";
            series1.DataSource = Data.GetSomeDataYear1();
            series1.ShowLabels = true;
            radChartView1.Series.Add(series1);
     
            var series2 = new LineSeries();
            series2.ValueMember = "Value";
            series2.CategoryMember = "Category";
            series2.DisplayMember = "ValueFormatted";
            series2.DataSource = Data.GetSomeDataYear2();
            series2.ShowLabels = true;
            radChartView1.Series.Add(series2);
        }
    }
     
    public class SomeChartData
    {
        public decimal Value { get; set; }
        public string ValueFormatted { get { return Value.ToString("C", CultureInfo.GetCultureInfo("de-DE")); } }
        public string Category { get; set; }
    }
     
    public static class Data
    {
        public static IList<SomeChartData> GetSomeDataYear1(){
            return new List<SomeChartData>(){
                new SomeChartData() { Category = "Jan",        Value = 4845741.12M },
                new SomeChartData() { Category = "Feb",        Value = 4345642.41M },
                new SomeChartData() { Category = "März",       Value = 4237854.06M },
                new SomeChartData() { Category = "April",      Value = 4035341.33M },
                new SomeChartData() { Category = "Mai",        Value = 3843723.21M },
                new SomeChartData() { Category = "Juni",       Value = 4125344.42M },
                new SomeChartData() { Category = "Juli",       Value = 4443741.22M },
                new SomeChartData() { Category = "August",     Value = 4645530.42M },
                new SomeChartData() { Category = "September",  Value = 5144431.39M },
                new SomeChartData() { Category = "Oktober",    Value = 5034720.42M },
                new SomeChartData() { Category = "November",   Value = 5030842.98M },
                new SomeChartData() { Category = "Dezember",   Value = 4995148.92M }
            };
        }
    }

    Thanks in advance &
    Best regards
  2. OLIVER
    OLIVER avatar
    4 posts
    Member since:
    Aug 2012

    Posted 22 Aug 2012 Link to this post

    I forgot to mention : the Version is 2012.2.726.20.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Answer
    Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 24 Aug 2012 Link to this post

    Hello Oliver,

    Thank you for wriiting.

    I logged the issue in our Public Issue Tracking System. Currently, the rendering system of RadChartView does not support this functionality. For the next version we will extend and introduce the Label rendering and customization functionality. The new label elements will support DisplayMember binding, formatting settings and mechanism for override.

    Thank you for your time and cooperation. Your Telerik points have been updated.

    Kind regards,
    Julian Benkov
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Back to Top