对于Tchart在C#中,如何让markstip展现出来的这两个系列的名称和标签值,当鼠标移到(Fo

2019-10-21 15:57发布

我有一个具有多个系列的TeeChart,我想用markstip显示出两个标签值和系列名称,当鼠标悬停。 我怎么能这样做? Chart.Tooltip1 = new Steema.TeeChart.Tools.MarksTip(Chart); Chart.Tooltip1.Style = MarksStyles.Labelvalue; Chart.Tooltip1.GetText += new Steema.TeeChart.(tooltip1_GetText);

Answer 1:

您可以使用系列的GetSeriesMark事件,例如:

  public partial class Form1 : Form
  {
    public Form1()
    {
      InitializeComponent();
      InitializeChart();
    }

    private void InitializeChart()
    {
      tChart1.Series.Add(new Steema.TeeChart.Styles.Bar()).FillSampleValues();

      tChart1[0].GetSeriesMark += Form1_GetSeriesMark;      
      tChart1[0].Marks.Visible = false;

      tChart1.Tools.Add(new Steema.TeeChart.Tools.MarksTip());
    }

    void Form1_GetSeriesMark(Steema.TeeChart.Styles.Series series, Steema.TeeChart.Styles.GetSeriesMarkEventArgs e)
    {
      e.MarkText = "X: " + series.XValues[e.ValueIndex].ToString() + ", Y: " + series.YValues[e.ValueIndex].ToString() + " - " + series.ToString();
    }    
  }


文章来源: For Tchart in C#, how to make markstip show out both series name and label value when mouse over
标签: c# teechart