1. 程式人生 > >ASP.NET MSChart 入門 Series 詳解 (四)

ASP.NET MSChart 入門 Series 詳解 (四)

///<summary>

///定義Series適用大部分圖形樣式------不適合樣式有、餅圖、空心餅圖等

///</summary>

///<param name="name"></param>

///<param name="stype"></param>

///<param name="XValueMember"></param>

///<param name="YValueMembers"></param>

///<returns></returns>

public static Series SetSeriesStyle(string

name, SeriesChartType stype, string XValueMember, string YValueMembers)

{

Series series = new Series(name);

string PointWidth = "0.8";

series.XValueMember = XValueMember;

series.YValueMembers = name;

series.ToolTip = "#VAL";

series["DrawingStyle"] = "Cylinder";

// series.MarkerStyle = MarkerStyle.Circle;

點標記

series["PointWidth"] = PointWidth;

series.ChartType = stype;

//series.ChartArea = name;

//series.Legend = name;

return series;

}

 series["PointWidth"] = PointWidth; 繪製的寬度

 series.XValueMember = XValueMember; 繫結資料的X軸顯示資料的 對應列名

 series.YValueMembers = name;   繫結資料的Y軸顯示資料的 對應列名

 series["DrawingStyle"] = "Cylinder"

; 繪製圖形的 樣式

 series.ToolTip  = "#VAL"; 滑鼠移到上去的顯示 的Y軸 對應的資料      

 series.ChartType = stype; 顯示圖形的樣式 此型別為列舉型別 下面 有我翻譯的一點東東 很多不準 俺是英盲

this.DropDownList1.Items.Add(new ListItem("區域填充", "13"));

this.DropDownList1.Items.Add(new ListItem("條形", "7"));

this.DropDownList1.Items.Add(new ListItem("盒型圖", "28"));

this.DropDownList1.Items.Add(new ListItem("氣泡", "2"));

this.DropDownList1.Items.Add(new ListItem("燭臺", "20"));

this.DropDownList1.Items.Add(new ListItem("豎形", "10"));

this.DropDownList1.Items.Add(new ListItem("空心圓", "18"));

this.DropDownList1.Items.Add(new ListItem("誤差條形圖", "27"));

this.DropDownList1.Items.Add(new ListItem("FastLine", "6"));

this.DropDownList1.Items.Add(new ListItem("FastPoint", "1"));

this.DropDownList1.Items.Add(new ListItem("漏斗形", "33"));

this.DropDownList1.Items.Add(new ListItem("鉤形圖", "31"));

this.DropDownList1.Items.Add(new ListItem("線形", "3"));

this.DropDownList1.Items.Add(new ListItem("餅圖", "17"));

this.DropDownList1.Items.Add(new ListItem("點形", "0"));

this.DropDownList1.Items.Add(new ListItem("點和圖", "32"));

this.DropDownList1.Items.Add(new ListItem("極地圖表", "26"));

this.DropDownList1.Items.Add(new ListItem("金字塔形", "34"));

this.DropDownList1.Items.Add(new ListItem("雷達形", "25"));

this.DropDownList1.Items.Add(new ListItem("變化幅度", "21"));

this.DropDownList1.Items.Add(new ListItem("橫著", "23"));

this.DropDownList1.Items.Add(new ListItem("豎著條形", "24"));

this.DropDownList1.Items.Add(new ListItem("Renko", "29"));

this.DropDownList1.Items.Add(new ListItem("曲線", "4"));

this.DropDownList1.Items.Add(new ListItem("曲線區域填充", "14"));

this.DropDownList1.Items.Add(new ListItem("曲線區域填充1", "22"));

this.DropDownList1.Items.Add(new ListItem("累加折線區域填充", "15"));

this.DropDownList1.Items.Add(new ListItem("累加折線區域填充百分比", "16"));

this.DropDownList1.Items.Add(new ListItem("累加條形", "8"));

this.DropDownList1.Items.Add(new ListItem("累加條形百分比", "9"));

this.DropDownList1.Items.Add(new ListItem("累加列", "11"));

