62,268
社区成员
发帖
与我相关
我的任务
分享
SqlConnection myconnection = new SqlConnection("server=WIN- 42QG6PPQFE7\\SQLEXPRESS;database=asd;Integrated Security=true");
SqlCommand mycommand = new SqlCommand("SELECT * FROM locate",myconnection);
myconnection.Open();
SqlDataReader dr = mycommand.ExecuteReader();
int i = 0;
while(dr.Read())
{
//int numbers = int.Parse(dr[0].ToString());
//string names = dr[0].ToString();
//画图
//PieItem segment = myPane.AddPieSlice(numbers, defaultColors[i], Color.White, 45f, 0, names);
//segment.LabelType = PieLabelType.Value;
i++;
}
Response.Write(i);
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZedGraph;
using ZedGraph.Web;
using System.Drawing;
using System.Collections;
using System.Data;
using System.Data.SqlClient;
namespace WebApplication28
{
public partial class year : System.Web.UI.Page
{
//初始化颜色序列
List<Color> defaultColors = new List<Color>();
private void InitDefaultColors()
{
defaultColors.Add(Color.Red);
defaultColors.Add(Color.Green);
defaultColors.Add(Color.Blue);
defaultColors.Add(Color.Yellow);
defaultColors.Add(Color.YellowGreen);
defaultColors.Add(Color.Aqua);
defaultColors.Add(Color.Cyan);
defaultColors.Add(Color.DarkSeaGreen);
defaultColors.Add(Color.Indigo);
}
protected void Page_Load(object sender, EventArgs e)
{
this.ZedGraphWeb1.RenderGraph += new ZedGraph.Web.ZedGraphWebControlEventHandler(ZedGraphWeb1_RenderGraph);
}
protected void ZedGraphWeb1_RenderGraph(ZedGraph.Web.ZedGraphWeb webObject, System.Drawing.Graphics g, ZedGraph.MasterPane masterPane)
{
InitDefaultColors();
GraphPane myPane =masterPane[0];
myPane.Title.Text = "用户所在地理位置统计";
//此处给ZEDGRAPH 背景填充颜色
myPane.Fill = new Fill(Color.Cornsilk);
myPane.Chart.Fill = new Fill(Color.Cornsilk);
myPane.Legend.Position = LegendPos.Right;
//
//连接数据库
//此处需要注意SQLEXPRESS实例前必须加上转义字符"/"否则会报错!
SqlConnection myconnection = new SqlConnection("server=WIN-42QG6PPQFE7\\SQLEXPRESS;database=asd;Integrated Security=true");
SqlCommand mycommand = new SqlCommand("SELECT province FROM locate",myconnection);
myconnection.Open();
SqlDataReader dr = mycommand.ExecuteReader();
int i = 0;
while(dr.Read()==true)
{
int numbers = int.Parse(dr[0].ToString());
string names = dr[0].ToString();
//画图
PieItem segment = myPane.AddPieSlice(numbers, defaultColors[i], Color.White, 45f, 0, names);
segment.LabelType = PieLabelType.Value;
}
dr.Close();
CurveList curves = myPane.CurveList;
masterPane.AxisChange(g);
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZedGraph;
using ZedGraph.Web;
using System.Drawing;
using System.Collections;
using System.Data;
using System.Data.SqlClient;
namespace WebApplication28
{
public partial class year : System.Web.UI.Page
{
//初始化颜色序列
List<Color> defaultColors = new List<Color>();
private void InitDefaultColors()
{
defaultColors.Add(Color.Red);
defaultColors.Add(Color.Green);
defaultColors.Add(Color.Blue);
defaultColors.Add(Color.Yellow);
defaultColors.Add(Color.YellowGreen);
defaultColors.Add(Color.Aqua);
defaultColors.Add(Color.Cyan);
defaultColors.Add(Color.DarkSeaGreen);
defaultColors.Add(Color.Indigo);
}
protected void Page_Load(object sender, EventArgs e)
{
this.ZedGraphWeb1.RenderGraph += new ZedGraph.Web.ZedGraphWebControlEventHandler(ZedGraphWeb1_RenderGraph);
}
protected void ZedGraphWeb1_RenderGraph(ZedGraph.Web.ZedGraphWeb webObject, System.Drawing.Graphics g, ZedGraph.MasterPane masterPane)
{
InitDefaultColors();
GraphPane myPane =masterPane[0];
myPane.Title.Text = "用户所在地理位置统计";
//此处给ZEDGRAPH 背景填充颜色
myPane.Fill = new Fill(Color.Cornsilk);
myPane.Chart.Fill = new Fill(Color.Cornsilk);
myPane.Legend.Position = LegendPos.Right;
//
//连接数据库
//此处需要注意SQLEXPRESS实例前必须加上转义字符"/"否则会报错!
SqlConnection myconnection = new SqlConnection("server=WIN-42QG6PPQFE7\\SQLEXPRESS;database=asd;Integrated Security=true");
SqlCommand mycommand = new SqlCommand("SELECT province FROM locate",myconnection);
myconnection.Open();
SqlDataReader dr = mycommand.ExecuteReader();
int i = 0;
while(dr.Read()==true)
{
int numbers = int.Parse(dr[0].ToString());
string names = dr[0].ToString();
//画图
PieItem segment = myPane.AddPieSlice(numbers, defaultColors[i], Color.White, 45f, 0, names);
segment.LabelType = PieLabelType.Value;
}
dr.Close();
CurveList curves = myPane.CurveList;
masterPane.AxisChange(g);
}