I have a webchart which used to have tooltips working. There is a 'toggle' for this chart that switches it from being a line chart to a column chart and vice-versa. Initially I was just simply data binding the chart to a data set - the legend and tooltips were both working.
Yesterday I had to switch from databinding to a data set to creating series then adding them to the chart. I did not touch any of the settings for the tooltips and for some reason they have disappeared.
I have stopped the code from running just after all the series have been added and can confirm that Chart.Tooltips.FormatString = "<DATA_VALUE>" so it strikes me as odd that the data value isn't actually being picked up anymore.
The chart is contained within a user control. Here is the markup for the user control:
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="ChartMain.ascx.vb" Inherits="ChartMain" %><%@ Register Assembly="Infragistics35.WebUI.UltraWebChart.v8.3" Namespace="Infragistics.WebUI.UltraWebChart" TagPrefix="igchart" %><%@ Register Assembly="Infragistics35.WebUI.UltraWebChart.v8.3" Namespace="Infragistics.UltraChart.Resources.Appearance" TagPrefix="igchartprop" %><%@ Register Assembly="Infragistics35.WebUI.UltraWebChart.v8.3" Namespace="Infragistics.UltraChart.Data" TagPrefix="igchartdata" %><div> <asp:Panel ID="MainControlContainer" runat="server"> <div style="text-align: left; float: left; width: 50px; position: relative; vertical-align: top;"> <asp:UpdateProgress AssociatedUpdatePanelID="ChartPanel" runat="server" ID="TrendChartProgress"> <ProgressTemplate> <div style="width: 100%; text-align: left; vertical-align: top; height: 33px;"> <asp:Image ID="WindowLoadingAnim" runat="server" ImageUrl="~/Images/windowload.gif" /> </div> </ProgressTemplate> </asp:UpdateProgress> </div> <div style="text-align: right; float: right; width: 50%; height: 33px; vertical-align: baseline; position: relative;"> <br /> <asp:ImageButton ID="Settings" runat="server" ImageUrl="~/Images/Gear_32.gif"></asp:ImageButton> <asp:ImageButton ID="OpenDetails" runat="server" ImageUrl="~/Images/magnifier.png" /> </div> <asp:UpdatePanel ID="ChartPanel" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false"> <ContentTemplate> <igchart:UltraChart ID="Chart" runat="server" BorderColor="Black" BorderWidth="0px" ChartType="LineChart" EmptyChartText="Data Not Available." Version="8.3" BackgroundImageFileName=""> <Legend BorderThickness="0" Location="Bottom" Visible="True"> <Margins Bottom="1" Left="1" Right="1" Top="1" /> </Legend> <ColorModel AlphaLevel="150" ColorBegin="SlateGray" ColorEnd="DarkRed" ModelStyle="CustomLinear"> </ColorModel> <Axis> <PE ElementType="None" Fill="Cornsilk" /> <X LineThickness="1" TickmarkInterval="0" TickmarkStyle="Smart" Visible="True"> <MajorGridLines AlphaLevel="255" Color="Gainsboro" DrawStyle="Dot" Thickness="1" Visible="True" /> <MinorGridLines AlphaLevel="255" Color="LightGray" DrawStyle="Dot" Thickness="1" Visible="False" /> <Labels Font="Verdana, 7pt" FontColor="DimGray" HorizontalAlign="Near" ItemFormatString="<ITEM_LABEL>" Orientation="VerticalLeftFacing" VerticalAlign="Center"> <SeriesLabels Font="Verdana, 7pt" FontColor="DimGray" FormatString="" HorizontalAlign="Near" Orientation="VerticalLeftFacing" VerticalAlign="Center"> <Layout Behavior="Auto"> </Layout> </SeriesLabels> <Layout Behavior="Auto"> </Layout> </Labels> </X> <Y LineThickness="1" TickmarkInterval="100" TickmarkStyle="Smart" Visible="True"> <MajorGridLines AlphaLevel="255" Color="Gainsboro" DrawStyle="Dot" Thickness="1" Visible="True" /> <MinorGridLines AlphaLevel="255" Color="LightGray" DrawStyle="Dot" Thickness="1" Visible="False" /> <Labels Font="Verdana, 7pt" FontColor="DimGray" HorizontalAlign="Far" ItemFormatString="<DATA_VALUE:00.##>" Orientation="Horizontal" VerticalAlign="Center"> <SeriesLabels Font="Verdana, 7pt" FontColor="DimGray" FormatString="" HorizontalAlign="Far" Orientation="Horizontal" VerticalAlign="Center"> <Layout Behavior="Auto"> </Layout> </SeriesLabels> <Layout Behavior="Auto"> </Layout> </Labels> </Y> <Y2 LineThickness="1" TickmarkInterval="100" TickmarkStyle="Smart" Visible="False"> <MajorGridLines AlphaLevel="255" Color="Gainsboro" DrawStyle="Dot" Thickness="1" Visible="True" /> <MinorGridLines AlphaLevel="255" Color="LightGray" DrawStyle="Dot" Thickness="1" Visible="False" /> <Labels Font="Verdana, 7pt" FontColor="Gray" HorizontalAlign="Near" ItemFormatString="<DATA_VALUE:00.##>" Orientation="Horizontal" VerticalAlign="Center" Visible="False"> <SeriesLabels Font="Verdana, 7pt" FontColor="Gray" FormatString="" HorizontalAlign="Near" Orientation="Horizontal" VerticalAlign="Center"> <Layout Behavior="Auto"> </Layout> </SeriesLabels> <Layout Behavior="Auto"> </Layout> </Labels> </Y2> <X2 LineThickness="1" TickmarkInterval="0" TickmarkStyle="Smart" Visible="False"> <MajorGridLines AlphaLevel="255" Color="Gainsboro" DrawStyle="Dot" Thickness="1" Visible="True" /> <MinorGridLines AlphaLevel="255" Color="LightGray" DrawStyle="Dot" Thickness="1" Visible="False" /> <Labels Font="Verdana, 7pt" FontColor="Gray" HorizontalAlign="Far" ItemFormatString="<ITEM_LABEL>" Orientation="VerticalLeftFacing" VerticalAlign="Center" Visible="False"> <SeriesLabels Font="Verdana, 7pt" FontColor="Gray" FormatString="" HorizontalAlign="Far" Orientation="VerticalLeftFacing" VerticalAlign="Center"> <Layout Behavior="Auto"> </Layout> </SeriesLabels> <Layout Behavior="Auto"> </Layout> </Labels> </X2> <Z LineThickness="1" TickmarkInterval="0" TickmarkStyle="Smart" Visible="False"> <MajorGridLines AlphaLevel="255" Color="Gainsboro" DrawStyle="Dot" Thickness="1" Visible="True" /> <MinorGridLines AlphaLevel="255" Color="LightGray" DrawStyle="Dot" Thickness="1" Visible="False" /> <Labels Font="Verdana, 7pt" FontColor="DimGray" HorizontalAlign="Near" ItemFormatString="<ITEM_LABEL>" Orientation="Horizontal" VerticalAlign="Center" Visible="False"> <SeriesLabels Font="Verdana, 7pt" FontColor="DimGray" HorizontalAlign="Near" Orientation="Horizontal" VerticalAlign="Center"> <Layout Behavior="Auto"> </Layout> </SeriesLabels> <Layout Behavior="Auto"> </Layout> </Labels> </Z> <Z2 LineThickness="1" TickmarkInterval="0" TickmarkStyle="Smart" Visible="False"> <MajorGridLines AlphaLevel="255" Color="Gainsboro" DrawStyle="Dot" Thickness="1" Visible="True" /> <MinorGridLines AlphaLevel="255" Color="LightGray" DrawStyle="Dot" Thickness="1" Visible="False" /> <Labels Font="Verdana, 7pt" FontColor="Gray" HorizontalAlign="Near" ItemFormatString="" Orientation="Horizontal" VerticalAlign="Center" Visible="False"> <SeriesLabels Font="Verdana, 7pt" FontColor="Gray" HorizontalAlign="Near" Orientation="Horizontal" VerticalAlign="Center"> <Layout Behavior="Auto"> </Layout> </SeriesLabels> <Layout Behavior="Auto"> </Layout> </Labels> </Z2> </Axis> <Effects> <Effects> <igchartprop:GradientEffect /> </Effects> </Effects> <Tooltips Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" FormatString="<DATA_VALUE>" Display="MouseMove" /> </igchart:UltraChart> </ContentTemplate> </asp:UpdatePanel> </asp:Panel></div>
Here is the code used to generate the series for the line chart:
Public Function GenerateChartSeries(ByVal itemID As Integer, ByVal seriesType As SeriesType, ByVal seriesLabel As String, ByVal nullHandling As Infragistics.UltraChart.Shared.Styles.NullHandling) As NumericTimeSeries Dim addPoint As Boolean Dim seriesTypeName As String Dim dv As New DataView Dim value As Double Dim chartSeries As New NumericTimeSeries Dim dataPoint As NumericTimeDataPoint
seriesTypeName = GetSeriesTypeName(seriesType)
' If we have data. If Not _chartData Is Nothing AndAlso _chartData.Rows.Count > 0 Then dv.Table = _chartData
' Apply a filter for the specified metric. dv.RowFilter = itemID = " & itemID.ToString"
' If we have rows in the view after configuring the filter, we must create a series of data points. If dv.Count > 0 Then chartSeries.Label = dv.Item(0).Item("ItemName") & ": " & seriesLabel
If dv.Table.Rows.Count > 0 Then For index As Integer = 0 To dv.Count - 1 addPoint = False
If IsDBNull(dv.Item(index).Item(seriesTypeName)) OrElse dv.Item(index).Item(seriesTypeName) Is Nothing Then If nullHandling = Infragistics.UltraChart.Shared.Styles.NullHandling.Zero Then value = 0 addPoint = True End If Else value = dv.Item(index).Item(seriesTypeName) addPoint = True End If
If addPoint Then dataPoint = New NumericTimeDataPoint(dv.Item(index).Item("EventDate"), value, dv.Item(index).Item("EventDate"), True) chartSeries.Points.Add(dataPoint) End If Next End If
End If End If
Return chartSeries End Function
And I'm calling the above code like this (for populating the line chart only):
Private Sub PopulateChart() Dim chartSeries As Infragistics.UltraChart.Resources.Appearance.NumericTimeSeries Dim itemIDs As String()
itemIDs = Me.ItemIDs.Split(",")
For index As Integer = 0 To itemIDs.Length - 1 chartSeries = _chartData.GetChartSeries(CType(itemIDs(index), Integer), SeriesType.Actual, Languages.TranslateText("Actual"), Me._handlingType)
If Not chartSeries Is Nothing AndAlso chartSeries.Points.Count > 0 Then Chart.Series.Add(chartSeries) End If Next
If Chart.ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.ColumnChart Then Chart.Data.SwapRowsAndColumns = True Else Chart.Data.SwapRowsAndColumns = False End If End Sub
Nevermind. Figured it out! The problem was coming from where I was creating the datapoint that got added to the series. I had to set the last parameter to False.
So, I changed this:
dataPoint = New NumericTimeDataPoint(dv.Item(index).Item("EventDate"), value, dv.Item(index).Item("EventDate"), True)
To this:
dataPoint = New NumericTimeDataPoint(dv.Item(index).Item("EventDate"), value, dv.Item(index).Item("EventDate"), False)
And the tooltips are working again :)