如何让TeeChart.Net自定义轴正常显示在图表区域
2013-08-22 16:52
519 查看
TeeChart.Net是一款功能全面、性能稳定的图表控件,受深受用户好评。在使用TeeChart.Net的过程中还是会遇到各种难题。今天为大家解决TeeChart.Net添加自定义轴的问题,如果遇到自定义轴的标签和标题都超出图表区域,比如出现在图表标题上面。应该如何解决呢?
大多数情况下,我们并不知道问题出在什么地方。如遇到这种情况,就只有一步一步操作,找出问题,最后再解决问题。
控件版本:TeeChart.Net v2013.4
Axis customAxis;
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
colorGrid1 = new ColorGrid(tChart1.Chart);
colorGrid1.FillSampleValues();
customAxis = new Axis(tChart1.Chart);
tChart1.Axes.Custom.Add(customAxis);
customAxis.Horizontal = true;
colorGrid1.HorizAxis = HorizontalAxis.Both;
colorGrid1.CustomHorizAxis = customAxis;
tChart1.Draw();
customAxis.OtherSide = true;
tChart1.Panel.MarginUnits = PanelMarginUnits.Pixels;
tChart1.Panel.MarginTop = 50;
tChart1.Header.CustomPosition = true;
tChart1.Header.Left = tChart1.Width / 2;
tChart1.Header.Top = 0;
button1.Click +=button1_Click;
}
结果:经过这样操作后,单个轴标签在图表区域显示。
colorGrid1.CustomHorizAxis = customAxis;
结果:图表制作顺利进行,但是按钮上的标签消失。
呼出customAxis.labels.Clear()工具,再添加另外的标签,新标签中仍然有许多轴标签在顶部。
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
colorGrid1 = new ColorGrid(tChart1.Chart);
colorGrid1.FillSampleValues();
colorGrid1.HorizAxis = HorizontalAxis.Both;
AddCustomLabels(tChart1.Axes.Top);
tChart1.Draw();
tChart1.Panel.MarginUnits = PanelMarginUnits.Pixels;
tChart1.Panel.MarginTop = 50;
tChart1.Header.CustomPosition = true;
tChart1.Header.Left = tChart1.Width / 2;
tChart1.Header.Top = 0;
button1.Click += button1_Click;
}
private void AddCustomLabels(Axis a)
{
a.Labels.Items.Clear();
a.Labels.Items.Add(colorGrid1.XValues[5], "Point 1");
}
Axis customAxis;
Steema.TeeChart.Styles.ColorGrid colorGrid1;
Steema.TeeChart.Styles.ColorGrid auxiliarygrid;
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
colorGrid1 = new ColorGrid(tChart1.Chart);
auxiliarygrid = new ColorGrid(tChart1.Chart);
colorGrid1.FillSampleValues();
customAxis = new Axis(tChart1.Chart);
tChart1.Axes.Custom.Add(customAxis);
customAxis.Horizontal = true;
colorGrid1.HorizAxis = HorizontalAxis.Bottom;
auxiliarygrid.CustomHorizAxis = customAxis;
auxiliarygrid.ShowInLegend = false;
AddCustomLabels(customAxis);
tChart1.Draw();
customAxis.OtherSide = true;
tChart1.Panel.MarginUnits = PanelMarginUnits.Pixels;
tChart1.Panel.MarginTop = 50;
tChart1.Header.CustomPosition = true;
tChart1.Header.Left = tChart1.Width / 2;
tChart1.Header.Top = 0;
}
总结:在第四个步骤,可以看出该图表是一个系列下多自定义轴图表,所以在系列中需要分配每一个轴,由于,前面三个步骤没有如此做,导致轴标签无法全部正常显示在图表区域;第五、第六两个步骤中,移除顶轴标签,再增加了另外的标签,并对多轴进行了分配,所以轴标签显示正常。
原文地址:http://www.evget.com/zh-CN/Info/catalog/19422.html
大多数情况下,我们并不知道问题出在什么地方。如遇到这种情况,就只有一步一步操作,找出问题,最后再解决问题。
操作环境:
系统:Windows 7(64位)控件版本:TeeChart.Net v2013.4
一、设置一个不同的顶边
结果:只能在图表标题上方添加一定空间,坐标轴标签依旧在图表上方,问题没有解决。二、修改代码,在顶部添加水平自定义轴,增加顶部边缘,重新定位图表标题
代码:Axis customAxis;
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
colorGrid1 = new ColorGrid(tChart1.Chart);
colorGrid1.FillSampleValues();
customAxis = new Axis(tChart1.Chart);
tChart1.Axes.Custom.Add(customAxis);
customAxis.Horizontal = true;
colorGrid1.HorizAxis = HorizontalAxis.Both;
colorGrid1.CustomHorizAxis = customAxis;
tChart1.Draw();
customAxis.OtherSide = true;
tChart1.Panel.MarginUnits = PanelMarginUnits.Pixels;
tChart1.Panel.MarginTop = 50;
tChart1.Header.CustomPosition = true;
tChart1.Header.Left = tChart1.Width / 2;
tChart1.Header.Top = 0;
button1.Click +=button1_Click;
}
结果:经过这样操作后,单个轴标签在图表区域显示。
三、继续添加下面代码
colorGrid1.HorizAxis = HorizontalAxis.Both;colorGrid1.CustomHorizAxis = customAxis;
结果:图表制作顺利进行,但是按钮上的标签消失。
四、精简代码
只添加:colorGrid1.HorizAxis = HorizontalAxis.Both;呼出customAxis.labels.Clear()工具,再添加另外的标签,新标签中仍然有许多轴标签在顶部。
五、不在使用自定义轴,而使用默认按钮坐标轴和图表顶轴
添加以下代码:private void InitializeChart()
{
tChart1.Aspect.View3D = false;
colorGrid1 = new ColorGrid(tChart1.Chart);
colorGrid1.FillSampleValues();
colorGrid1.HorizAxis = HorizontalAxis.Both;
AddCustomLabels(tChart1.Axes.Top);
tChart1.Draw();
tChart1.Panel.MarginUnits = PanelMarginUnits.Pixels;
tChart1.Panel.MarginTop = 50;
tChart1.Header.CustomPosition = true;
tChart1.Header.Left = tChart1.Width / 2;
tChart1.Header.Top = 0;
button1.Click += button1_Click;
}
private void AddCustomLabels(Axis a)
{
a.Labels.Items.Clear();
a.Labels.Items.Add(colorGrid1.XValues[5], "Point 1");
}
六、使用辅助,分配自定义轴
用下面的代码完成操作:Axis customAxis;
Steema.TeeChart.Styles.ColorGrid colorGrid1;
Steema.TeeChart.Styles.ColorGrid auxiliarygrid;
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
colorGrid1 = new ColorGrid(tChart1.Chart);
auxiliarygrid = new ColorGrid(tChart1.Chart);
colorGrid1.FillSampleValues();
customAxis = new Axis(tChart1.Chart);
tChart1.Axes.Custom.Add(customAxis);
customAxis.Horizontal = true;
colorGrid1.HorizAxis = HorizontalAxis.Bottom;
auxiliarygrid.CustomHorizAxis = customAxis;
auxiliarygrid.ShowInLegend = false;
AddCustomLabels(customAxis);
tChart1.Draw();
customAxis.OtherSide = true;
tChart1.Panel.MarginUnits = PanelMarginUnits.Pixels;
tChart1.Panel.MarginTop = 50;
tChart1.Header.CustomPosition = true;
tChart1.Header.Left = tChart1.Width / 2;
tChart1.Header.Top = 0;
}
总结:在第四个步骤,可以看出该图表是一个系列下多自定义轴图表,所以在系列中需要分配每一个轴,由于,前面三个步骤没有如此做,导致轴标签无法全部正常显示在图表区域;第五、第六两个步骤中,移除顶轴标签,再增加了另外的标签,并对多轴进行了分配,所以轴标签显示正常。
原文地址:http://www.evget.com/zh-CN/Info/catalog/19422.html
相关文章推荐
- 如何解决ASP.NET中中文不能正常显示问题?
- 如何解决ASP.NET中中文不能正常显示问题
- Asp.net如何使用access数据库做profile实现按照区域显示相应语言功能
- 在ASP.NET MVC 如何在Response.StatusCode = 404的同时,显示友好的自定义错误页面
- [Asp.Net]如何在GridView将数字显示成金额格式或自定义格式呢?
- TeeChart Pro .Net 教程---教程2 - 图表显示属性
- 在没有安装vs.net或vs6.0的IE上无法正常显示OWC图表问题的解决方案
- 如何解决ASP.NET中中文不能正常显示问题?
- 如何解决vs2003 asp.net树控件不能正常显示的问题
- [VB.NET]请问如何在dataGrid中显示搜索结果?
- 第四章 Spring.Net 如何管理您的类___自定义对象行为
- Asp.net TreeView 显示不正常。 解决方法
- 如何在WordPress中显示自定义头像
- 如何解决自定义404页面在IE等浏览器中无法显示问题
- [转贴]如何在ASP.NET中用OWC绘制图表
- (DB ,sqlserver2005,tips)如何获取用户自定义的触发器的内容(在sqlserver2005树形菜单没有显示)
- echarts 画的图表在ie9以下不能正常显示
- jquery实现在网页指定区域显示自定义右键菜单效果
- Flash图表控件FusionCharts如何自定义图表上的垂直线
- iOS开发 - 友盟分享(自定义分享)如何让新浪分享显示蓝色文字,其他平台内容不显示链接