this.DropDownList1.Items.Add(new ListItem("累加列百分比", "12"));

this.DropDownList1.Items.Add(new ListItem("T行線", "5"));

this.DropDownList1.Items.Add(new ListItem("股票圖形", "19"));

this.DropDownList1.Items.Add(new ListItem("ThreeLineBreak", "30"));

下面是微軟的列舉,簡單的說下 new ListItem("累加列", "11")  後面的11 對應的就是   StackedColumn = 11,

// 摘要:

//Specifies a chart type for a System.Web.UI.DataVisualization.Charting.Series.

public enum SeriesChartType

{

// 摘要:

//Point chart type.

Point = 0,

//

// 摘要:

//FastPoint chart type.

FastPoint = 1,

//

// 摘要:

//Bubble chart type.

Bubble = 2,

//

// 摘要:

//Line chart type.

Line = 3,

//

// 摘要:

//Spline chart type.

Spline = 4,

//

// 摘要:

//StepLine chart type.

StepLine = 5,

//

// 摘要:

//FastLine chart type.

FastLine = 6,

//

// 摘要:

//Bar chart type.

Bar = 7,

//

// 摘要:

//Stacked bar chart type.

StackedBar = 8,

//

// 摘要:

//Hundred-percent stacked bar chart type.

StackedBar100 = 9,

//

// 摘要:

//Column chart type.

Column = 10,

//

// 摘要:

//Stacked column chart type.

StackedColumn = 11,

//

// 摘要:

//Hundred-percent stacked column chart type.

StackedColumn100 = 12,

//

// 摘要:

//Area chart type.

Area = 13,

//

// 摘要:

//Spline area chart type.

SplineArea = 14,

//

// 摘要:

//Stacked area chart type.

StackedArea = 15,

//

// 摘要:

//Hundred-percent stacked area chart type.

StackedArea100 = 16,

//

// 摘要:

//Pie chart type.

Pie = 17,

//

// 摘要:

//Doughnut chart type.

Doughnut = 18,

//

// 摘要:

//Stock chart type.

Stock = 19,

//

// 摘要:

//Candlestick chart type.

Candlestick = 20,

//

// 摘要:

//Range chart type.

Range = 21,

//

// 摘要:

//Spline range chart type.

SplineRange = 22,

//

// 摘要:

//RangeBar chart type.

RangeBar = 23,

//

// 摘要:

//Range column chart type.

RangeColumn = 24,

//

// 摘要:

//Radar chart type.

Radar = 25,

//

// 摘要:

//Polar chart type.

Polar = 26,

//

// 摘要:

//Error bar chart type.

ErrorBar = 27,

//

// 摘要:

//Box plot chart type.

BoxPlot = 28,

//

// 摘要:

//Renko chart type.

Renko = 29,

//

// 摘要:

//ThreeLineBreak chart type.

ThreeLineBreak = 30,

//

// 摘要:

//Kagi chart type.

Kagi = 31,

//

// 摘要:

//PointAndFigure chart type.

PointAndFigure = 32,

//

// 摘要:

//Funnel chart type.

Funnel = 33,

//

// 摘要:

//Pyramid chart type.

Pyramid = 34,

}

  重點介紹的是餅圖 餅圖 有些特殊

///<summary>

///適合樣式有 、餅圖、空心餅圖

///</summary>

///<param name="name"></param>

///<param name="stype"></param>

///<param name="xValues"></param>

///<param name="yValues"></param>

///<returns></returns>

public static Series SetSeriesStyle(string name, SeriesChartType stype, string[] xValues, double[] yValues)

{

Series series = new Series(name);

series.ChartType = stype;

// series["PointWidth"] = PointWidth;

series.Points.DataBindXY(xValues, yValues);

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

{

series.Points[i].LegendText = xValues[i] + "#VAL";

//series.Points[i].Label = xValues[i] + "#PERCENT{P1}";

//series.Points[i].Label = "#PERCENT{P1}";

}

series.ToolTip = "#VALX#PERCENT{P1}";