现在还没搞清楚为什么画不上去,或者画上去的都成了块状的,但是之前由于测试这个代码写了一段是可以画的,所以COPY过来对比了一下,除了Text属性和IntervalOffset属性的先后不同,没有其它的不同,但是结果就是一个画出来是条,另一个是正常的虚线。
这个应该是MS的漏洞,不管是不是,反正我现在就这么认为了。
CrtView.ChartAreas[0].AxisY.MajorGrid.Enabled = false; // 关闭网格线
StripLine sprUsl = new StripLine();
sprUsl.Text = "USL";
sprUsl.IntervalOffset = Convert.ToDouble(dtChartInfo.Rows[0]["usl"]);
//sprUsl.IntervalOffset = 0.43000000000;
sprUsl.BorderColor = Color.Red;
sprUsl.BorderDashStyle = ChartDashStyle.Dash;
sprUsl.BorderWidth = 1;
CrtView.ChartAreas[0].AxisY.StripLines.Add(sprUsl);
sprUsl = new StripLine();
sprUsl.Text = "UCL";
sprUsl.IntervalOffset = Convert.ToDouble(dtChartInfo.Rows[0]["ucl"]);
sprUsl.BorderColor = Color.Red;
sprUsl.BorderDashStyle = ChartDashStyle.Dash;
sprUsl.BorderWidth = 1;
CrtView.ChartAreas[0].AxisY.StripLines.Add(sprUsl);
sprUsl = new StripLine();
sprUsl.Text = "LCL";
sprUsl.IntervalOffset = Convert.ToDouble(dtChartInfo.Rows[0]["lcl"]);
sprUsl.BorderColor = Color.Red;
sprUsl.BorderDashStyle = ChartDashStyle.Dash;
sprUsl.BorderWidth = 1;
sprUsl = new StripLine();
sprUsl.IntervalOffset = Convert.ToDouble(dtChartInfo.Rows[0]["tg"]);
sprUsl.Text = "CL";
sprUsl.BorderDashStyle = ChartDashStyle.Dash;
CrtView.ChartAreas[0].AxisY.StripLines.Add(sprUsl);//这里应该ADD上去
sprUsl = new StripLine();
sprUsl.IntervalOffset = Convert.ToDouble(dtChartInfo.Rows[0]["lsl"]);
sprUsl.Text = "LSL";
sprUsl.BorderDashStyle = ChartDashStyle.Dash;
CrtView.ChartAreas[0].AxisY.StripLines.Add(sprUsl);
昨天的代码:
真尼马奇怪设置了宽度为1也是满格的条状,
StripLine sprUsl = new StripLine();
sprUsl.IntervalOffset = Convert.ToDouble(dtChartInfo.Rows[0]["usl"]);
sprUsl.Text = "USL";
sprUsl.BorderDashStyle = ChartDashStyle.Dash;
sprUsl.BorderWidth = 1;
sprUsl.StripWidth = 1;
sprUsl.BackColor = Color.Red;
CrtView.ChartAreas[0].AxisY.StripLines.Add(sprUsl);
sprUsl = new StripLine();
sprUsl.IntervalOffset = Convert.ToDouble(dtChartInfo.Rows[0]["ucl"]);
sprUsl.Text = "UCL";
sprUsl.BorderDashStyle = ChartDashStyle.Dash;
CrtView.ChartAreas[0].AxisY.StripLines.Add(sprUsl);
sprUsl = new StripLine();
sprUsl.IntervalOffset = Convert.ToDouble(dtChartInfo.Rows[0]["lcl"]);
sprUsl.Text = "LCL";
sprUsl.BorderDashStyle = ChartDashStyle.Dash;