Ticket Q491714
Visible to All Users
Duplicate

Problem in displaying Enum List in Chart ( Enum List is not Displayed as required)

created 12 years ago

I am facing the same problem that was Addressed in Question Q362164. I have handled ChartControl.CustomDrawSeries in a ViewController to set the LegendText parameter according to the processed series. but i am facing problem in it. I have created a sample project and also attached a image to demonstrate the desire View. I have also pointed the area in a code where i am facing problem. Please help to perform this

Answers approved by DevExpress Support

created 12 years ago (modified 7 years ago)

Hello,
I have corrected your sample project:

C#
using System; using System.Text; using DevExpress.XtraCharts; using DevExpress.ExpressApp; using System.Collections.Generic; using DevExpress.ExpressApp.Utils; using DevExpress.ExpressApp.Chart.Web; using DevExpressSamplePorblem.Module.DomainComponents; namespace DevExpressSamplePorblem.Module.Web.Controllers { public partial class ChartController : ViewController { EnumDescriptor opportunitySourceEnumDescriptor; ASPxChartListEditor chartListEditor; public ChartController() { InitializeComponent(); RegisterActions(components); //TargetViewId = "ILead_ListView_Chart"; TargetViewId = "ICRMOpportunity_ChartView"; } protected override void OnViewControlsCreated() { base.OnViewControlsCreated(); chartListEditor = ((ListView)View).Editor as ASPxChartListEditor; if(chartListEditor != null) { opportunitySourceEnumDescriptor = new EnumDescriptor(typeof(OpportunitySource)); chartListEditor.ChartControl.CustomDrawSeries += new CustomDrawSeriesEventHandler(ChartControl_CustomDrawSeries); //chartListEditor.ChartControl.CustomDrawSeriesPoint += new CustomDrawSeriesPointEventHandler(ChartControl_CustomDrawSeriesPoint); chartListEditor.ChartControl.CustomDrawAxisLabel += new CustomDrawAxisLabelEventHandler(ChartControl_CustomDrawAxisLabel); } } protected override void OnDeactivated() { if(chartListEditor != null && chartListEditor.ChartControl != null) { chartListEditor.ChartControl.CustomDrawSeries -= new CustomDrawSeriesEventHandler(ChartControl_CustomDrawSeries); //chartListEditor.ChartControl.CustomDrawSeriesPoint -= new CustomDrawSeriesPointEventHandler(ChartControl_CustomDrawSeriesPoint); chartListEditor.ChartControl.CustomDrawAxisLabel -= new CustomDrawAxisLabelEventHandler(ChartControl_CustomDrawAxisLabel); } base.OnDeactivated(); } void ChartControl_CustomDrawAxisLabel(object sender, CustomDrawAxisLabelEventArgs e) { string caption = opportunitySourceEnumDescriptor.GetCaption(Convert.ToInt32(e.Item.AxisValueInternal)); e.Item.Text = caption; } //void ChartControl_CustomDrawSeriesPoint(object sender, CustomDrawSeriesPointEventArgs e) { //} void ChartControl_CustomDrawSeries(object sender, CustomDrawSeriesEventArgs e) { StringBuilder sb = new StringBuilder(opportunitySourceEnumDescriptor.Values.Length); for(int i = 0; i < opportunitySourceEnumDescriptor.Values.Length; i++) { sb.AppendLine(opportunitySourceEnumDescriptor.GetCaption(i)); } e.LegendText = sb.ToString(); } } }

If you are using a pie chart, you can handle the WebChartControl > CustomDrawSeriesPoint  event:

C#
using System; using System.Collections.Generic; using System.Linq; using System.Text; using ChartView.Module.BusinessObjects; using DevExpress.Data.Filtering; using DevExpress.ExpressApp; using DevExpress.ExpressApp.Actions; using DevExpress.ExpressApp.Chart.Web; using DevExpress.ExpressApp.Editors; using DevExpress.ExpressApp.Layout; using DevExpress.ExpressApp.Model.NodeGenerators; using DevExpress.ExpressApp.SystemModule; using DevExpress.ExpressApp.Templates; using DevExpress.ExpressApp.Utils; using DevExpress.Persistent.Base; using DevExpress.Persistent.Validation; using DevExpress.XtraCharts; namespace ChartView.Module.Web.Controllers { // For more typical usage scenarios, be sure to check out http://documentation.devexpress.com/#Xaf/clsDevExpressExpressAppViewControllertopic. public partial class ChartController : ViewController<ListView> { EnumDescriptor statusEnumDescriptor; Type enumType = typeof(DomainObject1.Status); ASPxChartListEditor aspxChartListEditor; public ChartController() { InitializeComponent(); TargetObjectType = typeof(DomainObject1); } protected override void OnActivated() { base.OnActivated(); statusEnumDescriptor = new EnumDescriptor(enumType); } protected override void OnViewControlsCreated() { base.OnViewControlsCreated(); // Access and customize the target View control. aspxChartListEditor = ((ListView)View).Editor as ASPxChartListEditor; if(aspxChartListEditor != null) { aspxChartListEditor.ChartControl.CustomDrawSeriesPoint += ChartControl_CustomDrawSeriesPoint; } } private void ChartControl_CustomDrawSeriesPoint(object sender, CustomDrawSeriesPointEventArgs e) { string caption = statusEnumDescriptor.GetCaption(Enum.Parse(enumType, e.SeriesPoint.Argument)); e.LabelText = caption; e.LegendText = caption; } protected override void OnDeactivated() { // Unsubscribe from previously subscribed events and release other references and resources. if(aspxChartListEditor != null && aspxChartListEditor.ChartControl != null) { aspxChartListEditor.ChartControl.CustomDrawSeriesPoint -= ChartControl_CustomDrawSeriesPoint; } base.OnDeactivated(); } } }

I hope it will meet your needs.
P.S.
For faster replies to questions related to customizing individual controls rather than to XAF, please contact an appropriate product team (e.g., XtraCharts).

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.