Hi,
I am using ClipTextAxisLabelLayoutBehavior to trim labels and display ellipces for data on X axis . Now i would like to display tooltip on mouse hover to show the entire label. I observed tooltips are only appearing for data on chart but not for labels.
Please suggest.
Thanks
bp
here is some code you can use to achieve this. unfortunately, you are constrained to using <ITEM_LABEL> for all tooltips in this example. if you want to request this as an official feature of winchart then please visit this page: https://ko.infragistics.com/community/ideas
using
System;
Infragistics.Win.UltraWinChart;
System.Windows.Forms;
Infragistics.UltraChart.Resources.Appearance;
Infragistics.UltraChart.Shared.Styles;
System.Drawing;
Infragistics.UltraChart.Shared.Events;
Infragistics.UltraChart.Core.Primitives;
System.Collections;
Infragistics.UltraChart.Resources;namespace TooltipXAxisLabels
{
public partial class Form1 : Form
private UltraChart UltraChart1 { get; set; }public Form1()
// add a chart to the formthis.UltraChart1 = new UltraChart();
this.UltraChart1.Dock = DockStyle.Fill;this.Controls.Add(this.UltraChart1);
// bind it to some series data with extra-long item labels.NumericSeries series1 = new NumericSeries();
series1.Points.Add(
new NumericDataPoint(1.0, "Point A AAAAAAAAAAAAAAAAA", false));series1.Points.Add(new NumericDataPoint(2.0, "Point B BBBBBBBBBBBBBBBBB", false));
new NumericDataPoint(3.0, "Point C CCCCCCCCCCCCCCCCC", false));series1.Points.Add(new NumericDataPoint(4.0, "Point D DDDDDDDDDDDDDDDDD", false));
this.UltraChart1.Series.Add(series1);
// configure x axis labelsthis.UltraChart1.Axis.X.Labels.Orientation = TextOrientation.Horizontal;
this.UltraChart1.Axis.X.Labels.SeriesLabels.Visible = false;
// add a text clipping behaviorthis.UltraChart1.Axis.X.Labels.Layout.Behavior = AxisLabelLayoutBehaviors.UseCollection;
ClipTextAxisLabelLayoutBehavior clipper = new ClipTextAxisLabelLayoutBehavior();clipper.ClipText = true;
clipper.Enabled =
true;clipper.EnableRollback = false;
clipper.HideText =
true;clipper.Trimming = StringTrimming.EllipsisCharacter;
this.UltraChart1.Axis.X.Labels.Layout.BehaviorCollection.Add(clipper);
// handle the chartdrawitem eventthis.UltraChart1.ChartDrawItem += new Infragistics.UltraChart.Shared.Events.ChartDrawItemEventHandler(UltraChart1_ChartDrawItem);
// the tooltips must use this format for the sample to work properlythis.UltraChart1.Tooltips.FormatString = "<ITEM_LABEL>";
}
private void UltraChart1_ChartDrawItem(object sender, ChartDrawItemEventArgs e)
Text textPrim = e.Primitive as Text;
// check if the primitive is a Text primitive.if (textPrim != null)
// this is the code you can use to make any primitive show tooltips.textPrim.Caps = PCaps.HitTest | PCaps.Tooltip;
textPrim.Chart =
this.UltraChart1.ChartType;textPrim.Row = Math.Max(textPrim.Row, 0);textPrim.Column = Math.Max(textPrim.Column, 0);