0
votes

The code I have loops through a datagridview based on the column selected and for each value in that row creates a point on a series

This is the code I've tried:

       System.Windows.Forms.DataVisualization.Charting.Series FirstVallSeries = new System.Windows.Forms.DataVisualization.Charting.Series
        {
            Name = SelectedColumn + "-" + FilterVal1.Text,
            //   Color = Color.DarkBlue,
            IsVisibleInLegend = true,
            IsValueShownAsLabel = true,


            ChartType = (SeriesChartType)Enum.Parse(typeof(SeriesChartType), ChartTypeComboBox.Text, true),



        };



        foreach (string e in distinctArray)
        {
            for (intRow = 0; intRow < dataGridView1.Rows.Count;)
            {


                if (dataGridView1[SelectedColumn, intRow].Value.ToString() == e)
                {
                    if (String.IsNullOrEmpty(Convert.ToString(dataGridView1[SelectedColumn, intRow].Value)) == false)
                    {


                        firstval++;

                    }
                }
                intRow++;
            }

            DataPoint dp = new DataPoint();
            dp.SetValueXY(e, firstval);
            dp.ToolTip = string.Format("{0}, {1}", e, firstval);

            FirstVallSeries.Points.Add(dp);


                   firstval = 0;

But when I run the App and mouse over each point in the series within the chart, the tool tip doesn't show up.

I can see the values, but no tooltip.

1
The code works fine. You need to wait a little (hover without moving) until they show up. Or show us more about how your points are created. But it looks perfectly fine to me.. What chartype do you use? Hovering precisely over a point is a little hard for Line or Curve charts or even small point makers.. - TaW
After i create the series i add it to chart1, which is blank. Ill check the code again, but is there anything i need to enable for the chart1? - Sewder
No, every point with a ToolTip will show it automatically. you can also show a Series based ToolTip instead, provided the chart keywords are good enough.. But, no, nothin to enable or add. Do you see the DataPoints? What ChartType do you use ?? - TaW
I used a column chart, then switched to a point chart. Still nothing. The datapoints show up but no tooltip. - Sewder
Na, ca 1 second will do. But you need to hit the DataPoint. You may try setting the MarkerSize a little larger..: FirstVallSeries.MarkerSize = 20; - TaW

1 Answers

0
votes

Try

dp.ToolTip = "#SERIESNAME : X=#VALX, Y=#VALY";

There are a list of special keywords the tooltip understands to get it to display your values (see here). In your case you probably only care about #VALX and #VALY. This should make it show up even if you aren't exactly on the marker point.