TChart的使用
TChart的使用
1.设置TChart的3d属性
Tchart.Aspect.View3D = true;
2.设置TChart y轴的Label显示样式
tChart.Axes.Left.Labels.Style = Steema.TeeChart.AxisLabelStyle.Auto;
3.设置TChart x轴的Label显示样式
tChart.Axes.Bottom.Labels.Style = Steema.TeeChart.AxisLabelStyle.Mark;
4.设置TChart Label的角度
tChart.Axes.Bottom.Labels.Angle = 45;
5.设置Tchart的Legend显示
TChart.Legend.Visible = true;
6.设置TChart Legend显示的位置
TChart.Legend.Alignment = Steema.TeeChart.LegendAlignments.Bottom;
7.设置Line的不同颜色显示
line1.ColorEach = true;
8.设置Bar的不同颜色显示
bar.ColorEach =true;
7.TChart的点击事件
ClickSeries(object sender, Steema.TeeChart.Styles.Series s, int valueIndex, MouseEventArgs e)
3D显示时,要设置好TChart.Aspect下的Chart3DPercent,Elevation等属性的值,否则点击视觉上看到的TChart的部分而无法触发该事件。造成这种情况的原因是3d投影的问题。在这里不详细讨论。
一个实现2D直线图,2D柱状图,2D饼图,3D直线图,3D柱状图,3D饼图切换的例子
思路是:先在TChart中添加3中类型的Series(line,bar,pie),然后通过控制TChart是否3D显示来实现
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
int type = comboBox1.SelectedIndex;
if (type > 2)
{
type -= 3;
}
for (int k = 0; k < comboBox1.Items.Count / 2; k++)
{
tChart1[k].Clear();
}
if (this.comboBox1.SelectedIndex > 2)
{
//设置tChart13D显示
tChart1.Aspect.View3D = true;
switch (comboBox1.SelectedIndex)
{
//设置3D饼图,该设置点击饼图的所有地方都能触发ClickSeries事件
case 5:
this.tChart1.Aspect.Elevation = 288;
this.tChart1.Aspect.Orthogonal = false;
this.tChart1.Aspect.Perspective = 0;
this.tChart1.Aspect.Rotation = 360;
break;
//设置3D直线图和3D柱状图,该设置点击线图,和柱状图的所有地方都能触发ClickSeries事件
default:
this.tChart1.Aspect.Chart3DPercent = 15;
this.tChart1.Aspect.Orthogonal = false;
this.tChart1.Aspect.Perspective = 15;
this.tChart1.Aspect.Rotation = 345;
this.tChart1.Aspect.Elevation = 345;
this.tChart1.Aspect.Orthogonal = true;
this.tChart1.Legend.TopLeftPos = 2;
break;
}
}
else
{
tChart1.Aspect.View3D = false;
}
foreach (DataRow row in ConstructDataSource(GetDataTable()).Rows)
{
tChart1[type].Add(double.Parse(row["指标值"].ToString()), row["指标名"].ToString());
}
tChart1[type].CheckDataSource();
tChart1.Legend.Series = tChart1[type];
tChart1.Legend.Alignment = Steema.TeeChart.LegendAlignments.Bottom;
}
posted on 2010-05-11 22:36 These days 阅读(6040) 评论(1) 编辑 收藏 举报