In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the knowledge of "how to use asp.net Microsoft Chart Control". In the operation of practical cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The copy code is as follows:
The copy code is as follows:
MsChart Chart Control
The copy code is as follows:
Using System
Using System.Collections.Generic
Using System.Linq
Using System.Web
Using System.Data
Using System.Web.UI
Using System.Web.UI.WebControls
/ / add
Using System.Drawing
Public partial class chart: System.Web.UI.Page
{
Protected void Page_Load (object sender, EventArgs e)
{
DataTable dt = CreatData ()
GetStyle1 (dt)
GetStyle2 (dt)
GetStyle3 (dt)
GetStyle4 (dt)
}
Protected void GetStyle1 (DataTable dt)
{
# region line chart
Chart1.DataSource = dt;// bind data
Chart1.Series ["Series1"] .ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Line;// sets the chart type
Chart1.Series [0] .XValueMember = "Country"; / / X axis data member column
Chart1.Series [0] .YValueMembers = "Score"; / / Y axis data member column
Chart1.ChartAreas ["ChartArea1"] .AxisX.Title = "country"; / / X axis title
Chart1.ChartAreas ["ChartArea1"] .AxisX.TitleAlignment = StringAlignment.Far;// sets the name of the Y-axis title in a position far away
Chart1.ChartAreas ["ChartArea1"] .AxisY.Title = "Gold"; / / X axis title
Chart1.ChartAreas ["ChartArea1"] .AxisY.TitleAlignment = StringAlignment.Far;// sets the name of the Y-axis title in a position far away
Chart1.ChartAreas ["ChartArea1"] .AxisX.Interval = 1 the distance between the X-axis data of a racket.
Chart1.ChartAreas ["ChartArea1"] .AxisX.MajorGrid.Enabled = false;// does not show vertical split lines
Chart1.Series [0] .IsValueShownAsLabel = true;// display coordinate values
# endregion
}
Protected void GetStyle2 (DataTable dt)
{
# region Spline (smooth Curve)
Chart2.DataSource = dt;// bind data
Chart2.Series ["Series1"] .ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Spline;// sets the chart type
Chart2.Series ["Series1"] .MarkerStyle = System.Web.UI.DataVisualization.Charting.MarkerStyle.Cross;// set the style of the point, cross
Chart2.Series [0] .XValueMember = "Country"; / / X axis data member column
Chart2.Series [0] .YValueMembers = "Score"; / / Y axis data member column
Chart2.ChartAreas ["ChartArea1"] .AxisX.Title = "country"; / / X axis title
Chart2.ChartAreas ["ChartArea1"] .AxisX.TitleAlignment = StringAlignment.Far;// sets the name of the Y-axis title in a position far away
Chart2.ChartAreas ["ChartArea1"] .AxisY.Title = "Gold"; / / X axis title
Chart2.ChartAreas ["ChartArea1"] .AxisY.TitleAlignment = StringAlignment.Far;// sets the name of the Y-axis title in a position far away
Chart2.ChartAreas ["ChartArea1"] .AxisX.Interval = 1 the distance between the X-axis data of a racket.
Chart2.ChartAreas ["ChartArea1"] .AxisX.MajorGrid.Enabled = false;// does not show vertical split lines
Chart2.Series [0] .IsValueShownAsLabel = true;// display coordinate values
# endregion
}
Protected void GetStyle3 (DataTable dt)
{
# region bar chart
Chart3.DataSource = dt;// bind data
Chart3.Series ["Series1"] .ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Bar;// sets the chart type
Chart3.Series [0] .XValueMember = "Country"; / / X axis data member column
Chart3.Series [0] .YValueMembers = "Score"; / / Y axis data member column
Chart3.ChartAreas ["ChartArea1"] .AxisX.Title = "country"; / / X axis title
Chart3.ChartAreas ["ChartArea1"] .AxisX.TitleAlignment = StringAlignment.Far;// sets the name of the Y-axis title in a position far away
Chart3.ChartAreas ["ChartArea1"] .AxisY.Title = "Gold"; / / X axis title
Chart3.ChartAreas ["ChartArea1"] .AxisY.TitleAlignment = StringAlignment.Far;// sets the name of the Y-axis title in a position far away
Chart3.ChartAreas ["ChartArea1"] .AxisX.Interval = 1 the distance between the X-axis data of a racket.
Chart3.ChartAreas ["ChartArea1"] .AxisX.MajorGrid.Enabled = false;// does not show vertical split lines
Chart3.Series [0] .IsValueShownAsLabel = true;// display coordinate values
# endregion
}
Protected void GetStyle4 (DataTable dt)
{
# region pie chart
Chart4.DataSource = dt;// bind data
Chart4.Series ["Series1"] .ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Pie;// sets the chart type
Chart4.Series [0] .XValueMember = "Country"; / / X axis data member column
Chart4.Series [0] .YValueMembers = "Score"; / / Y axis data member column
Chart4.Series [0] .LegendMapAreaAttributes = "Country"; / / Show country
Chart4.Series [0] .IsValueShownAsLabel = true;// display coordinate values
# endregion
}
/ / /
/ / create a two-dimensional data table
/ / /
/ / data table of type Datatable
Protected DataTable CreatData ()
{
DataTable dt = new DataTable ()
Dt.Columns.Add ("Country", System.Type.GetType ("System.String"))
Dt.Columns.Add ("Score", System.Type.GetType ("System.String"))
String [] n = new string [] {"China", "US", "Russia", "UK"}
String [] c = new string [] {"85", "80", "50", "35"}
For (int I = 0; I
< 4; i++) { DataRow dr = dt.NewRow(); dr["Country"] = n[i]; dr["Score"] = c[i]; dt.Rows.Add(dr); } return dt; } }This is the end of "how to use asp.net Microsoft Chart Control". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.