.NET3.5 Chart图标控件
现有数据
价格 时间
20000 2010-9-1
30000 2010-9-2
35000 2010-9-3
45000 2010-8-30
怎么用Chart控件实现线形图
y轴 是 价格
x轴是时间 从数据的时间列中取出最晚的那个(2010-8-30)
求各位高手给个答案
最好是有代码的
在线等....
------解决方案--------------------这两段代码是在最后面的 我复制到这里 方便你了解
Chart1.ChartAreas.Add(ca); //从这里两段代码中 你可以看出Series放进ChartAreas放进Chart
Chart1.Series.Add(se);//Series是数据 ChartAreas类识数学上XY坐标轴() .....
时间 它会帮你排序好 其他的你看微软的sample把
----------------------------------------------
Chart1.ChartAreas.Clear();
Chart1.Series.Clear();
ChartArea ca = new ChartArea("caKPI");
ca.AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Dot;
ca.AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dot;
ca.AxisX.Interval = 1;
Series se = new Series("seKPI");
se.ChartArea = "caKPI";
DataTable dt = helper.QueryKPI(timeStart, timeEnd, key);
foreach (DataRow row in dt.Rows)
{
se.Points.AddXY(row[0], row[1]);
}
se.ChartType = SeriesChartType.Spline; //数据显示方式 Line:为折线 Spline:曲线
se.Color = Color.Green; //线条颜色
se.BorderWidth = 1; //线条宽度
se.ShadowOffset = 1; //阴影宽度
se.IsVisibleInLegend = true; //是否显示数据说明
se.IsValueShownAsLabel = isValueShownAsLabel; //线条上是否给吃数据的显示
se.MarkerStyle = MarkerStyle.Circle; //线条上的数据点标志类型
se.MarkerColor = Color.Red;
se.MarkerSize = 4; //标志的大小
se.Font = new Font("", 12, FontStyle.Regular);
se.LabelForeColor = Color.Red;
Chart1.ChartAreas.Add(ca); //从这里两段代码中 你可以看出Series放进ChartAreas放进Chart
Chart1.Series.Add(se);//Series是数据 ChartAreas类识数学上XY坐标轴() .....
------解决方案--------------------C# code
Chart1.Series["Series1"].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Line;//折线图
double[] yval1 = { 20000, 30000, 35000, 45000 };
string[] xval1 = { "2010-9-1", "2010-9-2", "2010-9-3", "2010-8-30"};
Chart1.Series["Series1"].Points.DataBindXY(xval1, yval1);
Chart1.Series["Series1"].IsValueShownAsLabel = true;
Chart1.Series["Series1"].MarkerStyle = System.Web.UI.DataVisualization.Charting.MarkerStyle.Circle;
Chart1.Series["Series1"].MarkerSize = 5;
Chart1.Series["Series1"].MarkerColor = System.Drawing.Color.Black;
------解决方案--------------------
.NET MSChart应用
------解决方案--------------------
一般处理是加虚线:
Chart1.Series["Series1"].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Line;//折线图
double[] yval1 = { 20000, 30000, double.NaN, 45000, 45875 };
string[] xval1 = { "2010-9-1", "2010-9-2", "2010-9-3", "2010-8-30","2010-9-5"};
Chart1.Series["Series1"].Points.DataBindXY(xval1, yval1);
Chart1.Series["Series1"].IsValueShownAsLabel = true;
Chart1.Series["Series1"].MarkerStyle = System.Web.UI.DataVisualization.Charting.MarkerStyle.Circle;
Chart1.Series["Series1"].MarkerSize = 5;
Chart1.Series["Series1"].MarkerColor = System.Drawing.Color.Black;
foreach (System.Web.UI.DataVisualization.Charting.Series series in Chart1.Series)