Hello,
1) I want to show tooltips for labels which are on the X and Y axis. For custom chart the solution with creating CustomTooltips class worked fine
public class CustomTooltips : IRenderLabel { string _tooltip = String.Empty;
public string Tooltip { get { return _tooltip; } set { _tooltip = value; } }
#region IRenderLabel Members
public string ToString(System.Collections.Hashtable context) { if (!_tooltip.Equals(String.Empty)) { return _tooltip; } if (!context["SERIES_LABEL"].ToString().Equals(String.Empty)) { return context["DATA_VALUE"].ToString(); }
return context["ITEM_LABEL"].ToString(); }
#endregion }
than Mouse move event looks like this
private void ultraChart1_MouseMove(object sender, MouseEventArgs e) { ChartLayerCollection layers = ultraChart1.CompositeChart.ChartLayers; foreach (ChartLayerAppearance layer in layers) { bool success = false; if (layer.ChartLayer != null) { var text = layer.ChartLayer.ChartCore.GetChartPrimitiveFromPoint(e.Location) as Text; if (text != null) { labels.Tooltip = text.GetTextString(); success = true; } } if (!success) { labels.Tooltip = String.Empty; } } }
but now I am trying to do the same for bar chart like this
private void ultraBarChart_MouseMove(object sender, MouseEventArgs e) { ChartLayerCollection layers = new ChartLayerCollection(); layers.Add(barChart.BarChart.ChartComponent);
but I can't figure out what to add to "layers" collection.
Can you help me out?
The same question regarding TimeSeries chart.
2) The other question is when I apply this solution in composite chart which consist of column and line chart, the tooltips on line chart originally were showing Y axis values (which was good for me), after solution the show X axis values. How can I take back Y axis values?
Thanks
Hello Oleksandr,
Thank you for contacting Infragistics!
I recommend you see the following documentation and sample:
http://help.infragistics.com/doc/ASPNET/2014.2/CLR4.0/?page=Chart_Customize_Chart_ToolTips.html
http://es.infragistics.com/samples/aspnet/chart/adding-tooltips-to-a-chart
As you can see there are a couple presets that display with data and or label. Then you can customize if you like:
this.UltraChart1.Tooltips.Format = TooltipStyle.Custom; this.UltraChart1.Tooltips.FormatString = "My Data: <DATA_VALUE:$#0.00>";
Please let me know if you have any further questions concerning this matter.
Hello
The second issue resolved, thanks. But the first question was about showing tooltips for labels on X an Y axis. For example when I get mouse over one of the labels (not on columns) on X or Y axis it will show the tooltip for this label. Dimitar helped me with this for composite chart, now I just want to apply this for BarChart and TimeSeries chart.
Thanks!