Jump to content
Software FX Community

How can I change X-Axis labels height?


monofilm
 Share

Recommended Posts

As you can see at the image below X-Axis labels occupy more than 50% of image space. I'm wondering is it possible to limit X-Axis labels height by 50 pixels for example?

Posted Image 

 Source:

 

  DataTable table = new DataTable();

  table.Columns.Add("x", typeof(int));
  table.Columns.Add("y", typeof(string));

  DataRow row = table.NewRow();
  row["x"] = 0;
  row["y"] = "verylongstringverylongstringverylongstring";
  table.Rows.Add(row);
  row = table.NewRow();
  row["x"] = 1;
  row["y"] = "verylongstringverylongstringverylongstring";
  table.Rows.Add(row);
  row = table.NewRow();
  row["x"] = 4;
  row["y"] = "verylongstringverylongstringverylongstring";
  table.Rows.Add(row);

  Chart1.DataSourceSettings.Fields.Add(new ChartFX.WebForms.FieldMap("x", ChartFX.WebForms.FieldUsage.Value));
  Chart1.DataSourceSettings.Fields.Add(new ChartFX.WebForms.FieldMap("y", ChartFX.WebForms.FieldUsage.Label));

  Chart1.DataSource = table;
  Chart1.DataBind();

  Chart1.PlotAreaMargin.Bottom = 20;
  Chart1.PlotAreaMargin.Left = 20;
  Chart1.PlotAreaMargin.Right = 20;
  Chart1.PlotAreaMargin.Top = 20;

Link to comment
Share on other sites

 I might have found something that could help you. There is a property in the Axis class called MaxSizePercentage. It will limit the space taken by the axis as a percentage, but in a brute way. It will clip the begining of the string. To avoid that you could force the clipping of the end of the string using LabelTrimming.

Chart1.AxisX.MaxSizePercentage = 30;Chart1.AxisX.LabelTrimming = System.Drawing.StringTrimming.EllipsisWord;

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...