[DevExpress]ChartControl之自定义Tooltip示例

关键代码:

        /// <summary>
        /// 自定义ChartControl的Tooltip
        /// </summary>
        /// <param name="chart">ChartControl</param>
        /// <param name="e">MouseEventArgs</param>
        /// <param name="tooltip">ToolTipController</param>
        /// <param name="tooltipTitle">ToolTipController的Title</param>
        /// <param name="paramter">委托</param>
        public static void CustomToolTip(this ChartControl chart, MouseEventArgs e, ToolTipController tooltip, string tooltipTitle, System.Func<string, double[], string> paramter)
        {
            ChartHitInfo _hitInfo = chart.CalcHitInfo(e.X, e.Y);
            SeriesPoint _point = _hitInfo.SeriesPoint;
            if (_point != null)
            {
                string _msg = paramter(_point.Argument, _point.Values);
                tooltip.ShowHint(_msg, tooltipTitle);
            }
            else
            {
                tooltip.HideHint();
            }
        }

使用代码:

        private void chartControl1_MouseMove(object sender, MouseEventArgs e)
        {
            ChartControl _curChart = sender as ChartControl;
            _curChart.CustomToolTip(e, toolTipController1, "交易详情", (agr, values) =>
            {
                return string.Format("时间:{0}\r\n金额:{1}", agr, values[0]);
            });
        }

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

运行效果:

时间: 2024-10-10 22:29:54

[DevExpress]ChartControl之自定义Tooltip示例的相关文章

[DevExpress]ChartControl之时间轴示例

关键代码: using System; using System.Data; using System.Windows.Forms; using DevExpress.XtraCharts; namespace DevExpressChart { public partial class winDateTime : Form { public winDateTime() { InitializeComponent(); } private void winDateTime_Load(object

[DevExpress]ChartControl之创建Strip示例

关键代码: /// <summary> /// 创建Strip /// </summary> /// <param name="chart">ChartControl</param> /// <param name="strip">Strip</param> /// <param name="stripLable">Strip文字</param> //

DevExpress XtraGrid网格控件示例六:自定义合并单元格

假设 "Order Date" 列中包含日期/时间值.如果视图的GridOptionsView.AllowCellMerge选项设置为true,若相邻两个单元格值是日期/时间值的话,这两个相邻单元格便会合并.下面的代码介绍了如何合并例单元格的日期部分,要覆盖默认的单元格合并机制,需要处理一下GridView.CellMerge事件. C# using DevExpress.XtraGrid.Views.Grid; // ... private void gridView1_CellMe

DevExpress XtraGrid网格控件示例三:获取当前处于编辑状态的值

使用下面的示例代码,以获得当前编辑的值. C# 1 string editingValue; 2 if(gridControl1.KeyboardFocusView.IsEditing) 3 editingValue = gridControl1.KeyboardFocusView.EditingValue.ToString(); DevExpress XtraGrid网格控件示例三:获取当前处于编辑状态的值,布布扣,bubuko.com

DevExpress ChartControl大数据加载时有哪些性能优化方法

DevExpress ChartControl加载大数据量数据时的性能优化方法有哪些? 关于图表优化,可从以下几个方面解决: 1.关闭不需要的可视化的元素(如LineMarkers, Labels等): Series.View.LineMarkerOptions.Visible =false. 2. 关闭图表的滚动与缩放功能,手动调整范围,这样将大大减少所需计算的个数. 3. 将 ChartControl.RefreshDataOnRepaint属性设为false 4. 将 ChartContr

01_MUI之Boilerplate中:HTML5示例,动态组件,自定义字体示例,自定义字体示例,图标字体示例

?? 1安装HBuilder5.0.0,安装后的界面截图如下: 2 按照https://www.muicss.com/docs/v1/css-js/boilerplate-html中的说明,创建上图的Boilerplate.html: 3 代码内容如下: <!-- 作者:[email protected] 时间:2015-08-02 描述:使用MUI,您可以先简单地直接将以下CSS和JS加入到您的HTML文档中: <link href="//cdn.muicss.com/mui-0.

DevExpress XtraGrid网格控件示例四:初始化新建行的单元格

下面的代码显示了如何利用ColumnView.InitNewRow事件初始化新创建行的PurchaseDate字段: C# 1 using DevExpress.XtraGrid.Views.Grid; 2 private void gridView1_InitNewRow(object sender, InitNewRowEventArgs e) { 3 DevExpress.XtraGrid.Views.Grid.GridView view = sender as Grid.GridView

DevExpress XtraGrid网格控件示例五:验证终端用户输入的数据

本示例中禁用了无效的“colBudget”列单元格赋值.单元格值应该大于零且小于1,000,000.BaseView.ValidatingEditor事件处理检查输入值的有效性.如果出现无效的单元格赋值,BaseView.InvalidValueException事件会显示异常消息框.在这样情况下,调用GridView.HideEditor方法以便放弃所做的更改. C# 1 using DevExpress.XtraEditors.Controls; 2 // ... 3 private voi

DevExpress XtraGrid网格控件示例七:列过滤

Example 1: 下面的代码示例,展示了如何过滤开头字母为F的海运国家.利用ColumnFilterInfo 对象创建所需的过滤器.然后,为其分配GridColumn.FilterInfo属性. C# 1 using DevExpress.XtraGrid.Columns; 2 gridView1.Columns["ShipCountry"].FilterInfo = 3 new ColumnFilterInfo("[ShipCountry] LIKE 'F%'"