DevExpress Chartcontrol Implementation Timeline Instance Z

Source: Internet
Author: User

Using system;using system.data;using system.windows.forms;using devexpress.xtracharts;            namespace devexpresschart{public partial class Windatetime:form {public Windatetime () {        InitializeComponent ();        } private void Windatetime_load (object sender, EventArgs e) {Builderdevchart ();            } Private DataTable Createchartdata () {DataTable table = new DataTable ("Table1"); Table.            Columns.Add ("Date", typeof (DateTime)); Table.            Columns.Add ("Value", typeof (Int32)); Table.            Rows.Add (new object[] {new DateTime (2014, 5, 21), 10}); Table.            Rows.Add (new object[] {new DateTime (2014, 6, 22), 20}); Table.            Rows.Add (new object[] {new DateTime (2014, 7, 23), 40}); Table.            Rows.Add (new object[] {new DateTime (2014, 8, 24), 20}); Table.            Rows.Add (new object[] {new DateTime (2014, 9, 25), 30});        return table; } Private VOID Builderdevchart () {Series _lineseries = new Series ("Profit", Viewtype.line);            _lineseries.argumentscaletype = Scaletype.datetime;            _lineseries.argumentdatamember = "Date";            _lineseries.valuedatamembers[0] = "Value";            _lineseries.datasource = Createchartdata ();              CHARTCONTROL1.SERIES.ADD (_lineseries);            CHARTCONTROL1.SETTIMEAXISX (Datetimemeasurementunit.month, Datetimemeasurementunit.month, "Yyyy-MM"); ---------------------------------------------------------------//_lineseries.valuescaletype = Scaletype.da            Tetime;            _lineseries.argumentdatamember = "Value";            _lineseries.valuedatamembers[0] = "Date";            _lineseries.datasource = Createchartdata ();              CHARTCONTROL1.SERIES.ADD (_lineseries);            Xydiagram _diagram = (xydiagram) Chartcontrol1.diagram; _diagram.      Axisy.datetimemeasureunit = Datetimemeasurementunit.month;      _diagram.            Axisy.datetimegridalignment = Datetimemeasurementunit.month; _diagram.            AxisY.DateTimeOptions.Format = Datetimeformat.custom; _diagram.        AxisY.DateTimeOptions.FormatString = "MMMM";  }    }}

 

Using devexpress.utils;using devexpress.xtracharts; namespace devexpresschart{public static class Chartutils {//<summary>///Increase data filtering// </summary>//<param name= "seriesbase" >Series</param>//<param name= "ColumnName" > Column name </param>//<param name= "value" > column name corresponding filter value </param>//<param name= "Datafiltercondi tion ">datafiltercondition enumeration </param> public static void Adddatafilter (this seriesbase series, string column Name, Object value, Datafiltercondition datafiltercondition) {series. Datafilters.add (New Datafilter (ColumnName, value. GetType ().        FullName, datafiltercondition, value)); }///<summary>//Set X-axis lable angle///</summary>//<param name= "chart" >cha rtcontrol</param>//<param name= "angle" > Angle </param> public static void Setxlableangle (thi S Chartcontrol Chart, int angle) {Xydiagram _xydiagram = (xydiagram) chart.            Diagram;        if (_xydiagram! = null) _xydiagram.axisx.label.angle = Angle; }///<summary>//Set y-axis lable angle///</summary>//<param name= "chart" >char  tcontrol</param>//<param name= "angle" > Angle </param> public static void Setylableangle (this Chartcontrol chart, int angle) {Xydiagram _xydiagram = (xydiagram) chart.            Diagram;        _xydiagram.axisy.label.angle = Angle; }///<summary>//Set Coloreach///</summary>/<param name= "chart" >chart control</param>//<param name= "Coloreach" > whether set to coloreach</param> public static void SetC Oloreach (this series series, bool Coloreach) {seriesviewcoloreachsupportbase Coloreachview = (seriesvie Wcoloreachsupportbase) series.            View; if (coloreAchview = null) {Coloreachview.coloreach = Coloreach; }}///<summary>///Set whether to display Crosshair///</summary>//<param name= "chart" & Gt chartcontrol</param>//<param name= "crosshair" > whether to show crosshair </param> public static void SETCR Osshair (this Chartcontrol chart, bool crosshair) {chart. crosshairenabled = crosshair?            DefaultBoolean.True:DefaultBoolean.False; Chart.            Crosshairoptions.showargumentlabels = crosshair; Chart.            Crosshairoptions.showargumentline = crosshair; Chart.            Crosshairoptions.showvaluelabels = crosshair; Chart.        Crosshairoptions.showvalueline = crosshair; }///<summary>//new title text for Chartcontrol///</summary>//<param name= "Char T ">ChartControl</param>//<param name=" title ">title text </param> public static void AddT Itle (This Chartcontrol chart, string title) {ChartTitle _title = new ChartTitle (); _title.            Text = title; Chart.        Titles.add (_title); }///<summary>///The PIE series is set as a percentage showing//</summary>//<param name= "series" ; series</param> public static void Setpiepercentage (the This series series) {if (series. View is Pieseriesview) {(piepointoptions) series. pointoptions).                Percentoptions.valueaspercent = true; ((piepointoptions) series. pointoptions).                Valuenumericoptions.format = numericformat.percent; ((piepointoptions) series. pointoptions).            valuenumericoptions.precision = 0; }}///<summary>///Format the x-axis as a timeline///</summary>//<param name= "chart" & Gt chartcontrol</param>//<param name= "datetimemeasureunit" >x axis scale units </param>///<param NA Me= "dateTimegridalignment ">x axis scale spacing units </param> public static void Settimeaxisx (this chartcontrol chart, Datetimemeas Urementunit Datetimemeasureunit, Datetimemeasurementunit datetimegridalignment) {Xydiagram _diagram = ( Xydiagram) chart.            Diagram; if (_diagram! = null) {_diagram. Axisx.datetimemeasureunit = datetimemeasurementunit.month;//x axis scale unit _diagram.        axisx.datetimegridalignment = datetimemeasurementunit.month;//x axis scale Spacing}}//<summary> Format the x-axis as a timeline//</summary>//<param name= "chart" >ChartControl</param>/// Lt;param name= "datetimemeasureunit" >x axis scale units </param>///<param name= "datetimegridalignment" >x axis scale spacing single Bit </param>//<param name= "formatString" > Time format;eg:yyyy-mm</param> public static void Settim EAXISX (This Chartcontrol chart, Datetimemeasurementunit Datetimemeasureunit, DatetiMemeasurementunit datetimegridalignment, String formatString) {Xydiagram _diagram = (xydiagram) chart.            Diagram; if (_diagram! = null) {_diagram. Axisx.datetimemeasureunit = datetimemeasurementunit.month;//x axis scale unit _diagram. axisx.datetimegridalignment = datetimemeasurementunit.month;//x axis scale spacing _diagram.                AxisX.DateTimeOptions.Format = Datetimeformat.custom; _diagram.            AxisX.DateTimeOptions.FormatString = FormatString;  }        }    }}

The effect is as follows:

What are the performance optimization methods for DevExpress Chartcontrol when loading large data volumes?

For chart optimization, there are several ways to solve this:

1. Turn off unwanted visual elements (such as linemarkers, labels, etc.): Series.View.LineMarkerOptions.Visible =false.

2. Turn off the scrolling and zooming function of the chart and adjust the range manually, which will greatly reduce the number of calculations required.

3. Set the Chartcontrol.refreshdataonrepaint property to False

4. Set the Chartcontrol.cachetomemory property to true to provide graph performance and memory consumption through the cache.

5. Set the Chartcontrol.runtimehittesting property to False. This disables focus checking and testing, and provides the chart redraw speed.

____

Http://www.devexpresscn.com/DevExpress-Resources/Documentation-17.html

DevExpress Chartcontrol Implementation Timeline Instance Z

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.