Hi,
I am using a TreeMapChart and i want a custom tooltip. I have columns like Category,Name,Price and Sales. The treemap chart has generated according to the category. I tried to set the custom tooltip as explained in this article
http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=2807
I see the tooltip created but the values get misplaced. The highest category displays the 2 category values and so on respectively. The least category does not have any of the tooltip instead throws a error message
No Row at position .
I really dont understand what is this problem. Could anyone help to solve this issue?
Thanks in advance
Ferdin
it's hard to tell what's going on because i don't know how IRenderLabel is being implemented. what does your IRenderLabel.ToString(Hashtable context) method look like? are you using context["DATA_ROW"] to get the row index like in that KB article?
David
Thanks for your reply. Yes i am using context["DATA_ROW"]. I am attaching the code of IRenderClass which i used here.
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using Infragistics.UltraChart.Resources;
using System.Data;
{
public class RenderLabel:IRenderLabel
System.Text.StringBuilder ReturnValue;
localDT = myData;
}
ReturnValue.Length = 0;
DR = localDT.Rows[RowIndex];
ReturnValue.Append("Department:");
ReturnValue.Append("\n");
ReturnValue.Append(DR["ItemNumber"]);
ReturnValue.Append("Stock:");
ReturnValue.Append(DR["Description"]);
Hope this helps you to figure out my problem.
Thanks
okay, so the relationship between the row in the datatable and the context["DATA_ROW"] isn't direct, like it is for charts which are based on tabular data structures.
i think the best way to get your real row index back is by setting a primary key on your source DataTable and then using its Rows.Find method to get the row back.
here's some sample code:
private void Form1_Load(object sender, EventArgs e) { this.ultraChart1.ChartType = ChartType.TreeMapChart; DataTable table = new DataTable(); table.Columns.Add("Category", typeof(string)); table.Columns.Add("Name", typeof(string)); table.Columns.Add("UnitPrice", typeof(double)); table.Columns.Add("YearlySales", typeof(double)); table.Rows.Add(new object[ { "Fruit", "Apples", 3, 200 }); table.Rows.Add(new object[ { "Fruit", "Bananas", 2, 100 }); table.Rows.Add(new object[ { "Fruit", "Oranges", 1, 50 }); table.Rows.Add(new object[ { "Dairy", "Milk", 4, 20 }); table.Rows.Add(new object[ { "Dairy", "Cheese", 5, 10 }); table.Rows.Add(new object[ { "Meat", "Steak", 10, 150 }); table.Rows.Add(new object[ { "Meat", "Chicken", 8, 35 }); table.PrimaryKey = new DataColumn[ { table.Columns["Name"] }; this.ultraChart1.Data.DataSource = table; this.ultraChart1.Data.DataBind(); Hashtable labelRenderers = new Hashtable(); labelRenderers.Add("MY_TREE_LABEL", new TreeMapTooltipRenderer(table)); this.ultraChart1.LabelHash = labelRenderers; this.ultraChart1.Tooltips.FormatString = "<MY_TREE_LABEL>"; } internal class TreeMapTooltipRenderer : IRenderLabel { internal TreeMapTooltipRenderer(DataTable table) { this.Table = table; } private DataTable Table { get; set; } string IRenderLabel.ToString(Hashtable context) { if (context.ContainsKey("ShapeLabel")) { int realRowIndex = this.Table.Rows.IndexOf(this.Table.Rows.Find(context["ShapeLabel"])); return "Row Number " + realRowIndex; } return ""; } }