[DevExpress] ChartControl bar chart example, controlchart

Source: Internet
Author: User

[DevExpress] ChartControl bar chart example, controlchart

Key code:

Using System; using System. data; using System. windows. forms; using CSharpUtilHelpV2; using DevExpress. xtraCharts; namespace DevExpressChart {public partial class winProduct: Form {public winProduct () {InitializeComponent ();} static readonly string AccessFullPath = string. format (@ "{0} \ Northwind. MDB ", AppDomain. currentDomain. baseDirectory); static DataTable ProductList = null; AccessUtilsV2 AccessHelp Er = null; private void winChat_Load (object sender, EventArgs e) {AccessHelper = new AccessUtilsV2 (AccessFullPath); ProductList = AccessHelper. executeDataTable ("select * from Products", null); BuilderDevChart ();} private void BuilderDevChart () {if (ProductList! = Null) {Series _ barSeries = new Series ("test", ViewType. bar); _ barSeries. argumentDataMember = "ProductName"; // X axis _ barSeries. valueDataMembers [0] = "UnitPrice"; // y axis _ barSeries. dataSource = ProductList; _ barSeries. addDataFilter ("CategoryID", 4, DataFilterCondition. equal); _ barSeries. setColorEach (true); chartControl1.Series. add (_ barSeries); _ barSeries. legendPointOptions. pointView = PointView. argumentAndValues; // chartControl1.SeriesDataMember = "UnitPrice"; // chartControl1.SeriesTemplate. valueDataMembers [0] = "UnitPrice"; // chartControl1.SeriesTemplate. argumentDataMember = "ProductName"; // chartControl1.SeriesTemplate. argumentScaleType = ScaleType. qualitative; // chartControl1.SeriesTemplate. addDataFilter ("CategoryID", 4, DataFilterCondition. equal); // chartControl1.SeriesTemplate. legendPointOptions. pointView = PointView. argumentAndValues; chartControl1.SetXLableAngle (-35); chartControl1.SetCrosshair (true); chartControl1.Legend. direction = LegendDirection. leftToRight; chartControl1.Legend. alignmentHorizontal = LegendAlignmentHorizontal. center; chartControl1.Legend. alignmentVertical = LegendAlignmentVertical. bottomOutside; chartControl1.DataSource = ProductList; chartControl1.AddTitle ("Product List ");//--------------------------}}}}

Bytes ------------------------------------------------------------------------------------------------------

Using DevExpress. utils; using DevExpress. xtraCharts; namespace DevExpressChart {public static class ChartUtils {// <summary> // Add data filtering /// </summary> /// <param name = "SeriesBase"> Series </param> /// <param name = "columnName"> column name </param> /// filter value corresponding to <param name = "value"> column name </param> /// <param name = "dataFilterCondition"> DataFilterCondition enumeration </param> public static void AddDataFilter (this SeriesBase serie S, string columnName, object value, DataFilterCondition dataFilterCondition) {series. dataFilters. add (new DataFilter (columnName, value. getType (). fullName, dataFilterCondition, value ));} /// <summary> /// set the Lable angle on the X axis // </summary> /// <param name = "chart"> ChartControl </param> /// <param name = "angle"> angle </param> public static void SetXLableAngle (this ChartControl chart, int angle) {xydi1__ xyDia Gram = (xydi#) chart. di#; if (_ xydi! = Null) _ xydi.pdf. axisX. label. angle = angle ;} /// <summary> /// set the Lable angle of the Y axis // </summary> /// <param name = "chart"> ChartControl </param> /// <param name = "angle"> angle </param> public static void SetYLableAngle (this ChartControl chart, int angle) {xydi1__ xydi1_= (xydi1_) chart. di#; _ xydi. axisY. label. angle = angle ;}/// <summary> /// set ColorEach /// </summary> /// <param name = "chart "> ChartControl </param> // <param name =" colorEach "> set to ColorEach </param> public static void SetColorEach (this Series series, bool colorEach) {SeriesViewColorEachSupportBase colorEachView = (SeriesViewColorEachSupportBase) series. view; if (colorEachView! = Null) {colorEachView. colorEach = colorEach ;}} /// <summary> /// set whether to display the cross mark. /// </summary> /// <param name = "chart"> ChartControl </param> /// <param name = "crosshair"> whether to display the crosstab chart </param> public static void SetCrosshair (this ChartControl chart, bool crosshair) {chart. crosshairEnabled = crosshair? Defaboolean Boolean. true: defaboolean Boolean. false; chart. crosshairOptions. showArgumentLabels = crosshair; chart. crosshairOptions. showArgumentLine = crosshair; chart. crosshairOptions. showValueLabels = crosshair; chart. crosshairOptions. showValueLine = crosshair ;} /// <summary> /// Add the Title text of ChartControl /// </summary> /// <param name = "chart"> ChartControl </param> /// <param name = "title"> Title text </param> public static void AddTitle (this ChartControl chart, string title) {ChartTitle _ title = new ChartTitle (); _ title. text = title; chart. titles. add (_ title );} /// <summary> // set the pie Series to percent display // </summary> /// <param name = "series"> Series </param> public static void SetPiePercentage (this 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 ;}}}}

Running effect:

Hope this is helpful! Thank you!


(C # Language) How to Use the chartcontrol control of DevExpress to draw a bar chart during interface design? What are the main parameters?

The upstairs is right. Believe it or not. I believe it anyway.

Devexpress chart control ChartControl

No. There are only three display modes:
Category name: Value
Value
Category name

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.