一、绘制Y轴的MarkLine
ColorLine使用
实例化
// 实例化
colorLine Steema.TeeChart.Tools.ColorLine colorLine = new Steema.TeeChart.Tools.ColorLine(this.tChart1.Chart); colorLine.Active = true;
//所在轴
colorLine.Axis = tChart1.Axes.Left;
//值设置
colorLine.Value = Convert.ToDouble((textBox1.Text.Trim()));
//颜色设置
colorLine.Pen.Visible = true; colorLine.Pen.Color = cleBg.Color;
//粗细设置
colorLine.Pen.Width=2;
//线条样式设置 实线/虚线等
colorLine.Pen.Style=System.Drawing.Drawing2D.DashStyle.Solid;
效果展示
二、指定Y轴区间值内点的颜色
//自定义第一条线的Y轴值
double A=20;
//自定义第二条线的Y轴值
double B=25; /
/在触发处绑定GetPointerStyle事件
line.GetPointerStyle += Line_GetPointerStyle;
private void Line_GetPointerStyle(Steema.TeeChart.Styles.CustomPoint series, Steema.TeeChart.Styles.GetPointerStyleEventArgs e)
{
//因为e.ValueIndex从-1开始 所以做加1处理
int index = e.ValueIndex + 1;
//符合条件的改变其颜色,颜色也可前端配置读取
if (Convert.ToDouble(this.tChart.Series[0][index].Y) >= A && Convert.ToDouble(this.tChart.Series[0][index].Y) <= B)
{ series.Pointer.Color = System.Drawing.Color.Green; } else {
//看需求添加 ,符合条件外的改变点的颜色 //如不需改变可去掉整个else部分的代码 eries.Pointer.Color = System.Drawing.Color.Blue;
}
}
效果展示
三、刻度线以及次刻度线设置
//设置Y轴主刻度线
this.tChart1.Axes.Left.Ticks.Visible = true;
//刻度线粗细
this.tChart1.Axes.Left.Ticks.Width = 2;
//设置Y轴次刻度线
this.tChart1.Axes.Left.MinorTicks.Visible = true;
//设置Y轴次刻度线长度
this.tChart1.Axes.Left.MinorTicks.Length = 5;
//设置Y轴次刻度线铺满
this.tChart1.Axes.Left.MinorGrid.Visible = true;
//铺满条数
this.tChart1.Axes.Left.MinorTickCount = 2;