欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

c# 設(shè)置TeeChart控件的提示文本

 更新時(shí)間:2020年11月11日 11:04:00   作者:一只獨(dú)行的猿  
這篇文章主要介紹了c# 如何設(shè)置TeeChart控件的提示文本,幫助大家更好的理解和使用c#,感興趣的朋友可以了解下

  使用第三方Steema的TeeChart控件,設(shè)置鼠標(biāo)放在某一線條點(diǎn)上,顯示某一點(diǎn)的數(shù)據(jù)標(biāo)簽問題(虛線型十字光標(biāo)基準(zhǔn)線,放在線上顯示對應(yīng)點(diǎn)的二維坐標(biāo)軸數(shù)據(jù)數(shù)據(jù)),調(diào)用InitTeeChartTipTools方法即可:

/// <summary>
/// TeeChart線條的指示工具
/// </summary>
Steema.TeeChart.Tools.CursorTool cursorTool;
/// <summary>
/// 鼠標(biāo)指示顯示的文本
/// </summary>
private Steema.TeeChart.Tools.Annotation annotation;
/// <summary>
/// 初始化線條的提示工具信息
/// </summary>
private void InitTeeChartTipTools(Steema.TeeChart.TChart tChart)
{
  //以線形式對標(biāo)坐標(biāo)軸
  cursorTool = new Steema.TeeChart.Tools.CursorTool(tChart.Chart);
  cursorTool.Style = Steema.TeeChart.Tools.CursorToolStyles.Both;
  cursorTool.Pen.Style = System.Drawing.Drawing2D.DashStyle.Dash;
  cursorTool.Pen.Color = Color.Black;
  cursorTool.FollowMouse = true;
  cursorTool.Change += CursorTool_Change;
  //設(shè)置提示文本的信息
  annotation = new Steema.TeeChart.Tools.Annotation(tChart.Chart);
  annotation.Shape.Font.Name = "Arial";
  annotation.Shape.Font.Size = 12;
  annotation.Shape.Pen.Visible = true;
  annotation.Shape.Shadow.Visible = false;
  annotation.Shape.ShapeStyle = Steema.TeeChart.Drawing.TextShapeStyle.Rectangle;
  annotation.Position = Steema.TeeChart.Tools.AnnotationPositions.LeftBottom;
  annotation.TextAlign = StringAlignment.Center;

  for (int i = 0; i < tChart.Series.Count; i++)
  {
    tChart.Series[i].MouseEnter += Line_MouseEnter;
    tChart.Series[i].MouseLeave += Line_MouseLeave;
  }

  tChart.MouseLeave += TChart_MouseLeave;
  tChart.MouseEnter += TChart_MouseEnter;
}

/// <summary>
/// 鼠標(biāo)進(jìn)入TeeChart的事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void TChart_MouseEnter(object sender, EventArgs e)
{
  cursorTool.Chart=tChartCurve.Chart;
}

/// <summary>
/// 鼠標(biāo)離開TeeChart的事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void TChart_MouseLeave(object sender, EventArgs e)
{
  cursorTool.Chart = null;
}


/// <summary>
/// 當(dāng)鼠標(biāo)進(jìn)入線條時(shí),將TeeChart的cursorTool工具指示的線條設(shè)置為對應(yīng)的線條
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Line_MouseEnter(object sender, EventArgs e)
{
  cursorTool.Series = sender as Steema.TeeChart.Styles.Series;
}

