解决DevExpress XtraCharts轴标签重叠问题(代码示例)
作者:zhuhm 来源:本站原创 浏览:Loading...次 发布时间:2012-07-24 评论:0条
本文主要介绍两种方法来解决标签过长时导致的重叠问题。第一种方法是通过标签的Angle属性将标签旋转。此外,我们建立您启用Antialiasing属性,有助于流畅地绘制标签文本。第二种方法是使用轴标签的Staggered属性。
注:从DXperience12.1开始,已经解决XtraCharts轴标签的重叠问题。
using System;
using System.Windows.Forms;
using DevExpress.XtraCharts;
// ...
namespace AxisLabelsResolveOverlapping {
public partial class Form1: Form {
public Form1() {
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e) {
// Create an empty chart.
ChartControl chartControl1 = new ChartControl();
// Create a series and add points to it.
Series series1 = new Series("Series 1", ViewType.Bar);
series1.Points.Add(new SeriesPoint("First Argument", 10.5678));
series1.Points.Add(new SeriesPoint("Second Argument", 12.5798));
series1.Points.Add(new SeriesPoint("Third Argument", 11.6483));
series1.Points.Add(new SeriesPoint("Fourth Argument", 12.3154));
series1.Points.Add(new SeriesPoint("Fifth Argument", 12.7865));
// Add the series to the chart.
chartControl1.Series.Add(series1);
// Hide the legend (optional).
chartControl1.Legend.Visible = false;
// Cast the chart's diagram to the XYDiagram type,
// to access its axes.
XYDiagram diagram = (XYDiagram)chartControl1.Diagram;
// Make the X-axis labels staggered.
diagram.AxisX.Label.Staggered = true;
// Add a prefix to the Y-axis labels, and rotate them.
diagram.AxisY.Label.BeginText = "Axis value = ";
diagram.AxisY.Label.Angle = -30;
diagram.AxisY.Label.Antialiasing = true;
// Add the chart to the form.
chartControl1.Dock = DockStyle.Fill;
this.Controls.Add(chartControl1);
}
}
}
Imports Microsoft.VisualBasic
Imports System
Imports System.Windows.Forms
Imports DevExpress.XtraCharts
' ...
Namespace AxisLabelsResolveOverlapping
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
' Create an empty chart.
Dim chartControl1 As New ChartControl()
' Create a series and add points to it.
Dim series1 As New Series("Series 1", ViewType.Bar)
series1.Points.Add(New SeriesPoint("First Argument", 10.5678))
series1.Points.Add(New SeriesPoint("Second Argument", 12.5798))
series1.Points.Add(New SeriesPoint("Third Argument", 11.6483))
series1.Points.Add(New SeriesPoint("Fourth Argument", 12.3154))
series1.Points.Add(New SeriesPoint("Fifth Argument", 12.7865))
' Add the series to the chart.
chartControl1.Series.Add(series1)
' Hide the legend (optional).
chartControl1.Legend.Visible = False
' Cast the chart's diagram to the XYDiagram type,
' to access its axes.
Dim diagram As XYDiagram = CType(chartControl1.Diagram, XYDiagram)
' Make the X-axis labels staggered.
diagram.AxisX.Label.Staggered = True
' Add a prefix to the Y-axis labels, and rotate them.
diagram.AxisY.Label.BeginText = "Axis value = "
diagram.AxisY.Label.Angle = -30
diagram.AxisY.Label.Antialiasing = True
' Add the chart to the form.
chartControl1.Dock = DockStyle.Fill
Me.Controls.Add(chartControl1)
End Sub
End Class
End Namespace
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [http://www.devexpresscn.com/]
本文地址:http://www.devexpresscn.com/DevExpress-Resources/Documentation-165.html
评论列表
暂无评论
请谈谈你的看法 请使用IE或者Firefox浏览器,暂不支持Chrome!
慧都控件网为DevExpress界面控件的中国地区唯一正式授权经销商,正版控件销售公司,授权代理商,经销商及合作伙伴。
电话:400-700-1020
023-66090381
邮箱:sales@evget.com
相关资源
- XtraGrid可以导出到一个PDF文件吗?
- XtraGrid是线程安全的吗?
- 如何强制Grid单元格显示提示 即使单元格内容可见
- 通过ToolTipController如何实现工具提示控件
- 如何完全禁止导出为XPS
- PivotChart如何从图表中隐藏不必要的系列
- ASPxGridView能否实现多表头显示和统计
- 如何使用Silverlight报表设计器
- XtraReports控件创建主从报表的两种方法
- 如何使用子报表创建主从报表
- XtraCharts如何创建并排式甘特图
- 在XAF中如何使用仪表
- 如何更改LayoutPanel中Pin按钮的工具提示“自动隐藏”
- DevExpress VCL发布v12.1
- DXCharts如何绑定到数据图表系列
- DXv2 WPF 2012.1.5试用体验
- XAF如何验证数据
- GridView导出到Excel中不能导出自定义日期
- XtraGrid能否只计算可见数据行的数目
- XtraGrid 中文字符导出到Excel时不能显示