简体   繁体   English

在mschart(ASP.net C#)中将工具提示分配给点

[英]assigning tool tip to point in mschart (ASP.net C#)

I need to display the value in tool tip on moving the mouse over the data point.It displays the value but value which is displayed in not in proper data point. 我需要在将鼠标移到数据点上时在工具提示中显示值。它显示的是值,但显示的值不在正确的数据点中。 yvalue and axis lable collection is yvalue和轴标签集合为
(237.71 , 12:13:58 ), (238.53 , 12:28:58), (239.95 , 12:58:58 ), (238.25 , 1:13:57), (240.17 , 1:29:01), (241.24 , 1:58:57), (237.71,12:13:58),(238.53,12:28:58),(239.95,12:58:58),(238.25,1:13:57),(240.17,1:29:01), (241.24,1:58:57),
(243.24 , 2:13:57), (243.47 , 2:28:58), (242.05 , 2:58:57), For example on moving mouse over 237.71 data point it displays 238.53. (243.24,2:13:57),(243.47,2:28:58),(242.05,2:58:57),例如在将鼠标移到237.71数据点上时显示238.53。 and on moving mouse over 241.24 data point it displays 242.05. 将鼠标移到241.24数据点上时,将显示242.05。 Please give any suggestion. 请提出任何建议。

Chart1.Visible = true;
    string startDate = "", EndDate = "";
    Chart1.BackColor = System.Drawing.Color.FromArgb(211, 223, 240); //"#D3DFF0"
    Chart1.ChartAreas[0].AxisX.MajorGrid.Enabled = false;
    Chart1.ChartAreas[0].AxisX.MinorGrid.Enabled = false;
    Chart1.Legends.Add("R Phase");
    Chart1.Series.Add("R Phase");
    Chart1.Series[0].BorderColor = System.Drawing.Color.Transparent;
    Chart1.ChartAreas[0].AxisX.Title = "Time";
    Chart1.ChartAreas[0].AxisY.Title = "Value";
    Chart1.Series[0].ChartType = SeriesChartType.Line;
    Chart1.Series[0].BorderWidth = 3;
    Chart1.Series[0].Color = Color.Maroon;
    Chart1.Series[0].Points.DataBindXY(AxisLabelGrid1, yValueGrid1);
    Chart1.Series[0].IsValueShownAsLabel = true;
    Chart1.Series[0].IsVisibleInLegend = true;
    Chart1.ChartAreas[0].AxisX.IntervalType = DateTimeIntervalType.Auto;
    Chart1.ChartAreas[0].AxisX.Interval = 1.0;
    //Chart1.Series[0].ToolTip = "#VALX - #VALY";
    int i = 0;
    foreach (var pt in Chart1.Series[0].Points)
    {
        string date = GridView1.Rows[i].Cells[0].Text;
       pt.ToolTip = "Value :" + GridView1.Rows[i].Cells[1].Text + "\n Phase : Y Phase";
        if (i == 0)
        {
            startDate = date;
        }
        EndDate = date;
        pt.MarkerColor = System.Drawing.Color.Maroon;
        pt.MarkerSize = 10;
        pt.MarkerStyle = MarkerStyle.Circle;
       // pt.ToolTip = "Value :" + pt.YValues[0].ToString() + "\n Phase : R Phase";
        i++;
    }

    Title tit = new Title("Line chart from " + startDate + " to " + EndDate, Docking.Top, new Font("Garamond", 14), Color.Black);
    Chart1.Titles.Add(tit);

I had a similar problem before. 我以前也有类似的问题。

Chart1.Series[0].IsXValueIndexed = false; 
Chart1.Series[0].XValueType = ChartValueType.Time;

would solve the problem. 会解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM