DundasWebChart的例子
前台:
<dcwc:chart id="chart1" runat="server" width="970" height="360px" imagetype="png" titlefontcolor="whitesmoke" titlefont="microsoft sans serif, 12pt">
<series>
<dcwc:series backgradienttype="verticalcenter" name="default" color="0, 192, 192" backgradientendcolor="paleturquoise"></dcwc:series>
</series>
<legend enabled="false">
</legend>
<borderskin skinstyle="framethin6" framebackgradientendcolor="255, 192, 128" framebackhatchstyle="outlineddiamond"
framebackcolor="cornsilk" framebackgradienttype="leftright"></borderskin>
<chartareas>
<dcwc:chartarea backcolor="floralwhite" backgradienttype="leftright" name="default" backgradientendcolor="navajowhite"
shadowcolor="darkgray" shadowoffset="3"></dcwc:chartarea>
</chartareas>
</dcwc:chart>
后台:
protected dundas.charting.webcontrol.chart chart1;
//生成图表
chart1.chartareas["default"].axisy.title=dppramt.selecteditem.text;
chart1.chartareas["default"].axisx.title="date";
chart1.title =tit;
if (this.rbcolunm.checked==true)
{
chart1.series[0].charttype = "column";
}
else
{
chart1.series[0].charttype = "line";
}
//改变标题颜色
chart1.titlefontcolor = color.red;
chart1.series[0]["labelstyle"] = "center";
chart1.backhatchstyle = charthatchstyle.shingle;
chart1.backgradienttype = gradienttype.none;
chart1.borderstyle = chartdashstyle.dashdotdot;
chart1.forecolor=color.lightgray;
chart1.borderwidth = 1;
// 控制图形上显示的toolstip提示
chart1.series[0].tooltip = "#valx: #valy ";//valx表示x值 ,val{c}表示y值
// 控制图形上显示的toolstip提示
chart1.series[0].legendtooltip = "#percent";//表示所占的百分比
chart1.series[0]["fontcolor"] ="red";
oracledatareader dr = db.getdatareader(str);
if (dr.hasrows==true)
{
if (dppramt.selecteditem.text=="running time")
{
chart1.series[0].points.databindxy(dr, "rd_day"/*横轴*/, dr, "cd_acctime"/*纵轴*/);
}
else if (dppramt.selecteditem.text=="work time")
{
chart1.series[0].points.databindxy(dr, "rd_day"/*横轴*/, dr, "cd_worktime"/*纵轴*/);
}
else if (dppramt.selecteditem.text=="dig number")
{
chart1.series[0].points.databindxy(dr, "rd_day"/*横轴*/, dr, "cd_dignumber"/*纵轴*/);
}
else if (dppramt.selecteditem.text=="travel time")
{
chart1.series[0].points.databindxy(dr, "rd_day"/*横轴*/, dr, "cd_traveltime"/*纵轴*/);
}
else
{
chart1.series[0].points.databindxy(dr, "rd_day"/*横轴*/, dr, "cd_workhour"/*纵轴*/);
}
}
db.connclose();
setaxisinterval(chart1.chartareas["default"].axisx, 1, datetimeintervaltype.days);//连续显示横轴坐标
chart1.chartareas["default"].axisx.labelsautofit = false;//auto样式关
chart1.chartareas["default"].axisx.labelstyle.offsetlabels = false;//一行显示横轴坐标,非上下交错
// chart1.chartareas["default"].axisx.labelstyle.fontangle = -30; 横轴坐标倾斜角度
chart1.chartareas["default"].axisx.labelstyle.font = new font("arial", 10);//横轴坐标字体大小
chart1.chartareas["default"].axisy.labelstyle.font = new font("arial", 10);//纵轴坐标字体大小
chart1.chartareas["default"].axisx.titlefont = new font("times new roman",10, fontstyle.bold);//横轴标题字体
chart1.chartareas["default"].axisy.titlefont = new font("times new roman",10, fontstyle.bold);
chart1.chartareas["default"].axisy2.enabled =axisenabled.false;//允许右侧有数字显示
chart1.chartareas["default"].axisy2.linecolor = color.red;//控制线的颜色
chart1.chartareas["default"].axisy2.linestyle = chartdashstyle.solid;//控制线的类型 实线还是点划线等等
chart1.chartareas["default"].axisy2.arrows = arrowstype.none;//控制线是否带箭头
3.------------------------
DundasWebChart控件使用(1)
DundasWebChart控件使用
using Dundas.Charting.WebControl;
。。。。。。
namespace AuditOnline.chart
{
/// <summary>
/// chart 的摘要说明。
/// </summary>
public class chart : MyBasePage
{
protected Dundas.Charting.WebControl.Chart Chart1;
。。。。。。
Chart1.Series.Clear();
Chart1.Titles.Clear();
Chart1.Palette=ChartColorPalette.SeaGreen;
Chart1.BackColor=Color.FloralWhite;
//string yyhkmname=new KjkmManage("mnf_km"+tb_dep1.Value).KMMCFromCode(kmdm.Value,ref kmm);
Chart1.Titles.Add("事业单位财务分析指标\""+dlist_zb.SelectedItem.Text+"\"比较图");
Chart1.Titles[0].Font = new Font("Times New Roman", 20, FontStyle.Bold);
Chart1.Titles[0].Color = Color.Red;
Chart1.Series.Clear();
Chart1.Series.Add(curyear+"年"+dlist_month.SelectedItem.Text);
Chart1.ChartAreas["Default"].AxisX.Interval=1;
Chart1.ChartAreas[0].BackColor=Color.Gainsboro;
if(dlist_zb.SelectedIndex==4)
{
Chart1.ChartAreas[0].AxisY.Title="金额(元)";
//Chart1.Series[0].LabelFormat="##.##%";
Chart1.Series[0].ToolTip="#VAL";
}
else
{
Chart1.ChartAreas[0].AxisY.Title="百分比(%)";
Chart1.Series[0].LabelFormat="##.##%";
Chart1.Series[0].ToolTip="#VAL%";
}
Chart1.Series[0].ShowLabelAsValue=true;
Chart1.Series[0]["BarLabelStyle"] = "TopLeft";
Chart1.Series[0].BorderColor=Color.SkyBlue;
//Chart1.Series[1].BorderColor=Color.SkyBlue;
Chart1.Series[0].Points.DataBindXY(dep,sumcash);
//Chart1.Series[1].Points.DataBindY(preycash);
Chart1.Series[0]["PointWidth"] = "0.8";
//Chart1.Series[1].ToolTip="#VAL";
if(mcount<6) Chart1.Width=Unit.Pixel(800);
else Chart1.Width=Unit.Pixel(120+80*mcount);
Chart1.Height=Unit.Pixel(500);
//Response.Write(sql2+"<br>"+sql3);
。。。。。。
Chart1.Titles.Clear();
Chart1.Palette=ChartColorPalette.Default;
Chart1.BackColor=Color.WhiteSmoke;
//Chart1.Series[0].Type = SeriesChartType.Spline;
// string kmm="";
string yyhkmname=kmdm.Value;
// string yyhkmname=new KjkmManage("mnf_km"+tb_dep1.Value,dlist_year.SelectedValue).KMMCFromCode(kmdm.Value,out kmm);
Chart1.Titles.Add(this.GetDepartNameByID(Convert.ToInt32(tb_dep1.Value))+KMMCFromCode(kmdm.Value,strCodeDesign,m_dtkmTable)+"变化比较图");
Chart1.Titles[0].Font = new Font("Times New Roman", 20, FontStyle.Bold);
Chart1.Titles[0].Color = Color.Blue;
Chart1.Series.Clear();
Chart1.Series.Add(curyear+"年");
Chart1.Series.Add(preyear+"年");
Chart1.Series.Add(ppreyear+"年");
Chart1.Series[0].Type=SeriesChartType.Line;
Chart1.Series[1].Type=SeriesChartType.Line;
Chart1.Series[2].Type=SeriesChartType.Line;
Chart1.Series[0].BorderWidth=2;
Chart1.Series[1].BorderWidth=2;
Chart1.Series[2].BorderWidth=2;
Chart1.ChartAreas[0].Area3DStyle.Enable3D = false;
Chart1.ChartAreas[0].BackColor=Color.White;
//Chart1.DataSource=dv;
//string [] mstr={"1","2","3","4","5","6","7","8","9","10","11","12"};
Chart1.ChartAreas["Default"].AxisX.Interval=1;
Chart1.ChartAreas[0].AxisX.Title="月份";
Chart1.ChartAreas[0].AxisY.Title="金额(元)";
Chart1.Series[0].ShowLabelAsValue=true;
Chart1.Series[1].ShowLabelAsValue=true;
Chart1.Series[2].ShowLabelAsValue=true;
Chart1.Series[0]["BarLabelStyle"] = "TopLeft";
Chart1.Series[1]["BarLabelStyle"] = "TopLeft";
Chart1.Series[2]["BarLabelStyle"] = "TopLeft";
Chart1.Series[0].BorderColor=Color.SkyBlue;
Chart1.Series[1].BorderColor=Color.SkyBlue;
Chart1.Series[2].BorderColor=Color.SkyBlue;
Chart1.Series[0].Points.DataBindXY(mstr,curycash);
Chart1.Series[1].Points.DataBindY(preycash);
Chart1.Series[2].Points.DataBindY(ppreycash);
Chart1.Series[0]["PointWidth"] = "0.8";
Chart1.Series[1]["PointWidth"] = "0.8";
Chart1.Series[2]["PointWidth"] = "0.8";
//Chart1.Series[0].ToolTip="金额: #VAL";
//Chart1.Series[1].ToolTip="金额: #VAL";
Chart1.Series[0].ToolTip="#VAL";
Chart1.Series[1].ToolTip="#VAL";
Chart1.Series[2].ToolTip="#VAL";
if(dlist_dep.Items.Count< 6) Chart1.Width=Unit.Pixel(800);
else Chart1.Width=Unit.Pixel(120+80*dlist_dep.Items.Count);
Chart1.Height=Unit.Pixel(500);
。。。。。。
Chart1.Series.Clear();
Chart1.Titles.Clear();
Chart1.Palette=ChartColorPalette.SemiTransparent;
Chart1.BackColor=Color.WhiteSmoke;
//Chart1.Series[0].Type = SeriesChartType.Spline;
//string kmm="";
//string yyhkmname=new KjkmManage("mnf_km"+tb_dep1.Value).KMMCFromCode(kmdm.Value,ref kmm);
Chart1.Titles.Add(curyear+"年"+dlist_month.SelectedItem.Text+"科技服务收入比较图");
Chart1.Titles[0].Font = new Font("Times New Roman", 20, FontStyle.Bold);
Chart1.Titles[0].Color = Color.Red;
Chart1.Series.Clear();
Chart1.Series.Add("科技服务总收入");
Chart1.Series.Add("12121收入");
Chart1.Series.Add("防雷收入");
Chart1.Series.Add("广告及气球收入");
Chart1.Series.Add("其它收入");
Chart1.Series[0].Type=SeriesChartType.Spline;
Chart1.Series[1].Type=SeriesChartType.Spline;
Chart1.Series[2].Type=SeriesChartType.Spline;
Chart1.Series[3].Type=SeriesChartType.Spline;
Chart1.Series[4].Type=SeriesChartType.Spline;
Chart1.Series[0].BorderWidth=2;
Chart1.Series[1].BorderWidth=2;
Chart1.Series[2].BorderWidth=2;
Chart1.Series[3].BorderWidth=2;
Chart1.Series[4].BorderWidth=2;
// Chart1.Series[0].Type=SeriesChartType.Spline;
//Chart1.Series.Add(preyear+"年"+);
//Chart1.DataSource=dv;
//string [] mstr={"1","2","3","4","5","6","7","8","9","10","11","12"};
Chart1.ChartAreas["Default"].AxisX.Interval=1;
Chart1.ChartAreas[0].Area3DStyle.Enable3D = false;
Chart1.ChartAreas[0].BackColor=Color.White;
//Chart1.ChartAreas[0].AxisX.Title="月份";
Chart1.ChartAreas[0].AxisY.Title="金额(元)";
//Chart1.Series[0].LabelFormat="##.##%";
Chart1.Series[0].ToolTip="#VAL";
Chart1.Series[1].ToolTip="#VAL";
Chart1.Series[2].ToolTip="#VAL";
Chart1.Series[3].ToolTip="#VAL";
Chart1.Series[4].ToolTip="#VAL";
Chart1.Series[0].ShowLabelAsValue=true;
//Chart1.Series[0].FontColor=Color.Red;
Chart1.Series[0]["BarLabelStyle"] = "TopLeft";
Chart1.Series[1].ShowLabelAsValue=true;
Chart1.Series[1]["BarLabelStyle"] = "TopLeft";
Chart1.Series[2].ShowLabelAsValue=true;
Chart1.Series[2]["BarLabelStyle"] = "TopLeft";
//Chart1.Series[1]["BarLabelStyle"] = "TopLeft";
Chart1.Series[3].ShowLabelAsValue=true;
Chart1.Series[3]["BarLabelStyle"] = "TopLeft";
//Chart1.Series[1].ShowLabelAsValue=true;
Chart1.Series[4].ShowLabelAsValue=true;
Chart1.Series[4]["BarLabelStyle"] = "TopLeft";Chart1.Series[0].BorderColor=Color.SkyBlue;
//Chart1.Series[1].BorderColor=Color.SkyBlue;
Chart1.Series[0].Points.DataBindXY(dep,sumcash0);
Chart1.Series[1].Points.DataBindY(sumcash1);
Chart1.Series[2].Points.DataBindY(sumcash2);
Chart1.Series[3].Points.DataBindY(sumcash3);
Chart1.Series[4].Points.DataBindY(sumcash4);
Chart1.Series[0]["PointWidth"] = "0.8";
Chart1.Series[1]["PointWidth"] = "0.8";
Chart1.Series[2]["PointWidth"] = "0.8";
Chart1.Series[3]["PointWidth"] = "0.8";
Chart1.Series[4]["PointWidth"] = "0.8";
//Chart1.Series[0].ToolTip="金额: #VAL";
//Chart1.Series[1].ToolTip="金额: #VAL";
//Chart1.Series[1].ToolTip="#VAL";
if(mcount<6) Chart1.Width=Unit.Pixel(800);
else Chart1.Width=Unit.Pixel(120+80*mcount);
Chart1.Height=Unit.Pixel(500);
。。。。。。
DundasWebChart控件使用(2)
前台:
<dcwc:chart id="Chart1" runat="server" Width="970" Height="360px" ImageType="Png" TitleFontColor="WhiteSmoke" TitleFont="Microsoft Sans Serif, 12pt">
<SERIES>
<dcwc:Series BackGradientType="VerticalCenter" Name="Default" Color="0, 192, 192" BackGradientEndColor="PaleTurquoise"></dcwc:Series>
</SERIES>
<LEGEND Enabled="false">
</LEGEND>
<BORDERSKIN SkinStyle="FrameThin6" FrameBackGradientEndColor="255, 192, 128" FrameBackHatchStyle="OutlinedDiamond"
FrameBackColor="Cornsilk" FrameBackGradientType="LeftRight"></BORDERSKIN>
<CHARTAREAS>
<dcwc:ChartArea BackColor="FloralWhite" BackGradientType="LeftRight" Name="Default" BackGradientEndColor="NavajoWhite"
ShadowColor="DarkGray" ShadowOffset="3"></dcwc:ChartArea>
</CHARTAREAS>
</dcwc:chart>
后台:
protected Dundas.Charting.WebControl.Chart Chart1;
//生成图表
Chart1.ChartAreas["Default"].AxisY.Title=DpPramt.SelectedItem.Text;
Chart1.ChartAreas["Default"].AxisX.Title="DATE";
Chart1.Title =tit;
if (this.RBColunm.Checked==true)
{
Chart1.Series[0].ChartType = "Column";
}
else
{
Chart1.Series[0].ChartType = "Line";
}
//改变标题颜色
Chart1.TitleFontColor = Color.Red;
Chart1.Series[0]["LabelStyle"] = "Center";
Chart1.BackHatchStyle = ChartHatchStyle.Shingle;
Chart1.BackGradientType = GradientType.None;
Chart1.BorderStyle = ChartDashStyle.DashDotDot;
Chart1.ForeColor=Color.LightGray;
Chart1.BorderWidth = 1;
// 控制图形上显示的toolstip提示
Chart1.Series[0].ToolTip = "#VALX: #VALY ";//VALX表示X值 ,VAL{C}表示Y值
// 控制图形上显示的toolstip提示
Chart1.Series[0].LegendToolTip = "#PERCENT";//表示所占的百分比
Chart1.Series[0]["FontColor"] ="Red";
OracleDataReader dr = db.GetDataReader(str);
if (dr.HasRows==true)
{
if (DpPramt.SelectedItem.Text=="running time")
{
Chart1.Series[0].Points.DataBindXY(dr, "rd_day"/*横轴*/, dr, "cd_acctime"/*纵轴*/);
}
else if (DpPramt.SelectedItem.Text=="work time")
{
Chart1.Series[0].Points.DataBindXY(dr, "rd_day"/*横轴*/, dr, "cd_worktime"/*纵轴*/);
}
else if (DpPramt.SelectedItem.Text=="dig number")
{
Chart1.Series[0].Points.DataBindXY(dr, "rd_day"/*横轴*/, dr, "cd_dignumber"/*纵轴*/);
}
else if (DpPramt.SelectedItem.Text=="travel time")
{
Chart1.Series[0].Points.DataBindXY(dr, "rd_day"/*横轴*/, dr, "cd_traveltime"/*纵轴*/);
}
else
{
Chart1.Series[0].Points.DataBindXY(dr, "rd_day"/*横轴*/, dr, "cd_workhour"/*纵轴*/);
}
}
db.ConnClose();
SetAxisInterval(Chart1.ChartAreas["Default"].AxisX, 1, DateTimeIntervalType.Days);//连续显示横轴坐标
Chart1.ChartAreas["Default"].AxisX.LabelsAutoFit = false;//auto样式关
Chart1.ChartAreas["Default"].AxisX.LabelStyle.OffsetLabels = false;//一行显示横轴坐标,非上下交错
// Chart1.ChartAreas["Default"].AxisX.LabelStyle.FontAngle = -30; 横轴坐标倾斜角度
Chart1.ChartAreas["Default"].AxisX.LabelStyle.Font = new Font("Arial", 10);//横轴坐标字体大小
Chart1.ChartAreas["Default"].AxisY.LabelStyle.Font = new Font("Arial", 10);//纵轴坐标字体大小
Chart1.ChartAreas["Default"].AxisX.TitleFont = new Font("Times New Roman",10, FontStyle.Bold);//横轴标题字体
Chart1.ChartAreas["Default"].AxisY.TitleFont = new Font("Times New Roman",10, FontStyle.Bold);
Chart1.ChartAreas["Default"].AxisY2.Enabled =AxisEnabled.False;//允许右侧有数字显示
Chart1.ChartAreas["Default"].AxisY2.LineColor = Color.Red;//控制线的颜色
Chart1.ChartAreas["Default"].AxisY2.LineStyle = ChartDashStyle.Solid;//控制线的类型 实线还是点划线等等
Chart1.ChartAreas["Default"].AxisY2.Arrows = ArrowsType.None;//控制线是否带箭头
DundasWebChart控件使用(3)
Dundas chart 数据绑定的问题
时间:2008-01-30 23:33:50 来源:论坛整理 翻译整理:IT者 :作者:blue7506
我想在一个饼状图里面显示统计数据,代码如下:
string sql = "SELECT bj,count(*) as m FROM gzxx group by bj";
string con = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= test.mdb";
OleDbConnection form5con = new OleDbConnection(con);
OleDbCommand form5com = new OleDbCommand(sql, form5con);
DataSet form5DataSet = new DataSet();
OleDbDataAdapter form5OleDbDataAdapter = new OleDbDataAdapter(sql, con);
form5con.Open();
form5OleDbDataAdapter.Fill(form5DataSet, "form5table");
chart1.Series["Series1"].Points.DataBind(form5DataSet.Tables["form5table"],"bj","m");
提示错误:
错误 2 “DataBind”方法没有采用“3”个参数的重载
这是为什么,正确的写法是什么?谢谢好高手指教!
网友回复:应该有例子的! 你自己在文档里或官方网站查一下:
这里有个例子
DataTable pc=form5DataSet.Tables["form5table"];
if(pc!=null&&pc.Count> 0)
{
Chart1.Titles[0].Text=pc[0].P_MarketName Chart1.Titles[0].Text;
for(int i = pc.Count-1; i > -1; i--)
{
Chart1.Series["Prices"].Points.AddXY(Convert.ToDateTime(pc[i].P_PubTime), pc[i].P_AverPrice);
int j=Chart1.Series["PricesCols"].Points.AddXY(Convert.ToDateTime(pc[i].P_PubTime), pc.MaxAverPrice);
Chart1.Series["PricesCols"].Points[j].ToolTip = String.Format("{0:yyyy年MM月dd日} {1}元/公斤", Convert.ToDateTime(pc[i].P_PubTime),pc[i].P_AverPrice);
//Chart1.Series["PricesCols"].Points[j].MapAreaAttributes = String.Format("href='javascript:void(0);' onmouseover=\"dispData('{0:yyyy年MM月dd日}','{1}')\" onmouseout=\"hideData()\"", Convert.ToDateTime(pc[i].P_PubTime), pc.MaxAverPrice);
Chart1.Series["PricesCols"].Points[j].MapAreaAttributes = "href='javascript:void(0);'";
}
//labMsg.Visible=false;
labMsg.Text="提示:将鼠标移动到价格曲线上并停留片刻,您可以看到具体日期下的价格信息!";
}
else
{
labMsg.Text="未找到最近60天内报价数据,如您需要查询更多的历史数据,请使用价格趋势图Vip版本!";
Chart1.Visible=false;
}
网友回复:谢谢!我自己解决了!
把
chart1.Series["Series1"].Points.DataBind(form5DataSet.Tables["form5table"],"bj","m");
改成
chart1.Series["Series1"].Points.DataBind(form5DataSet.Tables"form5table"].DefaultView , "bj", "m","");
我们用的代码
前台
<DCWC:Chart ID="Chart1" runat="server" BackGradientEndColor="LightBlue" BorderLineColor="Gray"
Height="317px" ImageUrl="../ReportImages/" Palette="EarthTones" Width="840px">
<Titles>
<DCWC:Title Alignment="MiddleRight">
</DCWC:Title>
</Titles>
<Legends>
<DCWC:Legend BackColor="Transparent" BorderColor="Transparent" Enabled="False" Name="Default">
</DCWC:Legend>
</Legends>
<BorderSkin FrameBackColor="Khaki" FrameBackGradientEndColor="Olive" />
<Series>
<DCWC:Series BackGradientEndColor="Khaki" BackGradientType="VerticalCenter" BorderColor="64, 64, 64"
BorderWidth="2" ChartType="Spline" FontColor="Red" LegendText="水位" MarkerBorderColor="64, 64, 64"
MarkerStyle="Circle" Name="Series1" ShadowOffset="1" ShowLabelAsValue="True"
XValueType="Double" YValueType="Double" >
</DCWC:Series>
<DCWC:Series BackGradientEndColor="Khaki" BackGradientType="VerticalCenter" BorderColor="1, 64, 64"
BorderWidth="2" ChartType="Spline" FontColor="Red" LegendText="流量" MarkerBorderColor="64, 64, 64"
MarkerStyle="Triangle" Name="Series2" ShadowOffset="1" ShowLabelAsValue="True"
XValueType="Double" YValueType="Double">
</DCWC:Series>
</Series>
<ChartAreas>
<DCWC:ChartArea BackColor="Transparent" BorderColor="64, 64, 64" Name="Default">
<AxisY2 LineColor="64, 64, 64">
</AxisY2>
<AxisX2 LineColor="64, 64, 64">
</AxisX2>
<AxisY LineColor="64, 64, 64">
<MajorGrid LineColor="Gray" LineStyle="Dash" />
<LabelStyle OffsetLabels="True" ShowEndLabels="False" />
</AxisY>
<AxisX LineColor="64, 64, 64">
<MajorGrid LineColor="Gray" LineStyle="Dash" />
</AxisX>
</DCWC:ChartArea>
</ChartAreas>
</DCWC:Chart>
后台代码
private void BindGridView()
{
if (ViewState["m_strArea"] == null)
ViewState["m_strArea"] = "1=1";
DataSet ds = clsFunRsvr.GetRsvrPublicReport(ViewState["m_strTMBegin"].ToString(), ViewState["m_strTMEnd"].ToString(), ViewState["m_strArea"].ToString());
this.grdView.DataSource = ds.Tables[0];
grdView.DataBind();
PageCursorControl1.SetDs = ds;
PageCursorControl1.SetBind();
//绑定图表控件
if (ViewState["m_strArea"].ToString() != "1=1" && ds.Tables[0].Rows.Count > 0)
{
//((Chart)TabContainer1.FindControl("Chart1")).Visible = true;
CreateColumn(ds.Tables[0]);
}
}
private void CreateColumn(DataTable dt)
{
int intRecn = dt.Rows.Count;
double[] yValues = new double[intRecn];
double[] y2Values = new double[intRecn];
string[] xValues = new string[intRecn];
double miny = 0;
double miny1 = 0;
try
{
for (int i = 0; i < dt.Rows.Count; i++)
{
xValues[i] = dt.Rows[i]["tm"].ToString();
yValues[i] = Convert.ToDouble(dt.Rows[i]["RZ"]);
y2Values[i] = Convert.ToDouble(dt.Rows[i]["W"]);
if(i == 0|| Convert.ToDouble(dt.Rows[i]["RZ"])<miny)
miny = Convert.ToDouble(dt.Rows[i]["RZ"]);
if (i == 0 ||Convert.ToDouble(dt.Rows[i]["W"]) < miny1)
miny1 = Convert.ToDouble(dt.Rows[i]["W"]);
}
this.Chart1.Width = Unit.Pixel(840);
this.Chart1.Height = Unit.Pixel(420);
Chart1.Series["Series1"].Points.DataBindXY(xValues, yValues);
Chart1.Series["Series2"].Points.DataBindXY(xValues, y2Values);
Chart1.Series["Series2"].YAxisType = AxisType.Secondary;
Chart1.Series["Series1"].Type = SeriesChartType.Spline;
Chart1.Series["Series2"].Type = SeriesChartType.Spline;
Chart1.Series["Series1"]["DoughnutRadius"] = "30";
Chart1.ChartAreas["Default"].AxisX.LabelStyle.ShowEndLabels = false;
Chart1.ChartAreas["Default"].AxisX.LabelStyle.Interval = 1;
Chart1.Legends["Default"].Enabled = false;//显示标签
Chart1.ChartAreas["Default"].EquallySizedAxesFont = true; //小字体
Chart1.ChartAreas["Default"].AxisY.Arrows = ArrowsType.None;
//Hide X axis end labels
Chart1.ChartAreas["Default"].AxisX.MinorGrid.Enabled = true;
Chart1.ChartAreas["Default"].AxisX.MinorTickMark.Enabled = true;
Chart1.ChartAreas["Default"].AxisX.TitleAlignment = StringAlignment.Far;
Chart1.ChartAreas["Default"].AxisX.TitleColor = Color.Red;
Chart1.ChartAreas["Default"].AxisX.Title = "日期";
// Set Grid lines and tick marks interval
Chart1.ChartAreas["Default"].AxisX.MajorGrid.Interval = 4;
Chart1.ChartAreas["Default"].AxisX.MajorTickMark.Interval = 4;
Chart1.ChartAreas["Default"].AxisX.MinorGrid.Interval = 1;
Chart1.ChartAreas["Default"].AxisX.MinorTickMark.Interval = 1;
Chart1.ChartAreas["Default"].AxisX.MajorGrid.LineStyle = ChartDashStyle.Dot;
Chart1.ChartAreas["Default"].AxisY.MajorGrid.LineStyle = ChartDashStyle.Dot;
Chart1.ChartAreas["Default"].AxisX.MinorGrid.LineStyle = ChartDashStyle.Dot;
Chart1.ChartAreas["Default"].AxisY.MinorGrid.LineStyle = ChartDashStyle.Dot;
Chart1.ChartAreas["Default"].AxisY.TitleAlignment = StringAlignment.Far;
Chart1.ChartAreas["Default"].AxisY.TitleColor = Color.Red;
Chart1.ChartAreas["Default"].AxisY.Title = "水位(米)";
Chart1.ChartAreas["Default"].AxisY2.TitleColor = Color.Red;
Chart1.ChartAreas["Default"].AxisY2.Title = "库容(百万立方米)";
Chart1.Series["Series1"]["BackGradientType"] = "LeftRight";
// 控制图形上显示的toolstip提示
Chart1.Series["Series1"].ToolTip = "#VALY";//valx表示x值 ,val{c}表示y值
Chart1.Series["Series2"].ToolTip = "#VALY2";//valx表示x值 ,val{c}表示y值
//设置y轴起始点值
Chart1.ChartAreas["Default"].AxisY.Minimum = Convert.ToInt32(miny-10);
Chart1.ChartAreas["Default"].AxisY2.Minimum =Convert.ToInt32(miny1-10);
// Set series point width
Chart1.Series["Series1"]["PointWidth"] = "0.6";
// Show data points labels
if (cbShowValue.Checked == false)
{
Chart1.Series["Series1"].ShowLabelAsValue = false;//显示点上的数据
Chart1.Series["Series2"].ShowLabelAsValue = false;
}
//Set data points label style
Chart1.Series["Series1"]["BarLabelStyle"] = "Center";
Chart1.Series["Series1"]["DrawingStyle"] = "Cylinder";
Chart1.ImageUrl = "../ReportImages/resSJSJTJ";
}
catch(Exception ex)
{
throw ex;
}
}

浙公网安备 33010602011771号