C# TeeChart使用心得,干货

去除顶上TeeChart 标题:图表->标题->显示
3D->2D:图表->3D->3D效果
右侧小图例去除:图表->图例

修改黑色背景:
1.外面板修改背景颜色:图表->面板->渐彩->颜色:开始 中间 结束修改颜色为黑色
2.内面板修改背景颜色:图表->壁板->显示壁板
3. 面板->背景->透明

图表->面板->边缘->外斜面->颜色-> 白色修改其他颜色

private void chart_MouseMove(object sender, MouseEventArgs e)
{
int value = (int)this.tChart1.Series[3].GetMarkValue(e.X);
//根据X轴鼠标事件对应的X值获取Y值,这是官方的方法但是不准确
//根据X轴找到对应的Y轴的数据最后用的一个偏方
}

this.tChart1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chart_MouseDown);
this.tChart1.MouseLeave += new System.EventHandler(this.chart_MouseLeave);
this.tChart1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart_MouseMove);
this.tChart1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.chart_MouseUp);

同一个X轴,多个Y轴:
声明4个Y轴
public Steema.TeeChart.Axis axis;
public Steema.TeeChart.Axis Green;
public Steema.TeeChart.Axis Red;
public Steema.TeeChart.Axis Orange;
intit方法中:
axis = this.tChart1.Axes.Left;
axis.AxisPen.Color = System.Drawing.Color.Cyan;
axis.StartPosition = 0; //开始位置
axis.EndPosition = 17;//结束位置
axis.Labels.Font.Color = System.Drawing.Color.Cyan;
axis.SetMinMax(0, 4);//这条Y轴的最大最小值

            Green = new Steema.TeeChart.Axis(tChart1.Chart);
            this.tChart1.Axes.Custom.Add(Green);
            Green.AxisPen.Color = System.Drawing.Color.Green;
            Green.StartPosition = 23;
            Green.EndPosition = 43;
            Green.Labels.Font.Color = System.Drawing.Color.Green;
            this.line2.CustomVertAxis = Green;  //曲线绑定Y轴部分
            Green.SetMinMax(0, 100);

            Red = new Steema.TeeChart.Axis(tChart1.Chart);
            this.tChart1.Axes.Custom.Add(Red);
            Red.AxisPen.Color = System.Drawing.Color.Red;
            Red.StartPosition = 48;
            Red.EndPosition = 68;
            Red.Labels.Font.Color = System.Drawing.Color.Red;
            this.line3.CustomVertAxis = Red;
            this.line3.LinePen.Color = System.Drawing.Color.Red;
            Red.SetMinMax(0, 100); 
            

             Orange = new Steema.TeeChart.Axis(tChart1.Chart);
            this.tChart1.Axes.Custom.Add(Orange);
            Orange.AxisPen.Color = System.Drawing.Color.Orange;
            Orange.StartPosition = 73;
            Orange.EndPosition = 100;
            Orange.Labels.Font.Color = System.Drawing.Color.Orange;
            this.line4.CustomVertAxis = Orange;
            this.line4.LinePen.Color = System.Drawing.Color.Orange;
            this.tChart1.Axes.Bottom.Labels.Font.Color = System.Drawing.Color.Orange;
            this.tChart1.Axes.Bottom.Grid.Visible = false;
            Orange.SetMinMax(0, 260);

            tChart1.Axes.Bottom.Scroll(0, false);
            tChart1.Axes.Bottom.Labels.DateTimeFormat = "HH:mm:ss";  //底部X轴时间格式
             this.tChart1.Axes.Bottom.AxisPen.Color = System.Drawing.Color.White; // 底部X轴线颜色

记得有点乱,改天来补。
1.关于实现放大部分图表效果,用自带的放大缩小,当数据量非常大的时候行不通,当一个图表上的数据点非常多了,放大缩小会很卡,要自己写代码实现。
2.根据鼠标位置实时显示对于同一个X轴多个Y轴上的点的数据。

你可能感兴趣的:(C#,TeeChart)