.NET Framework Bookmark and Share   
 index > Chart Controls for .NET Framework > Pie Chart ToolTip Not Working Need Help
 

Pie Chart ToolTip Not Working Need Help

Hi Guys, i have a small problem. i am using ado.net to retrieve my data and that works fine, i need to display a tool tip for each series in my pie chart, i get the tool tip but its only displaying the last entry in my table as the tooltip, heres my code, please help

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Not Page.IsPostBack Then
            Using myConnection As New SqlConnection
                myConnection.ConnectionString = ConfigurationManager.ConnectionStrings("TempConn").ConnectionString

                Dim myCommand As New SqlCommand
                myCommand.Connection = myConnection
                myCommand.CommandText = "SELECT CategoryName, color, COUNT(*) as ProductCount FROM Products p INNER JOIN Categories c ON c.CategoryID = p.CategoryID GROUP BY CategoryName,color ORDER BY CategoryName,color"

                myConnection.Open()
                Dim myReader As SqlDataReader = myCommand.ExecuteReader()

                myReader.Close()
                myReader = myCommand.ExecuteReader()
                If myReader.HasRows = True Then

                    'start the loop 
                    While myReader.Read
                        Chart1.Series("Series1").Points.AddY(myReader.Item("ProductCount").ToString)
                        Chart1.Series("Series1").ToolTip = myReader.Item("CategoryName").ToString & " " & myReader.Item("ProductCount").ToString
                        ' chtCategoriesProductCount.Series(0).Points.Item(i).ToolTip = myReader.Item("color").ToString & " " & myReader.Item("ProductCount").ToString
                        'Chart1.Series("Series1").Color = System.Drawing.ColorTranslator.FromHtml(myReader.Item("color").ToString)
                    End While

                End If

                myReader.Close()
                myConnection.Close()
            End Using
        End If

        Chart1.Series("Series1").ChartType = SeriesChartType.Pie  ' Set the bar width
        Chart1.Series("Series1")("PointWidth") = "0.5" ' Show data points labels
        Chart1.Series("Series1").IsValueShownAsLabel = True ' Set data points label style
        Chart1.Series("Series1")("BarLabelStyle") = "Center" ' Show chart as 3D
        Chart1.ChartAreas("ChartArea1").Area3DStyle.Enable3D = True   ' Draw chart as 3D Cylinder
        Chart1.Series("Series1")("DrawingStyle") = "Cylinder"

    End Sub
nivash_ns

Add the tooltip to the point, not the whole series.

	Dim dp As DataPoint
	While myReader.Read
		dp = New DataPoint(0, myReader.Item("ProductCount"))
		dp.ToolTip = myReader.Item("CategoryName").ToString & " " & myReader.Item("ProductCount").ToString
		Chart1.Series("Series1").Points.Add(dp)
	End While
  • Marked As Answer bynivash_ns Friday, September 04, 2009 2:07 PM
  •  
sipla

Add the tooltip to the point, not the whole series.

	Dim dp As DataPoint
	While myReader.Read
		dp = New DataPoint(0, myReader.Item("ProductCount"))
		dp.ToolTip = myReader.Item("CategoryName").ToString & " " & myReader.Item("ProductCount").ToString
		Chart1.Series("Series1").Points.Add(dp)
	End While
  • Marked As Answer bynivash_ns Friday, September 04, 2009 2:07 PM
  •  
sipla
Dude, you a genius that totally sorted out my problem

Thanks again
nivash_ns
that worked out quite fine, but just on another note, do you know how i could use like custom tool-tips, because i would like the tool tip size changed and be a different the tool tip be a different color
nivash_ns

You can use google to search for other answers

Custom Search

More Threads

• Using MS Chart assemblies in ASP.NET Application without installation
• Can I use the Chart Control & Samples With VB.net Express?
• Simple Pie Chart Display
• Stacked bar label text?
• How to drawing dynamic Electrocardiogram (ECG)in Chart Control?
• Deploying charts with older Framework versions
• In the Crystal Report, change the data displayed at runtime
• Creating a simple chart by two columns.
• HOW TO ADD THE RADOR CHART AND HOW TO ENTER THE DATA IN THE RADOR CHART
• Chart.SaveImage throws exception when chart has two scale breaks