Xaf: modifying chart at runtime

Source: Internet
Author: User

For example, modify the chart in the Code and save the modification without calling Wizard.

You can add/delete/hide series and change the chart style.

Using system; using system. text; using system. io; using devexpress. expressapp. chart. win; using devexpress. expressapp. chart; using devexpress. xtracharts; namespace dynamicchartsolution. module. win {public class chartmanagerwin {private chartcontrol; private imodelchartlistview chartmodel; private seriesbuilder; // <summary> // method for creating chartmanagerwin in viewcontroller: // chartcontrol C C = (listview) view ). editor as chartlisteditor ). chartcontrol // imodelchartlistview M = (imodelchartlistview) view. model // new chartmanagerwin (CC, m) /// </Summary> /// <Param name = "control"> </param> /// <Param name = "model"> </param> Public chartmanagerwin (chartcontrol control, imodelchartlistview model) {This. chartcontrol = control; this. chartmodel = model;} // <summary> // use seriesbuilder to create a se Ries /// </Summary> /// <returns> </returns> Public seriesbuilder getseriesbuilder () {return builder = new seriesbuilder ();} public seriesbuilder getseriesbuilder (string seriesname, devexpress. xtracharts. viewtype) {return builder = new seriesbuilder (seriesname, viewtype );} /// <summary> /// Save the chart changes to the Model /// </Summary> /// <Param name = "model"> </param> Public void savechanges () {memory Stream MS = new memorystream (); chartcontrol. savetostream (MS); chartmodel. chartsettings. settings = encoding. utf8.getstring (Ms. toarray ());} /// <summary> /// change the chart display style /// </Summary> /// <Param name = "style"> </param> Public void changestyle (devexpress. xtracharts. viewtype style) {foreach (series S in chartcontrol. series) {S. changeview (style) ;}savechanges () ;}// note that if the added series and current chart styles are different, they are not displayed. Public void addseries (Params series [] series) {chartcontrol. series. addrange (series); savechanges ();} public void removeseries (string seriesname) {If (chartcontrol. series [seriesname]! = NULL) chartcontrol. series. remove (chartcontrol. series [seriesname]); savechanges ();} public void setvisibility (string seriesname, bool visible) {chartcontrol. series [seriesname]. visible = visible;} public class seriesbuilder {private Series; Public series {get {return series;} public seriesbuilder () {series = new series ();} public seriesbuilder (string seriesname, devexpress. xtracharts. viewtype) {series = new series (seriesname, viewtype);} public string name {set {series. name = value ;}} public devexpress. xtracharts. viewtype {set {series. changeview (value) ;}} public object datasource {set {series. datasource = value ;}} Public String argumentdatamember {set {series. argumentdatamember = value ;}} public devexpress. xtracharts. scaletype argumentscaletype {set {series. argumentscaletype = value ;}} public devexpress. xtracharts. scaletype valuescaletype {set {series. valuescaletype = value ;}} Public String valuedatamember {set {series. valuedatamembers. addrange (value) ;}} Public String summaryfunction {set {series. summaryfunction = value ;}} public void adddatafilter (string columnname, string columntypename, datafiltercondition condition, object Value) {series. datafilters. add (columnname, columntypename, condition, value );}}}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.