I have a chart on which I have added a single SeriesHotspot tool in order so that I can (i) display tooltips when users hover over points and (ii) so that I can display a popup as I hover of annotations.
The code to achieve this is something like this:
Code: Select all
Dim seriesHotspotTool As New Steema.TeeChart.Tools.SeriesHotspot(ch)
With seriesHotspotTool
.HelperScript = Steema.TeeChart.Tools.HotspotHelperScripts.Annotation
.HotspotCanvasIndex = 499
.MapAction = Steema.TeeChart.Styles.MapAction.Script
.MapElements = ""
End With
AddHandler seriesHotspotTool.GetHTMLMap, AddressOf hotspot_GetHTMLMap
Code: Select all
Private Sub hotspot_GetHTMLMap(ByVal sender As Steema.TeeChart.Tools.SeriesHotspot, ByVal e As Steema.TeeChart.Tools.SeriesHotspotEventArgs)
' Point tooltips
Dim XVal As String = e.PointPolygon.Title
XVal = Date.FromOADate(e.Series.XValues.Value(e.PointPolygon.ValueIndex)).ToString("dd/MM/yyyy HH:mm:ss")
e.PointPolygon.Title = "Date/Time: " & XVal & vbCrLf & _
"Value: " & e.Series.YValues.Value(e.PointPolygon.ValueIndex).ToString()
' Annotation tooltips
If ((e.Series Is WebChart.Chart(0)) AndAlso (e.PointPolygon.ValueIndex = 0)) Then
Dim mapElements As String = String.Empty
Dim i As Integer
Dim countOfAnnotations As Integer = annotations.Count
For Each annotation In annotations
If i = 0 Then
mapElements &= ">"
End If
mapElements &= "<AREA shape=""Poly"" " & _
"onmouseover=""ShowAnnotation('Annotation" & i.ToString() & "');"" " & _
"onmouseout=""ShowAnnotation('');"" " & _
"coords = """ & _
annotation.Left & "," & _
annotation.Top & "," & _
annotation.Left + annotation.Width & "," & _
annotation.Top & "," & _
annotation.Left + annotation.Width & "," & _
annotation.Top + annotation.Height & "," & _
annotation.Left & "," & _
annotation.Top + annotation.Height & _
IIf(i = countOfAnnotations - 1, """", """>")
i += 1
Next
If mapElements <> String.Empty Then
CType(sender, Steema.TeeChart.Tools.SeriesHotspot).MapElements = mapElements
End If
End If
End Sub
Code: Select all
<div>
<IMG>
<MAP>
<AREA shape="Poly" onmouseover="ShowAnnotation('Annotation 1');" onmouseout="ShowAnnotation('');" coords = "238,374,260,374,260,393,238,393">
<AREA shape="Poly" onmouseover="ShowAnnotation('Annotation 2');" onmouseout="ShowAnnotation('');" coords = "264,364,284,364,284,383,264,383">
<AREA shape="Poly" Title="Date/Time: 16/02/2009 23:30:00 Value: 220" coords=" 676,194,651,194,676,194,653,194,652,195,651,196,650,195,649,194,650,193,651,192,652,193,653,194">
<AREA shape="Poly" Title="Date/Time: 16/02/2009 22:30:00 Value: 220" coords=" 651,194,626,194,651,194,628,194,627,195,626,196,625,195,624,194,625,193,626,192,627,193,628,194">
<AREA shape="Poly" Title="Date/Time: 16/02/2009 21:30:00 Value: 220" coords=" 626,194,601,194,626,194,603,194,602,195,601,196,600,195,599,194,600,193,601,192,602,193,603,194">
<AREA shape="Poly" Title="Date/Time: 16/02/2009 20:30:00 Value: 220" coords=" 601,194,575,194,601,194,577,194,576,195,575,196,574,195,573,194,574,193,575,192,576,193,577,194">
</MAP>
</div>
Code: Select all
<div>
<IMG>
<MAP>
<AREA shape="Poly" onmouseover="ShowAnnotation('Annotation 1');" onmouseout="ShowAnnotation('');" coords = "238,374,260,374,260,393,238,393">
<AREA shape="Poly" onmouseover="ShowAnnotation('Annotation 2');" onmouseout="ShowAnnotation('');" coords = "264,364,284,364,284,383,264,383">
</MAP>
</div>
Code: Select all
Dim XVal As String = e.PointPolygon.Title
XVal = Date.FromOADate(e.Series.XValues.Value(e.PointPolygon.ValueIndex)).ToString("dd/MM/yyyy HH:mm:ss")
e.PointPolygon.Title = "Date/Time: " & XVal & vbCrLf & _
"Value: " & e.Series.YValues.Value(e.PointPolygon.ValueIndex).ToString()
Code: Select all
<AREA shape="Poly" coords=" 678,194,677,195,676,196,675,195,674,194,675,193,676,192,677,193,678,194">
<AREA shape="Poly" coords=" 676,194,651,194,676,194,653,194,652,195,651,196,650,195,649,194,650,193,651,192,652,193,653,194">
<AREA shape="Poly" coords=" 651,194,626,194,651,194,628,194,627,195,626,196,625,195,624,194,625,193,626,192,627,193,628,194">
Norman