【发布时间】:2013-09-27 02:38:17
【问题描述】:
我想通过 TeeChart 实现一个 .Net 控件,如下所示: 1. 控件包含多个图表,所有图表共享comman垂直轴。如果一个图表被缩放,其他图表应该同步缩放; 2. 每个图表包含多条水平线,每条水平线对应一个唯一的水平轴。
【问题讨论】:
我想通过 TeeChart 实现一个 .Net 控件,如下所示: 1. 控件包含多个图表,所有图表共享comman垂直轴。如果一个图表被缩放,其他图表应该同步缩放; 2. 每个图表包含多条水平线,每条水平线对应一个唯一的水平轴。
【问题讨论】:
请查看All Features\Welcome !\Axes\Opaque zones 的功能演示中的示例。功能演示是随 TeeChart 安装一起提供的程序,包括组件支持的主要功能示例。
如果你有几个TCharts,并且你想同步它们,你可以为它处理两个图表上的Scroll事件。即:
public Form1()
{
InitializeComponent();
CreateChart();
InitializeChart();
}
Steema.TeeChart.TChart tChart1, tChart2;
private void CreateChart()
{
tChart1 = new Steema.TeeChart.TChart();
this.Controls.Add(tChart1);
tChart2 = new Steema.TeeChart.TChart();
this.Controls.Add(tChart2);
tChart1.Dock = DockStyle.Left;
tChart2.Dock = DockStyle.Right;
}
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart2.Aspect.View3D = false;
Line line1 = new Line(tChart1.Chart);
line1.FillSampleValues();
Line line2 = new Line(tChart2.Chart);
line2.DataSource = line1;
tChart1.Scroll += new EventHandler(tChart1_Scroll);
tChart2.Scroll += new EventHandler(tChart2_Scroll);
}
void tChart1_Scroll(object sender, EventArgs e)
{
tChart2.Axes.Left.SetMinMax(tChart1.Axes.Left.Minimum, tChart1.Axes.Left.Maximum);
tChart2.Axes.Bottom.SetMinMax(tChart1.Axes.Bottom.Minimum, tChart1.Axes.Bottom.Maximum);
}
void tChart2_Scroll(object sender, EventArgs e)
{
tChart1.Axes.Left.SetMinMax(tChart2.Axes.Left.Minimum, tChart2.Axes.Left.Maximum);
tChart1.Axes.Bottom.SetMinMax(tChart2.Axes.Bottom.Minimum, tChart2.Axes.Bottom.Maximum);
}
【讨论】: