protected void Page_Load(object sender, EventArgs e) { //Please modify the connection string in web.config and choose the correct path of .mdb file. //Step 1: Choose one appearance style from enum FanG.Chartlet.AppearanceStyles Chartlet1.AppearanceStyle = FanG.Chartlet.AppearanceStyles.Bar_2D_StarryNight_FlatCrystal_Glow_TextureBorder; //Alternative steps //If you want to use other colors, decomments the statement below, and you can use different value (0 ~ 12) //Chartlet1.FillShiftStep = 8; //You can still setting other attributes here. //Step 2: Bind a data source Chartlet1.BindChartData(SqlDataSource1); //OK, run your web form, a beautiful chart appears, does it? //So simple Chartlet is. //More info on http://www.Chartlet.cn //========================================================// Chartlet2.AppearanceStyle = FanG.Chartlet.AppearanceStyles.Line_2D_StarryNight_ThickRound_Glow_NoBorder; Chartlet2.ChartTitle.Text = "Line Chart"; //You adjust some attributes based on AppearanceStyle selected //Chartlet2.LineWidth = 2; Chartlet2.MaxValueY = 1000; Chartlet2.BindChartData(SqlDataSource1); Chartlet3.AppearanceStyle = FanG.Chartlet.AppearanceStyles.Line_3D_StarryNight_FlatCrystalRound_NoGlow_NoBorder; Chartlet3.Fill.ShiftStep = 7; Chartlet3.ChartTitle.Text = "Pie Chart"; Chartlet3.BindChartData(SqlDataSource1); Chartlet4.AppearanceStyle = FanG.Chartlet.AppearanceStyles.Pie_3D_Aurora_NoCrystal_NoGlow_NoBorder; Chartlet4.Fill.ShiftStep = 9; Chartlet4.ChartTitle.Text = "3D Pie Chart"; Chartlet4.BindChartData(SqlDataSource1); }
protected void Page_Load(object sender, EventArgs e) { string cs = WebConfigurationManager.ConnectionStrings["Chartlet"].ConnectionString + Server.MapPath("App_data\\Chartlet.mdb"); SqlDataSource1.ConnectionString = cs; //设置数值标签的文字样式 Chartlet1.Tips.ForeColor = Color.Brown; Chartlet1.MaxValueY = 1000; Chartlet1.Shadow.Radius = 5; Chartlet1.ColorGuider.Show = false; Chartlet1.AppearanceStyle = FanG.Chartlet.AppearanceStyles.Pie_3D_Aurora_FlatCrystal_NoGlow_NoBorder; Chartlet1.Fill.ShiftStep = 4; Chartlet1.BindChartData(SqlDataSource1); //更多信息请参看 http://www.Chartlet.cn string sql = "Select Season,Profit from Sales"; OleDbConnection cn = new OleDbConnection(cs); OleDbDataAdapter da = new OleDbDataAdapter(sql, cn); DataSet ds = new DataSet(); da.Fill(ds, "Jesy"); Chartlet2.AppearanceStyle = FanG.Chartlet.AppearanceStyles.Line_3D_Aurora_FlatCrystalRound_NoGlow_NoBorder; //下面两个属性用来增大图形右边和下面的可视范围,避免ColorGuider和XLabels的字符被截断 Chartlet2.InflateBottom = 50; Chartlet2.InflateRight = 100; Chartlet2.Width = 1200; //下面通过MinValueY和MaxValueY来纵向拉伸图形,可以注释下面两句看看不拉伸的效果 Chartlet2.MinValueY = 200; Chartlet2.MaxValueY = 600; Chartlet2.BindChartData(ds); /*** 这里演示手动修改横坐标,纵坐标一般是数值,最多只能修改纵坐标的单位,其他暂时不支持修改 ***/ DataTable tb = ds.Tables["Jesy"]; Chartlet3.YLabels.UnitText = "销售额(万元)"; Chartlet3.XLabels.UnitFont = new Font("Arial", 18, FontStyle.Bold, GraphicsUnit.Pixel); Chartlet3.ShowErrorInfo = false; Chartlet3.InflateBottom = 100; Chartlet3.AppearanceStyle = FanG.Chartlet.AppearanceStyles.Bar_2D_StarryNight_FlatCrystal_Glow_WhiteBorder; Chartlet3.BindChartData(tb); //下面演示在绑定数据源之后,如何修改X坐标和ColorGuider的文字 Chartlet3.GroupTitle = new string[] { "利润", "成本" }; /** X 坐标的修改 **/ Chartlet3.AxisX[0] = "春"; Chartlet3.AxisX[1] = "夏"; /* * 以此类推,修改每一个X坐标 * 你也可以把一个string数组赋给AxisX,但是数组长度必须大于等于tb.Rows.Count * * 下面提供一种利用数组拷贝的方法赋值,不需要知道AxisX数组的长度 */ string[] xlabels = new string[] { "春", "夏", "秋", "冬" }; xlabels.CopyTo(Chartlet3.AxisX, 0); /*** 这里演示手动修改横坐标,纵坐标一般是数值,最多只能修改纵坐标的单位,其他暂时不支持修改 ***/ }
protected void Page_Load(object sender, EventArgs e) { string cs = WebConfigurationManager.ConnectionStrings["Chartlet"].ConnectionString + Server.MapPath("App_data\\Chartlet.mdb"); string sql = "Select Season,Sales,Profit,Cost,(Sales-Profit-Cost) as S1 from Sales where user='******' order by Profit DESC"; OleDbConnection cn = new OleDbConnection(cs); OleDbDataAdapter da = new OleDbDataAdapter(sql, cn); DataSet ds = new DataSet(); da.Fill(ds, "Jesy"); string sql2 = "select DTime,Sales,Cost from Sales order by Dtime ASC"; DataSet ds2 = new DataSet(); da = new OleDbDataAdapter(sql2, cn); da.Fill(ds2, "Jesy"); /*选择外观基调*/ Chartlet1.AppearanceStyle = FanG.Chartlet.AppearanceStyles.Trend_2D_Aurora_ThinRound_Glow_NoBorder; //调整折线连接点的大小 Chartlet1.LineConnectionRadius = 6; //调整折线宽度 Chartlet1.Stroke.Width = 2; //关闭投影效果 Chartlet1.Shadow.Enable = false; //通过下面一句调整标题的高度 Chartlet1.ChartTitle.OffsetY = -10; //下面一句是TrendChart必须要有的,是TrendChart中最重要的设置(StartTime,EndTime,TimeSpanType,XLabelDisplayFormat) //如果你使用TrendChart,但是缺少了这一句,那么系统会提示:Please Set Chartlet.Trend attribute for Trend Chart //详细介绍请参看Chartlet.Trend的参考手册 Chartlet1.Trend = new FanG.TrendAttributes("2009-04-29", "2009-5-11", FanG.Chartlet.TimeSpanTypes.Day, "MM-dd"); //图表标题 Chartlet1.ChartTitle.Text = "TrendChart(趋势图)"; //绑定数据 Chartlet1.BindChartData(ds2); /******************************/ Chartlet2.AppearanceStyle = FanG.Chartlet.AppearanceStyles.Bar_2D_Aurora_FlatCrystal_NoGlow_NoBorder; Chartlet2.ColorGuider.Font = new Font("Arial", 9, FontStyle.Italic); Chartlet2.ColorGuider.ForeColor = Color.Green; Chartlet2.ChartTitle.ForeColor = Color.Green; Chartlet2.XLabels.ForeColor = Color.Green; Chartlet2.YLabels.ForeColor = Color.Green; Chartlet2.Tips.ForeColor = Color.Green; Chartlet2.ChartTitle.Text = "BaseLine Attribute(基准线属性)"; Chartlet2.YLabels.ValueFormat = "0."; //线面设置baseline属性,会产生一条基准线,基准线一下的数据会导致柱子负向增长 Chartlet2.BaseLineX = 360; Chartlet2.BindChartData(ds); /*****************************/ Chartlet3.AppearanceStyle = FanG.Chartlet.AppearanceStyles.Line_2D_StarryNight_ThickRound_Glow_NoBorder; Chartlet3.Tips.Font = new Font("Verdana", 6, FontStyle.Regular); Chartlet3.Tips.ForeColor = Color.Purple; Chartlet3.ChartTitle.Font = new Font("Verdana", 12, FontStyle.Regular); Chartlet3.YLabels.Font = new Font("Arial", 6); Chartlet3.YLabels.UnitFont = new Font("Arial", 6); Chartlet3.XLabels.Font = new Font("Arial", 11); Chartlet3.XLabels.UnitFont = new Font("Arial", 6); Chartlet3.XLabels.RotateAngle = 0; Chartlet3.ChartTitle.Text = "自定义颜色、X坐标文字、ColorGuider文字"; Chartlet3.BaseLineX = 492; //使用自定义颜色数组 //先定义一个自己的颜色数组 Color[] myColorA = { Color.Black, Color.Blue, Color.Green }; //在把它复制到你使用的Chartlet颜色数组中,如StarryNight myColorA.CopyTo(Chartlet3.StarryNight, 0); //折线连接符的大小 Chartlet3.LineConnectionRadius = 8; Chartlet3.Stroke.Width = 3; Chartlet3.BindChartData(ds); //自定义ColorGuider的文字,必须放在BindChartData()后面 Chartlet3.GroupTitle = new string[] { "CG1", "CG2", "CG3", "CG4", "CG5" }; //自定义X坐标文字,必须放在BindChartData()后面 Chartlet3.AxisX = new string[] { "x1", "x2", "x3", "x4", "x5" }; /****************************/ Chartlet4.AppearanceStyle = FanG.Chartlet.AppearanceStyles.HBar_2D_Aurora_FlatCrystal_Glow_NoBorder; Chartlet4.XLabels.RotateAngle = 0; Chartlet4.ChartTitle.Text = "HBar-Pareto (横向柱图-柏拉图)"; Chartlet4.Fill.TextureEnable = true; Chartlet4.BindChartData(ds); }
protected void Page_Load(object sender, EventArgs e) { //请先修改Web.Config里面的数据库连接字符串的.mdb文件的路径 /***********************************************************/ //第一步:设置一个属性(只需要从枚举类型中选取就可以了) Chartlet1.AppearanceStyle = FanG.Chartlet.AppearanceStyles.Bar_2D_Aurora_FlatCrystal_Glow_NoBorder; //可选步骤 //如果你要改变颜色,请取消下面一行的注释,并可以修改参数的值 0 ~ 12 (预置了12种典型颜色) Chartlet1.Fill.ShiftStep = 8; Chartlet1.Crystal.Contraction = 0; Chartlet1.Shadow.Distance = 2; Chartlet1.Shadow.Alpha = 200; //第二步:绑定一个数据源 Chartlet1.BindChartData(SqlDataSource1); //好了,运行一下看看,是不是一个很美丽的图表出现了? //Chartlet就这么简单 //更多信息请参看 http://www.Chartlet.cn /*☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆ * ☆ BindChartData()方法有四个构造函数,支持常见的四种数据源(DataSet,DataTable,DataView,SqlDataSource) * ☆ BindChartData(DataSet DataSource) * ☆ BindChartData(DataTable DataSource) * ☆ BindChartData(DataView DataSource) * ☆ BindChartData(SqlDataSource DataSource) * ☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆*/ /**********************************************************/ //========================================================// Chartlet2.AppearanceStyle = FanG.Chartlet.AppearanceStyles.Line_2D_StarryNight_ThickRound_Glow_NoBorder; Chartlet2.ChartTitle.Text = "2D Line Chart"; //在选择了AppearanceType的基础上进行微调 //Chartlet2.LineWidth = 2; Chartlet2.MaxValueY = 1000; Chartlet2.BindChartData(SqlDataSource1); Chartlet3.AppearanceStyle = FanG.Chartlet.AppearanceStyles.Line_3D_Aurora_FlatCrystalRound_NoGlow_NoBorder; /*************在选择了AppearanceType的基础上进行微调****************/ Chartlet3.Fill.ShiftStep = 7; Chartlet3.LineConnectionRadius = 8; //对于折线的颜色控制都使用StrokeColor属性(包括3D折线图) Chartlet3.Stroke.ShiftStep = 8; Chartlet3.Alpha3D = 200; Chartlet2.Tips.Show = false; //你可以取消注释下面一句,看看另一种效果 //Chartlet3.Crystal.Direction = FanG.Chartlet.Direction.BottomTop; //************上面代码是在AppearanceType的基础上进行微调***********/ Chartlet3.ChartTitle.Text = "3D Line Chart"; Chartlet3.BindChartData(SqlDataSource1); Chartlet4.AppearanceStyle = FanG.Chartlet.AppearanceStyles.Pie_3D_Aurora_NoCrystal_NoGlow_NoBorder; Chartlet4.Fill.ShiftStep = 9; Chartlet4.ChartTitle.Text = "3D Pie Chart"; Chartlet4.BindChartData(SqlDataSource1); }