Jump to content
Software FX Community

Displaying data from N properties of a Business object in a Bar chart with N bars


cbg3

Recommended Posts

As the title suggests, I have a business object that has a number of public properties on it, some of which I want to display in a Bar chart, and others I do not. The values of the properties I do want to display should be aggregated from the n series of business objects I hand to the chart's DataSource property, with the sum of each property displayed in a column in the Bar chart. Thus, if each instance of the business object has 3 properties I want to display, the Bar chart should have 3 columns.

The code I'm using is below. The issues I'm experiencing are that each series of data produces a new column in the bar chart, which is not what I want. The DisplayNames I specify for the FieldMaps are being ignored. Lastly, the property I don't want displayed, IrrelevantProperty, is being displayed.

Thanks for your support.

--------------- 

        chart1.Data.Series = 1;        chart1.Data.Points = 3;        Email[] emails = new Email[3];        emails[0] = new Email(50, 12, 23, 99);        emails[1] = new Email(30, 12, 23, 99);        emails[2] = new Email(40, 2, 4, 99);        chart1.DataSource = emails;        chart1.Gallery = Gallery.Bar;        chart1.DataSourceSettings.Fields.Clear();        fieldMap = new FieldMap();        fieldMap.Name = "EmailSetSize";        fieldMap.DisplayName = "Emails Sent";        fieldMap.Usage = FieldUsage.XValue;        chart1.DataSourceSettings.Fields.Add(fieldMap);        fieldMap = new FieldMap();        fieldMap.Name = "OptedOutSetSize";        fieldMap.DisplayName = "Opt Outs";        fieldMap.Usage = FieldUsage.XValue;        chart1.DataSourceSettings.Fields.Add(fieldMap);        fieldMap = new FieldMap();        fieldMap.Name = "BadSetSize";        fieldMap.DisplayName = "Bounces";        fieldMap.Usage = FieldUsage.XValue;        chart1.DataSourceSettings.Fields.Add(fieldMap);        fieldMap = new FieldMap();        fieldMap.Name = "IrrelevantProperty";        fieldMap.Usage = FieldUsage.NotUsed;        chart1.DataSourceSettings.Fields.Add(fieldMap);    class Email    {        private int emailSetSize;        public int EmailSetSize        {            get { return emailSetSize; }        }                private int badMailSetSize;        public int BadSetSize        {            get { return badMailSetSize; }        }        private int optedOutSetSize;        public int OptedOutSetSize        {            get { return optedOutSetSize; }        }        private int irrelevantProperty;        public int IrrelevantProperty        {            get { return irrelevantProperty; }        }        public Email(int emailSetSize, int badMailSetSize, int optedOutSetSize, int irrelevantProperty)        {            this.emailSetSize = emailSetSize;            this.badMailSetSize = badMailSetSize;            this.optedOutSetSize = optedOutSetSize;            this.irrelevantProperty = irrelevantProperty;        }    }
Link to comment
Share on other sites

Hi again,

After moving things around a bit in my code, I found that it seems order is important, and also figured out some things about series and points. Now I am able to get the data from the properties I want and not show the ones I don't. Still, the FieldMap.DisplayName is being ignored.

----

Email[] emails = new Email[3];emails[0] = new Email(50, 12, 23, 99);emails[1] = new Email(30, 12, 23, 99);emails[2] = new Email(40, 2, 4, 99);chart4.DataSource = emails;chart4.Gallery = Gallery.Bar;chart4.DataSourceSettings.Fields.Clear();FieldMap fieldMap;fieldMap = new FieldMap();fieldMap.Name = "EmailSetSize";fieldMap.DisplayName = "Emails Sent";fieldMap.Usage = FieldUsage.XValue;chart4.DataSourceSettings.Fields.Add(fieldMap);fieldMap = new FieldMap();fieldMap.Name = "OptedOutSetSize";fieldMap.DisplayName = "Opt Outs";fieldMap.Usage = FieldUsage.XValue;chart4.DataSourceSettings.Fields.Add(fieldMap);fieldMap = new FieldMap();fieldMap.Name = "BadSetSize";fieldMap.DisplayName = "Bounces";fieldMap.Usage = FieldUsage.XValue;chart4.DataSourceSettings.Fields.Add(fieldMap);chart4.Data.Series = chart4.DataSourceSettings.Fields.Count;chart4.Data.Points = chart4.DataSourceSettings.Fields.Count;class Email{    private int emailSetSize;    public int EmailSetSize    {        get { return emailSetSize; }    }        private int badMailSetSize;    public int BadSetSize    {        get { return badMailSetSize; }    }    private int optedOutSetSize;    public int OptedOutSetSize    {        get { return optedOutSetSize; }    }    private int irrelevantProperty;    public int IrrelevantProperty    {        get { return irrelevantProperty; }    }    public Email(int emailSetSize, int badMailSetSize, int optedOutSetSize, int irrelevantProperty)    {        this.emailSetSize = emailSetSize;        this.badMailSetSize = badMailSetSize;        this.optedOutSetSize = optedOutSetSize;        this.irrelevantProperty = irrelevantProperty;    }}
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...