/// <summary>
/// 當(dāng)鼠標(biāo)離開線條時(shí),將TeeChart的cursorTool工具指示的線條設(shè)置為null
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Line_MouseLeave(object sender, EventArgs e)
{
  cursorTool.Series = null;
}
/// <summary>
/// 鼠標(biāo)指示工具改變事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CursorTool_Change(object sender, Steema.TeeChart.Tools.CursorChangeEventArgs e)
{
  try
  {
    Steema.TeeChart.Tools.CursorTool cursor = sender as Steema.TeeChart.Tools.CursorTool;
    if (cursor != null && cursor.Series != null)
    {
      annotation.Text = string.Format("({0},{1})", cursor.XValue.ToString("f1"), cursor.YValue.ToString("f1"));
      annotation.Top = cursor.Series.GetVertAxis.CalcYPosValue(InterpolateLineSeries(cursor.Series, cursor.XValue));
      annotation.Left = tChartCurve.Axes.Bottom.CalcXPosValue(cursor.XValue);
      annotation.Top -= 20;//將文本放在鼠標(biāo)上方
      SizeF size = this.CreateGraphics().MeasureString(annotation.Text,
        new Font(annotation.Shape.Font.Name, annotation.Shape.Font.Size));
      if (annotation.Left + size.Width + 12 >= annotation.Chart.Width)
      {
        annotation.Left -= (int)size.Width + 12;//防止文本標(biāo)簽超出右邊界而看不全
      }
    }
    else
    {
      //將其設(shè)置到控件外部
      annotation.Text = "";
      annotation.Top = annotation.Chart.Height + 5;
      annotation.Left = annotation.Chart.Width + 5;
    }
  }
  catch (Exception ex)
  {
    annotation.Text = ex.Message;
    annotation.Top = 5;
    annotation.Left = 5;
  }
}
/// <summary>
/// 計(jì)算某一點(diǎn)的Y值坐標(biāo)
/// </summary>
/// <param name="series">曲線</param>
/// <param name="xvalue">對應(yīng)的X軸的值</param>
/// <returns>計(jì)算得到的對應(yīng)的Y軸的值</returns>
private double InterpolateLineSeries(Steema.TeeChart.Styles.Series series, double xvalue)
{
  try
  {
    int index;
    for (index = series.FirstVisibleIndex; index <= series.LastVisibleIndex; 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;
  }
}

以上就是c# 設(shè)置TeeChart控件的提示文本的詳細(xì)內(nèi)容,更多關(guān)于c# 設(shè)置提示文本的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • C# 服務(wù)器發(fā)送郵件失敗實(shí)例分析

    C# 服務(wù)器發(fā)送郵件失敗實(shí)例分析

    在本篇文章里小編給大家?guī)硪黄P(guān)于C# 服務(wù)器發(fā)送郵件失敗實(shí)例內(nèi)容,需要的朋友們可以學(xué)習(xí)下。
    2020-03-03
  • C#如何通過RFC連接sap系統(tǒng)

    C#如何通過RFC連接sap系統(tǒng)

    這篇文章主要為大家詳細(xì)介紹了C#如何通過RFC連接sap系統(tǒng)的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-04-04
  • C#獲取計(jì)算機(jī)名,IP,MAC信息實(shí)現(xiàn)代碼

    C#獲取計(jì)算機(jī)名,IP,MAC信息實(shí)現(xiàn)代碼

    利用C#獲取計(jì)算機(jī)名,IP,MAC信息如何實(shí)現(xiàn),一直是網(wǎng)友們的頭疼問題,本文整理了一些實(shí)現(xiàn)代碼,需要的朋友可以參考下
    2012-11-11
  • C#基礎(chǔ)知識之FileStream

    C#基礎(chǔ)知識之FileStream

    C#中FileStream對象表示在磁盤或網(wǎng)絡(luò)路徑上指向文件的流。可以使用FileStream 類對文件系統(tǒng)上的文件進(jìn)行讀取、寫入、打開、關(guān)閉等。下面我們就來詳細(xì)探討下
    2016-07-07
  • C#微信開發(fā)之發(fā)送模板消息

    C#微信開發(fā)之發(fā)送模板消息

    這篇文章主要為大家詳細(xì)介紹了C#微信開發(fā)之發(fā)送模板消息的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-06-06
  • 在Unity中實(shí)現(xiàn)簡單的偽時(shí)間同步

    在Unity中實(shí)現(xiàn)簡單的偽時(shí)間同步

    這篇文章主要介紹了在Unity中實(shí)現(xiàn)簡單的偽時(shí)間同步,為什么說是偽同步呢,因?yàn)閮H僅是獲取的數(shù)據(jù)庫所在服務(wù)器的系統(tǒng)時(shí)間,分享給大家,有需要的小伙伴可以參考下
    2015-03-03
  • 解析C#設(shè)計(jì)模式之單例模式

    解析C#設(shè)計(jì)模式之單例模式

    這篇文章主要介紹了C#設(shè)計(jì)模式之單例模式的相關(guān)資料,幫助大家更好的理解和學(xué)習(xí)c# 設(shè)計(jì)模式的內(nèi)容,感興趣的朋友可以了解下
    2020-12-12
  • c#的異或運(yùn)算符介紹

    c#的異或運(yùn)算符介紹

    這篇文章介紹了c#的異或運(yùn)算符,有需要的朋友可以參考一下
    2013-11-11
  • C# partial關(guān)鍵字說明

    C# partial關(guān)鍵字說明

    C# 中可以將類、結(jié)構(gòu)或接口的定義拆分到兩個(gè)或多個(gè)源文件中,在類聲明前添加partial關(guān)鍵字即可,通過本文給大家介紹C# partial關(guān)鍵字說明,需要的朋友參考下
    2016-02-02
  • C#中dynamic的使用方法及應(yīng)用場景

    C#中dynamic的使用方法及應(yīng)用場景

    在 C# 編程中,dynamic 類型是一個(gè)非常特殊的類型,它在編譯時(shí)并不會(huì)進(jìn)行類型檢查,而是在運(yùn)行時(shí)才進(jìn)行類型解析,本文將詳細(xì)講解 dynamic 的使用方法、優(yōu)缺點(diǎn)以及一些實(shí)際應(yīng)用場景,需要的朋友可以參考下
    2024-08-08

最新評論