The practice of Webchartcontrol control histogram in devexpress (data is called stored procedure)

Source: Internet
Author: User

Foreground control code: Webchartcontrol Control:

<%--Monthly Purchase Volume statistics--%>
<dxchartsui:webchartcontrol id= "WebChartControl1" runat= "Server" width= "700px" height= "400px" cssclass= "Chartsui "></dxchartsui:WebChartControl>

The background code (CS) can be written in the custom method:

?//The first bar in a bar chart

Series Series1 = new series ("Amount", Viewtype.bar);

Series1.datasource = DT;

Series1.argumentscaletype = scaletype.qualitative;

Which field to display

Series1.argumentdatamember = "Ymonth";

Series1.valuescaletype = scaletype.numerical;

Column Value field in a bar chart

Series1.ValueDataMembers.AddRange (new string[] {"SUM (Amoney)"});

The second column in a bar chart

Series Series2 = new series ("Purchase Quantity", Viewtype.bar);

Series2.datasource = DT;

Series2.argumentscaletype = scaletype.qualitative;

Series2.argumentdatamember = "Ymonth";

Series2.valuescaletype = scaletype.numerical;

Series2.ValueDataMembers.AddRange (new string[] {"SUM (buynum)"});

Chartservices.setcharttitle (this. WebChartControl1, True, "Purchase volume chart Statistics", True, 2, Stringalignment.center, Charttitledockstyle.top, True, new Font ("Arial", page, Fon    Tstyle.bold), color.red, 10); Show Chart Title

for (int i = 0; i < dt. Rows.Count; i++)

{

String tt = dt. rows[i]["Ymonth"]. ToString ();

Seriespoint point1 = new Seriespoint (dt. rows[i]["Ymonth"]. ToString (), convert.todouble (dt. rows[i]["SUM (Amoney)"]. ToString ()));

Seriespoint Point2 = new Seriespoint (dt. rows[i]["Ymonth"]. ToString (), convert.todouble (dt. rows[i]["sum (buynum)"]. ToString ()));

SERIES1.POINTS.ADD (POINT1);

SERIES2.POINTS.ADD (Point2);

}

WEBCHARTCONTROL1.SERIES.ADD (SERIES1);

WEBCHARTCONTROL1.SERIES.ADD (Series2);

The Chartservices class file code (used to set the title, color, value, and so on in the Webchartcontrol)-usually has its own property on the front webchartcontrol, and sometimes it can be referenced when it is not.

Class Chartservices

{

///

Draw a graphic

///

Chart control

Series name

Type

Data source

///

///

public static void Drawchart (DevExpress.XtraCharts.Web.WebChartControl control, String seriesname, ViewType type, DataTable DT, String column1, String column2)

{

Series Series = new series (seriesname, type);

DataTable table = dt;

Seriespoint point = null;

for (int i = 0; i < table. Rows.Count; i++)

{

Point = new seriespoint (table. ROWS[I][COLUMN1]. ToString (), convert.todouble (table. ROWS[I][COLUMN2]. ToString ()));

Series. Points.Add (point);

}

Control. Series.add (series);

Special handling for pie charts

if (type = = Viewtype.pie)

{

Set display mode (Argument: Show legend Description, Argumentandvalues: Show legend Contents and data)

Series. Label.PointOptions.PointView = pointview.argumentandvalues;

Set the data display form (Percent: Percent, Currency: currency type, add ¥,scientific before data: scientific notation)

Series. Label.PointOptions.ValueNumericOptions.Format = numericformat.percent;

Whether the data retains decimals (0: No decimal places, 1 retains one decimal place, and 2 retains two decimal places)

Series. Label.PointOptions.ValueNumericOptions.Precision = 0;

Data can only be default and none when displayed as a percentage

((Pieserieslabel) series. Label). Resolveoverlappingmode = Resolveoverlappingmode.default;

}

}

///

Set Chart title

///

Chart control

Whether the caption is visible

Title text

Whether to break line

Maximum allowable number of rows

Alignment

Position

Whether to allow skin to be set

Font

Text color

Font indent value

public static void Setcharttitle (DevExpress.XtraCharts.Web.WebChartControl control, bool isVisible, String text, BOOL Iswordwrop, int maxlinecount, stringalignment alignment, Charttitledockstyle dock, bool isantialiasing, font font, Color t Extcolor, int indent)

{

Set Title

ChartTitle title = new ChartTitle ();

Title. Visible = isVisible;

Display text

Title. Text = text;

Whether line wrapping is allowed

Title. WordWrap = Iswordwrop;

Maximum allowable number of rows

Title. Maxlinecount = Maxlinecount;

Alignment

Title. Alignment = Alignment;

Position

Title. Dock = dock;

Whether to allow skin to be set

Title. antialiasing = isantialiasing;

Font

Title. Font = font;

Font Color

Title. TextColor = TextColor;

Indent value

Title. Indent = Indent;

Control. Titles.add (title);

}

///

Add a title to the x-axis

///

Graphical controls

Whether the caption is visible

Alignment

Title Display text

Title Font Color

Whether to allow skin to be set

Font

public static void Setaxisx (DevExpress.XtraCharts.Web.WebChartControl control, bool isVisible, stringalignment Aligment, string text, color color, bool isantialiasing, font font)

{

Xydiagram Xydiagram = (xydiagram) control. Diagram;

Xydiagram. AxisX.Title.Visible = isVisible;

Xydiagram. AxisX.Title.Alignment = aligment;

Xydiagram. AxisX.Title.Text = Text;

Xydiagram. AxisX.Title.TextColor = color;

Xydiagram. AxisX.Title.Antialiasing = isantialiasing;

Xydiagram. AxisX.Title.Font = Font;

}

///

Add a title to the x-axis

///

Graphical controls

Whether the caption is visible

Alignment

Title Display text

Title Font Color

Whether to allow skin to be set

Font

public static void Setaxisy (DevExpress.XtraCharts.Web.WebChartControl control, bool isVisible, stringalignment Aligment, string text, color color, bool isantialiasing, font font)

{

Xydiagram Xydiagram = (xydiagram) control. Diagram;

Xydiagram. AxisY.Title.Visible = isVisible;

Xydiagram. AxisY.Title.Alignment = aligment;

Xydiagram. AxisY.Title.Text = Text;

Xydiagram. AxisY.Title.TextColor = color;

Xydiagram. AxisY.Title.Antialiasing = isantialiasing;

Xydiagram. AxisY.Title.Font = Font;

}

}

The practice of Webchartcontrol control histogram in devexpress (data is called stored procedure)

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.