C# Teechart 鼠标悬停 显示数据

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication2
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
            this.tChart1.Series[0].Add(1, 2);
            this.tChart1.Series[0].Add(2, 6);
            this.tChart1.Series[0].Add(6, 3);
        }
        private double xval;
        private void cursorTool1_Change(object sender, Steema.TeeChart.Tools.CursorChangeEventArgs e)
        {
            try
            {
                xval = e.XValue;
                tChart1.Header.Text = "";
                for (int i = 0; i < tChart1.Series.Count; i++)
                    if (tChart1.Series[i] is Steema.TeeChart.Styles.Custom)
                    {
                        tChart1.Header.Text += tChart1.Series[i].Title + ": Y(" + e.XValue.ToString("0.00") + ")= ";
                        tChart1.Header.Text += InterpolateLineSeries(tChart1.Series[i] as Steema.TeeChart.Styles.Custom, e.XValue).ToString("0.00") + "\r\n";
                    }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }

        private double InterpolateLineSeries(Steema.TeeChart.Styles.Custom series, double xvalue)
        {
            return InterpolateLineSeries(series, series.FirstVisibleIndex, series.LastVisibleIndex, xvalue);
        }

        /// <summary>
        /// Calculate y=y(x) for arbitrary x. Works fine only for line series with ordered x values.
        /// </summary>
        /// <param name="series"></param>
        /// <param name="firstindex"></param>
        /// <param name="lastindex"></param>
        /// <param name="xvalue"></param>
        /// <returns>y=y(xvalue) where xvalue is arbitrary x value.</returns>
        private double InterpolateLineSeries(Steema.TeeChart.Styles.Custom series, int firstindex, int lastindex, double xvalue)
        {
            try
            {
                int index;
                for (index = firstindex; index <= lastindex; index++)
                {
                    if (index == -1 || series.XValues.Value[index] > xvalue) break;
                }
                // safeguard
                if (index < 1) index = 1;
                else if (index >= series.Count) index = series.Count - 1;
                // y=(y2-y1)/(x2-x1)*(x-x1)+y1
                double dx = series.XValues[index] - series.XValues[index - 1];
                double dy = series.YValues[index] - series.YValues[index - 1];
                if (dx != 0.0) return dy * (xvalue - series.XValues[index - 1]) / dx + series.YValues[index - 1];
                else return 0.0;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return 0.0;
            }
        }

    }
}

  

时间: 2024-08-30 17:22:03

C# Teechart 鼠标悬停 显示数据的相关文章

内容过长显示省略号 鼠标悬停显示

<!doctype html> <html> <head> <style type="text/css"> //css控制内容过长显示省略号和悬停时显示全部内容 .li1 { list-style:none; width:200px; white-space:nowrap; text-overflow:ellipsis; -o-text-overflow:ellipsis; overflow: hidden; margin-top:5px

鼠标悬停显示CSS3动画边框

效果体验:http://keleyi.com/keleyi/phtml/css3/14.htm 以下是代码: 1 <!DOCTYPE html> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta charset="utf-8" /> 5 <title>CSS3鼠标悬停显示动画边框-柯乐义</title><base

jQuery鼠标悬停显示提示信息窗体

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>鼠标悬停显示提示信息窗体</titl

jQuery鼠标悬停显示提示信息窗口

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>鼠标悬停显示提示信息窗口</title&g

鼠标悬停显示透明文字内容

我总结了一个css规律,凡是变化的css特效,总是在不同状态之间转换,只要规定好不同状态下的样式就好了 <!DOCTYPE html> <html> <head> <meta charset="gb2312" /> <title>鼠标悬停显示透明文字内容</title> <style> .xuanting{ width:220px; margin:0 auto; height:240px; backgr

EasyUI的Datagrid鼠标悬停显示单元格内容

功能描述:table鼠标悬停显示单元格内容 1.js函数 1 function hoveringShow(value) { 2 return "<span title='" + value + "'>" + value + "</span>"; 3 } 2.调用函数 1 <table id="mydatagrid" style="width:100%;height:96%"&g

jquery实现鼠标悬停显示大图(个人随笔)

HTML代码: <!doctype html> <html> <head> <meta charset="utf-8"> <title>鼠标悬停图片放大</title> <link type="text/css" rel="stylesheet" href="stye/style.css"/> <script type="tex

实现Bootstrap导航条可点击和鼠标悬停显示下拉菜单

使用Bootstrap导航条组件时,如果你的导航条带有下拉菜单,那么这个带下拉菜单的导航在点击时只会浮出下拉菜单,它本身的href属性会失效,也就是失去了超链接功能,这并不是我想要的,我希望导航条的链接可以正常打开它的链接,但又需要下拉菜单功能,开始折腾~ 首先解决带下拉菜单的导航条可以点击问题,下拉菜单效果是JS实现的,分析bootstrap.js文件发现,Bootstrap把下拉菜单写成了一个JQuery插件,在dropdown代码段中找到了关键的几句: // APPLY TO STANDA

鼠标悬停显示说明层的案例

示例1: //在鼠标显示一个层,该层的内容为div1的内容 function showTip(e,content,ifhave){      //if(!e) e = window.event;//alert(e);if(ifhave==null || ifhave=='0')return;//var div1 = document.getElementById('divdisplay'); //将要弹出的层 //div1.innerHTML="备注:"+content;var div