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.