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.
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.
| using System; | |
| using System.Data; | |
| using System.Configuration; | |
| using System.Collections; | |
| using System.Drawing; | |
| using System.Web; | |
| using System.Web.Security; | |
| using System.Web.UI; | |
| using System.Web.UI.WebControls; | |
| using System.Web.UI.WebControls.WebParts; | |
| using System.Web.UI.HtmlControls; | |
| using Telerik.Charting; | |
| using Telerik.WebControls; | |
| public partial class Default5 : System.Web.UI.Page | |
| { | |
| protected void Page_Load(object sender, EventArgs e) | |
| { | |
| if (!Page.IsPostBack) | |
| { | |
| CreateChart(RadChart1); | |
| CreateChart(RadChart2); | |
| } | |
| } | |
| private void CreateChart(RadChart radChart) | |
| { | |
| const double hourStep = 1 / 24.0; | |
| const double minuteStep = hourStep / 60; | |
| const double fiveMinuteStep = minuteStep * 5; | |
| double startTime = new DateTime(2008, 1, 1, 19, 0, 0, 0).ToOADate(); | |
| double endTime = new DateTime(2008, 1, 2, 7, 0, 0, 0).ToOADate(); | |
| radChart.ChartTitle.TextBlock.Text = "Trend Chart"; | |
| radChart.PlotArea.XAxis.AddRange(startTime, endTime, hourStep); | |
| radChart.PlotArea.YAxis.AutoScale = false; | |
| radChart.PlotArea.YAxis.MaxValue = 70; | |
| radChart.PlotArea.YAxis.MinValue = -70; | |
| radChart.PlotArea.YAxis.AxisLabel.TextBlock.Text = "UOM"; | |
| radChart.PlotArea.YAxis.AxisLabel.TextBlock.Visible = true; | |
| radChart.PlotArea.XAxis.AutoScale = false; | |
| Random r = new Random(); | |
| ChartSeries s = radChart.CreateSeries(radChart.ID + "Series 1", Color.Empty, Color.Empty, ChartSeriesType.Line); | |
| Int32 testResultId = 0; | |
| for (double currentTime = startTime; currentTime < endTime; currentTime += fiveMinuteStep) | |
| { | |
| testResultId += 1; | |
| ChartSeriesItem item = new ChartSeriesItem(); | |
| item.XValue = currentTime + (r.NextDouble() - 0.5) * fiveMinuteStep; | |
| item.YValue = 0 + (r.NextDouble() - 0.5) * 90; | |
| item.Label.ActiveRegion.Tooltip = "value=" + item.YValue + ", time=" + DateTime.FromOADate(item.XValue).ToShortTimeString(); | |
| item.Label.ActiveRegion.Url = "http://localhost/ChartTest/Default2.aspx?TestResultId=" + testResultId; | |
| item.Label.TextBlock.Text = " "; | |
| s.Appearance.LineSeriesAppearance.Color = Color.Blue; | |
| s.Items.Add(item); | |
| } | |
| s = radChart.CreateSeries(radChart.ID + "Series 2", Color.Empty, Color.Empty, ChartSeriesType.Line); | |
| testResultId = 0; | |
| for (double currentTime = startTime; currentTime < endTime; currentTime += fiveMinuteStep) | |
| { | |
| testResultId += 1; | |
| ChartSeriesItem item = new ChartSeriesItem(); | |
| item.XValue = currentTime + (r.NextDouble() - 0.5) * fiveMinuteStep; | |
| item.YValue = 0 + (r.NextDouble() - 0.5) * 90; | |
| item.Label.ActiveRegion.Tooltip = "value=" + item.YValue + ", time=" + DateTime.FromOADate(item.XValue).ToShortTimeString(); | |
| item.Label.ActiveRegion.Url = "http://localhost/ChartTest/Default2.aspx?TestResultId=" + testResultId; | |
| item.Label.TextBlock.Text = " "; | |
| s.Appearance.LineSeriesAppearance.Color = Color.Green; | |
| s.Items.Add(item); | |
| } | |
| } | |
| } | |
| <%@ 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> |