Hi,
I have a composite chart with 1 area and 3 layers on it. One layer has stack column chart, two layers have line charts. I would like to set custom tooltips separately for each layer. I wrote my own IRenderLabel classes, set them as renderers for custom format strings, created the hashtable from it. I set also the appropriate format strings on the layers (I did it in designer : Chart Layer->Chart Type Appearance->Chart Text->ItemFormatString), but it doesn't work.
Is there any way to solve this problem? Thanks in advance
ChartText is something completely different from tooltips. Currently, there is no way to set tooltips specifically for one layer, so you will need to come up with a way to make one single IRenderLabel object handle all tooltips from the Tooltips.FormatString
Thanks for help, I use the DataItemOver event to obtain the layer index, and I call my IRenderLabel class every time in this event, when the layer index has changed. It works fine.
Hi, can u please post the code u used for the charts dataitem over event ..it would be of great help to me..
Hi ahsin,
It's my chart_dataitemover event handler.
int oldLayerIndex = layerIndex; if (e.LayerID == "Layer One") layerIndex = 0; else if (e.LayerID == "Layer Two") layerIndex = 1; else if (e.LayerID == "Layer Three") layerIndex = 2; if (oldLayerIndex != layerIndex) CustomizeLabels(layerIndex);
I have a variable "layerIndex", which is stored in the form. I change it every time, when this event is called. If it's different from the old layer index, I customize the labels for the chart.
private void CustomizeLabels(int layerIndex) { chart.Tooltips.Format = TooltipStyle.Custom; chart.Tooltips.FormatString = "<TOOLTIP>"; Hashtable tooltips = new Hashtable(); tooltips.Add("TOOLTIP", new IRenderLabelClass(layerIndex)); chart.LabelHash = tooltips; }
And the result of ToString() method in IRenderLabelClass depends on layerIndex value.
Regards:)
thanks ! .. but thn am not very clear about how to associate tat particular data item over event handler with the ultra chart.. how do i do tat
?
Let me try to add some more color:
private void CustomizeTooltips(int layerIndex){chart.Tooltips.Format = TooltipStyle.Custom;chart.Tooltips.FormatString = "<TOOLTIP>";Hashtable tooltips = chart.LabelHash;if (tooltips["TOOLTIP"] != null)tooltips.Remove("TOOLTIP");tooltips.Add("TOOLTIP", new RenderTooltip(layerIndex));chart.LabelHash = tooltips;}
{
chart.Tooltips.FormatString = "<TOOLTIP>";
if (tooltips["TOOLTIP"] != null)
chart.LabelHash = tooltips;
}
Create a new class that implements the IRenderLabel interface. In this class you'll need a constructor to store the layer ID you're passing in, and a ToString method that implements the logic you want:
using System;using System.Collections;using System.Text;using Infragistics.UltraChart.Shared.Styles;using Infragistics.UltraChart.Resources;class RenderTooltip : IRenderLabel{private int layerID;public RenderTooltip(int layerID) {this.layerID = layerID; } public string ToString(Hashtable context) { // Add your logic here if (layerID == 0)return context["DATA_VALUE"].ToString(); elsereturn ...; }}
using System;
using System.Collections;
using System.Text;
using Infragistics.UltraChart.Shared.Styles;
using Infragistics.UltraChart.Resources;
class RenderTooltip : IRenderLabel
{ // Add your logic here
if (layerID == 0)
else
Hope that helps! Thanks mtanska for your posts - they got me to the solution I needed!Yash.
Hope that helps!
Thanks mtanska for your posts - they got me to the solution I needed!
Yash.
To do this, you need to create a Composite Chart with 2 ColumnChart layers, each of which uses a different Y-axis.
Want to set two different scales on the same y axis for a column chart
i.e.,
with a minumum range of 0 to a max of 10.. i wanna set 0 - 5 with an interval of 1 and from 5 to 10 wit 2 as the inteval..
any solutions???
Are you sure you're using Infragistics UltraChart for Windows Forms? Is the dll you're using named Infragistics2.Win.UltraWinChart.vX.x.dll ?
i dont find the data item over event handler in the events list of the ultrachart..
any solns?