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
105
WrapTextAxisLabelLayoutBehavior
posted

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

Parents Reply Children
No Data