Hello,
I want to generate a customized tooltip for time entries. What I've done so far is:
Add the RenderLabel (copied from some sample code):
View.Chart.Tooltips.FormatString = "<GanttToolTip>"; Hashtable myHashTable = new Hashtable(); myHashTable.Add("GanttToolTip", new RenderLabel()); //Attach the Hash table to the Chart View.Chart.LabelHash = myHashTable;
This works, however, I'm not sure what a good way is to actually identify the individual tasks within IRender.ToString. I currently set GanttTimeEntry.PercentComplete to a value that serves as a unique identifier (because I don't otherwise use PercentComplete) and that I can then read within IRender.ToString by looking at context["PERCENT_VALUE"], but this seems to be a somewhat ugly solution and perhaps I want to actually use PercentComplete in the future.
What is a better way to pass my own context information into the IRenderLabel or is there a different, better approach to do customized tooltips for each TimeEntry? The context variable does not seem to contain any other key I can set.
I also tried setting
View.Chart.Tooltips.FormatString = "<ITEM_LABEL>";
and
GanttTimeEntry.Label
but the tooltip then seems to be generated from GanttItem.Key, not GanttTimeEntry.Label...
Thanks!
You can find all possible string formats values in:
http://help.infragistics.com/Help/NetAdvantage/NET/2008.3/CLR2.0/html/Chart_Label_Formatting.html
For the cases that these are not enough is used IRenderLabel interface, so you way of doing this is good.
I had this problem as well and found the above reply from Teodor Taushanov absolutely useless. He clearly hadn't read the user's email.
On another forum I found a much more helpful reply from Infragistics David Negley in which he solves the problem with the sample code below. I attach here for anyone else that wishes to have a custom tooltip associated with their gantt TimeEntry.
using System;using System.Collections;using System.Data;using System.Web;using System.Web.UI;using Infragistics.UltraChart.Data;using Infragistics.UltraChart.Shared.Styles;using Infragistics.UltraChart.Resources;using Infragistics.UltraChart.Resources.Appearance;public partial class _Default : Page, IRenderLabel{ protected void Page_Load(object sender, EventArgs e) { this.UltraChart1.ChartType = ChartType.GanttChart; this.UltraChart1.Tooltips.FormatString = "<MY_LABEL>"; Hashtable labelHash = new Hashtable(); labelHash.Add("MY_LABEL", this); this.UltraChart1.LabelHash = labelHash; GanttSeries series1 = new GanttSeries("Series 1"); GanttItem item1 = series1.Items.Add("Item 1"); GanttTimeEntry timeEntry1 = item1.Times[item1.Times.Add(DateTime.Now, DateTime.Now.AddDays(1))]; this.UltraChart1.Series.Add(series1); } string IRenderLabel.ToString(Hashtable context) { DateTime startTime = (DateTime)context["START_TIME"]; DateTime endTime = (DateTime)context["END_TIME"]; int seriesIndex = (int)context["DATA_ROW"]; int itemIndex = (int)context["DATA_COLUMN"]; int timeEntryIndex = (int)context["TIME_ENTRY_INDEX"]; GanttSeries series = this.UltraChart1.Series[seriesIndex] as GanttSeries; GanttItem item = series.Items[itemIndex]; GanttTimeEntry timeEntry = item.Times[timeEntryIndex]; return series.ToString() + "//" + item.ToString() + "//" + timeEntry.ToString(); }}