Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
590
Tooltips for all labels
posted

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

Parents Reply Children
No Data