Hello,
I want to be able to wrap the text of my column or bar chart so it doesn't get cut off by the edge of the chart. I tried implementing a custom behavior and set it to use behavior, but it doesn't seem to do anything. The text for the labels seem to get cut off by the edge of the chart.
Do you have any suggestions to try. I simplified the code to reproduce the issue, please see the class below.
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Data;using Infragistics.UltraChart.Shared.Styles;using System.Drawing;using Infragistics.WebUI.UltraWebChart;using Infragistics.UltraChart.Resources.Appearance;
namespace InfragisticsTooltipTest{ public partial class _Default : System.Web.UI.Page { protected Random RandomGen = new Random(42); protected Control form; protected void Page_Load(object sender, EventArgs e) { foreach (Control con in this.Controls) { if (con.ID == "form1") { form = con; break; } }
// add charts UltraChart chart = new UltraChart(); chart.ID = "Uc"; this.ConfigureChart(chart); form.Controls.Add(chart); }
protected void ConfigureChart(UltraChart chart) { chart.ChartType = ChartType.BarChart; chart.Tooltips.Display = TooltipDisplay.MouseMove; chart.Tooltips.Format = TooltipStyle.DataValue;
chart.Data.DataSource = this.CreateTable(); chart.DataBind(); chart.Axis.Y.Labels.Layout.Behavior = AxisLabelLayoutBehaviors.UseCollection; WrapTextAxisLabelLayoutBehavior textWrap = new WrapTextAxisLabelLayoutBehavior(); textWrap.UseOnlyToPreventCollisions = false; chart.Axis.Y.Labels.Layout.BehaviorCollection.Add(textWrap);
}
protected DataTable CreateTable() { DataTable ret = new DataTable(); ret.Columns.Add("Name", typeof(string)); ret.Columns.Add("Sales Men Wrap Test",typeof(int));
DataRow dr; string[] names = new string[] { "Ken", "Joe", "Bill", "Craig", "Jack" }; foreach (string name in names) { dr = ret.NewRow(); dr["Name"] = name; dr["Sales Men Wrap Test"] = this.RandomGen.Next(0, 100); ret.Rows.Add(dr); } return ret; } }}
Best Regards,
Kevin Woo
Try using this property:
this.UltraChart1.Axis.Y.Labels.WrapText = true;
Thank you very much for your response. I noticed a few things about this response that were odd and maybe it was just me. In either case, it worked and I'll take it.
1. For some reason WrapText does not appear in my intellisense for Infragistics35.v10.3. I wonder is it hidden or depreciated? Maybe my IDE just doesn't load it correctly or is refering to a previous version?
2. I still had to add in the collection properties, so ultimately my code looked like this:
chart.Axis.Y.Labels.WrapText = true; chart.Axis.Y.Labels.ClipText = false; chart.Axis.Y.Labels.Layout.Behavior = AxisLabelLayoutBehaviors.UseCollection; WrapTextAxisLabelLayoutBehavior textWrap = new WrapTextAxisLabelLayoutBehavior(); textWrap.UseOnlyToPreventCollisions = false; chart.Axis.Y.Labels.Layout.BehaviorCollection.Add(textWrap);
Other than that the result was
This is what I was looking for, thanks for the help.
WrapText is a property used in the chart's internal code, but which is not fully supported as part of the public API. so it is hidden from intellisense, but not deprecated.
Can anyone let me kow how to wrap label of Pie chart
Hi,
Unfortunately, the UltraChart doesn’t support this functionality, but you can set the labels with:
"Pie \n Text"
Thanks David.
the WrapText behavior doesn't always expand each label's bounds enough to actually wrap the text, as you might expect. there is a bug report in our system for this issue, #81370. it is currently fixed and expected to be part of a future service release. for more information about this bug report and the availability of a fix, please contact Infragistics Developer Support.
Anyone on the Infragistics know why this isn't working for me? I'm using Infragistics v10.3, VS 2010, and VB.NET. Here's my code:
UltraChart1.Axis.X.Labels.WrapText = True UltraChart1.Axis.X.Labels.ClipText = False UltraChart1.Axis.X.Labels.Layout.Behavior = AxisLabelLayoutBehaviors.UseCollection Dim textwrap As WrapTextAxisLabelLayoutBehavior = New WrapTextAxisLabelLayoutBehavior textwrap.UseOnlyToPreventCollisions = False UltraChart1.Axis.X.Labels.Layout.BehaviorCollection.Add(textwrap)