Line Chart ToolTip Problem

Thread is closed for posting
2 posts, 0 answers
  1. Mike
    Mike avatar
    5 posts
    Member since:
    Oct 2007

    Posted 11 Jun 2008 Link to this post

    I have 2 charts on my web page (see attached code blocks).

    I can set a ToolTip and URL for each point in each series.

    This works fine if I only have one chart on my page.

    If I have two charts, then only the second charts ToolTips and URL links work.

    Any idea what I am doing wrong?

    Any help appreciated.

    Regards,

    Paul.

    1 using System;  
    2 using System.Data;  
    3 using System.Configuration;  
    4 using System.Collections;  
    5 using System.Drawing;  
    6 using System.Web;  
    7 using System.Web.Security;  
    8 using System.Web.UI;  
    9 using System.Web.UI.WebControls;  
    10 using System.Web.UI.WebControls.WebParts;  
    11 using System.Web.UI.HtmlControls;  
    12 using Telerik.Charting;  
    13 using Telerik.WebControls;  
    14  
    15 public partial class Default5 : System.Web.UI.Page  
    16 {  
    17     protected void Page_Load(object sender, EventArgs e)  
    18     {  
    19         if (!Page.IsPostBack)  
    20         {  
    21             CreateChart(RadChart1);  
    22             CreateChart(RadChart2);  
    23  
    24         }  
    25     }  
    26  
    27     private void CreateChart(RadChart radChart)  
    28     {  
    29         const double hourStep = 1 / 24.0;  
    30         const double minuteStep = hourStep / 60;  
    31         const double fiveMinuteStep = minuteStep * 5;  
    32  
    33         double startTime = new DateTime(2008, 1, 1, 19, 0, 0, 0).ToOADate();  
    34         double endTime = new DateTime(2008, 1, 2, 7, 0, 0, 0).ToOADate();  
    35  
    36         radChart.ChartTitle.TextBlock.Text = "Trend Chart";  
    37  
    38         radChart.PlotArea.XAxis.AddRange(startTime, endTime, hourStep);  
    39         radChart.PlotArea.YAxis.AutoScale = false;  
    40         radChart.PlotArea.YAxis.MaxValue = 70;  
    41         radChart.PlotArea.YAxis.MinValue = -70;  
    42  
    43         radChart.PlotArea.YAxis.AxisLabel.TextBlock.Text = "UOM";  
    44         radChart.PlotArea.YAxis.AxisLabel.TextBlock.Visible = true;  
    45  
    46         radChart.PlotArea.XAxis.AutoScale = false;  
    47  
    48         Random r = new Random();  
    49         ChartSeries s = radChart.CreateSeries(radChart.ID + "Series 1", Color.Empty, Color.Empty, ChartSeriesType.Line);  
    50  
    51         Int32 testResultId = 0;  
    52         for (double currentTime = startTime; currentTime < endTime; currentTime += fiveMinuteStep)  
    53         {  
    54             testResultId += 1;  
    55             ChartSeriesItem item = new ChartSeriesItem();  
    56             item.XValue = currentTime + (r.NextDouble() - 0.5) * fiveMinuteStep;  
    57             item.YValue = 0 + (r.NextDouble() - 0.5) * 90;  
    58  
    59             item.Label.ActiveRegion.Tooltip = "value=" + item.YValue + ", time=" + DateTime.FromOADate(item.XValue).ToShortTimeString();  
    60             item.Label.ActiveRegion.Url = "http://localhost/ChartTest/Default2.aspx?TestResultId=" + testResultId;  
    61             item.Label.TextBlock.Text = " ";  
    62             s.Appearance.LineSeriesAppearance.Color = Color.Blue;  
    63  
    64  
    65             s.Items.Add(item);  
    66         }  
    67  
    68         s = radChart.CreateSeries(radChart.ID + "Series 2", Color.Empty, Color.Empty, ChartSeriesType.Line);  
    69  
    70         testResultId = 0;  
    71         for (double currentTime = startTime; currentTime < endTime; currentTime += fiveMinuteStep)  
    72         {  
    73             testResultId += 1;  
    74             ChartSeriesItem item = new ChartSeriesItem();  
    75             item.XValue = currentTime + (r.NextDouble() - 0.5) * fiveMinuteStep;  
    76             item.YValue = 0 + (r.NextDouble() - 0.5) * 90;  
    77  
    78             item.Label.ActiveRegion.Tooltip = "value=" + item.YValue + ", time=" + DateTime.FromOADate(item.XValue).ToShortTimeString();  
    79             item.Label.ActiveRegion.Url = "http://localhost/ChartTest/Default2.aspx?TestResultId=" + testResultId;  
    80             item.Label.TextBlock.Text = " ";  
    81             s.Appearance.LineSeriesAppearance.Color = Color.Green;  
    82  
    83             s.Items.Add(item);  
    84         }  
    85  
    86     }  
    87  
    88 }  
    89  
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default5.aspx.cs" Inherits="Default5" %> 
     
    <%@ Register Assembly="RadChart.Net2" Namespace="Telerik.WebControls" TagPrefix="radC" %> 
    <%@ Register Assembly="RadChart.Net2" Namespace="Telerik.Charting" TagPrefix="radC" %> 
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     
    <html xmlns="http://www.w3.org/1999/xhtml" > 
    <head runat="server">  
        <title>Untitled Page</title> 
    </head> 
    <body> 
        <form id="form1" runat="server">  
        <div> 
            <radC:RadChart ID="RadChart1" runat="server"  Width="1082px" Height="807px" DefaultType="Line" > 
                <ChartTitle> 
                    <TextBlock Text="Trend Chart">  
                    </TextBlock> 
                    <Appearance> 
                        <FillStyle MainColor="Azure">  
                        </FillStyle> 
                    </Appearance> 
                </ChartTitle> 
                <Appearance TextQuality="AntiAlias">  
                    <FillStyle MainColor="Azure">  
                    </FillStyle> 
                </Appearance> 
                <PlotArea> 
                    <Appearance Dimensions-Margins="10%, 10%, 10%, 10%" > 
                        <FillStyle MainColor="Azure" SecondColor="">  
                        </FillStyle> 
                    </Appearance> 
                    <XAxis LayoutMode="Inside" AutoScale="False">  
                    <AxisLabel> 
                        <TextBlock Text="Time" Visible="True">  
                        </TextBlock> 
                    </AxisLabel> 
                        <Appearance ValueFormat="ShortTime">  
                            <LabelAppearance RotationAngle="45" Position-AlignedPosition="Top">                          
                            </LabelAppearance> 
                            <MajorGridLines Visible="False" /> 
                        </Appearance> 
                        <Items> 
                            <radC:ChartAxisItem> 
                                <Appearance Position-AlignedPosition="Top" RotationAngle="45">  
                                </Appearance> 
                            </radC:ChartAxisItem> 
                            <radC:ChartAxisItem Value="1">  
                                <Appearance Position-AlignedPosition="Top" RotationAngle="45">  
                                </Appearance> 
                            </radC:ChartAxisItem> 
                            <radC:ChartAxisItem Value="2">  
                                <Appearance Position-AlignedPosition="Top" RotationAngle="45">  
                                </Appearance> 
                            </radC:ChartAxisItem> 
                            <radC:ChartAxisItem Value="3">  
                                <Appearance Position-AlignedPosition="Top" RotationAngle="45">  
                                </Appearance> 
                            </radC:ChartAxisItem> 
                            <radC:ChartAxisItem Value="4">  
                                <Appearance Position-AlignedPosition="Top" RotationAngle="45">  
                                </Appearance> 
                            </radC:ChartAxisItem> 
                            <radC:ChartAxisItem Value="5">  
                                <Appearance Position-AlignedPosition="Top" RotationAngle="45">  
                                </Appearance> 
                            </radC:ChartAxisItem> 
                            <radC:ChartAxisItem Value="6">  
                                <Appearance Position-AlignedPosition="Top" RotationAngle="45">  
                                </Appearance> 
                            </radC:ChartAxisItem> 
                            <radC:ChartAxisItem Value="7">  
                                <Appearance Position-AlignedPosition="Top" RotationAngle="45">  
                                </Appearance> 
                            </radC:ChartAxisItem> 
                        </Items> 
                    </XAxis> 
                    <YAxis IsZeroBased="False" MaxValue="100" Step="10">  
                    </YAxis> 
                    <DataTable> 
                        <Appearance RenderType="PlotAreaRelative" TextHorizontalAlign="Center" TextVerticalAlign="Middle">  
                        </Appearance> 
                    </DataTable> 
                    <YAxis2 MinValue="1">  
                    </YAxis2> 
                    <EmptySeriesMessage Visible="True">  
                    </EmptySeriesMessage> 
                </PlotArea> 
                <Legend> 
                    <Appearance Position-AlignedPosition="None">  
                    </Appearance> 
                </Legend> 
            </radC:RadChart> 
          
            <radC:RadChart ID="RadChart2" runat="server"  Width="1082px" Height="807px" DefaultType="Line" > 
                <ChartTitle> 
                    <TextBlock Text="Trend Chart">  
                    </TextBlock> 
                    <Appearance> 
                        <FillStyle MainColor="Azure">  
                        </FillStyle> 
                    </Appearance> 
                </ChartTitle> 
                <Appearance TextQuality="AntiAlias">  
                    <FillStyle MainColor="Azure">  
                    </FillStyle> 
                </Appearance> 
                <PlotArea> 
                    <Appearance Dimensions-Margins="10%, 10%, 10%, 10%" > 
                        <FillStyle MainColor="Azure" SecondColor="">  
                        </FillStyle> 
                    </Appearance> 
                    <XAxis LayoutMode="Inside" AutoScale="False">  
                    <AxisLabel> 
                        <TextBlock Text="Time" Visible="True">  
                        </TextBlock> 
                    </AxisLabel> 
                        <Appearance ValueFormat="ShortTime">  
                            <LabelAppearance RotationAngle="45" Position-AlignedPosition="Top">                          
                            </LabelAppearance> 
                            <MajorGridLines Visible="False" /> 
                        </Appearance> 
                        <Items> 
                            <radC:ChartAxisItem> 
                                <Appearance Position-AlignedPosition="Top" RotationAngle="45">  
                                </Appearance> 
                            </radC:ChartAxisItem> 
                            <radC:ChartAxisItem Value="1">  
                                <Appearance Position-AlignedPosition="Top" RotationAngle="45">  
                                </Appearance> 
                            </radC:ChartAxisItem> 
                            <radC:ChartAxisItem Value="2">  
                                <Appearance Position-AlignedPosition="Top" RotationAngle="45">  
                                </Appearance> 
                            </radC:ChartAxisItem> 
                            <radC:ChartAxisItem Value="3">  
                                <Appearance Position-AlignedPosition="Top" RotationAngle="45">  
                                </Appearance> 
                            </radC:ChartAxisItem> 
                            <radC:ChartAxisItem Value="4">  
                                <Appearance Position-AlignedPosition="Top" RotationAngle="45">  
                                </Appearance> 
                            </radC:ChartAxisItem> 
                            <radC:ChartAxisItem Value="5">  
                                <Appearance Position-AlignedPosition="Top" RotationAngle="45">  
                                </Appearance> 
                            </radC:ChartAxisItem> 
                            <radC:ChartAxisItem Value="6">  
                                <Appearance Position-AlignedPosition="Top" RotationAngle="45">  
                                </Appearance> 
                            </radC:ChartAxisItem> 
                            <radC:ChartAxisItem Value="7">  
                                <Appearance Position-AlignedPosition="Top" RotationAngle="45">  
                                </Appearance> 
                            </radC:ChartAxisItem> 
                        </Items> 
                    </XAxis> 
                    <YAxis IsZeroBased="False" MaxValue="100" Step="10">  
                    </YAxis> 
                    <DataTable> 
                        <Appearance RenderType="PlotAreaRelative" TextHorizontalAlign="Center" TextVerticalAlign="Middle">  
                        </Appearance> 
                    </DataTable> 
                    <YAxis2 MinValue="1">  
                    </YAxis2> 
                    <EmptySeriesMessage Visible="True">  
                    </EmptySeriesMessage> 
                </PlotArea> 
                <Legend> 
                    <Appearance Position-AlignedPosition="None">  
                    </Appearance> 
                </Legend> 
            </radC:RadChart> 
          
        </div> 
        </form> 
    </body> 
    </html> 
     
  2. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 12 Jun 2008 Link to this post

    Hi Mike,

    Indeed there was such problem with older versions of the control -- we would suggest you to update to the latest version of RadChart and you should not experience the erroneous behavior any more.


    Greetings,
    Manuel
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top