teechart 上的 关于Custom axes的一段代码

来源:互联网 发布:阿里云dnf 编辑:程序博客网 时间:2024/06/03 15:57

private void LoadChart() {
tChart1.Dock = DockStyle.Fill;
Steema.TeeChart.Axis axis1 = new Steema.TeeChart.Axis(false, false,tChart1.Chart);//新建坐标轴
Steema.TeeChart.Styles.Line line1 = new
Steema.TeeChart.Styles.Line(tChart1.Chart);
Steema.TeeChart.Styles.Line line2 = new
Steema.TeeChart.Styles.Line(tChart1.Chart);
tChart1.Axes.Custom.Add(axis1);//添加到custom坐标轴组中

line1.FillSampleValues(100);
line2.FillSampleValues(100);
line2.HorizAxis = Steema.TeeChart.Styles.HorizontalAxis.Both;
tChart1.Axes.Top.Visible = true;
tChart1.Axes.Top.Labels.Visible = false;
line1.CustomVertAxis = axis1;

axis1.MinimumOffset = 20;
tChart1.Axes.Left.MaximumOffset = 20;
tChart1.Axes.Custom[0].StartPosition = 0;
tChart1.Axes.Custom[0].EndPosition = 62.46;
tChart1.Axes.Left.StartPosition = 70.86;
tChart1.Axes.Left.EndPosition = 100;
}

private void AdjustGap() {
double chartTop = (double)tChart1.Axes.Top.Position;
double chartBottom = (double)tChart1.Axes.Bottom.Position;
double chartHeight = chartBottom - chartTop;
double interAxesGap = 10;
double interAxesGapPercent = (interAxesGap / chartHeight) * 100;

tChart1.Axes.Custom[0].StartPosition = 0;
tChart1.Axes.Custom[0].EndPosition = 66.66 - interAxesGapPercent;
tChart1.Axes.Left.StartPosition = 66.66 + interAxesGapPercent;
tChart1.Axes.Left.EndPosition = 100;
}

private void Form1_Resize(object sender, System.EventArgs e) {
AdjustGap();
}

原创粉丝点击