Profile Picture

Wrap X Axis labels in a horizontal chart

Posted By Bob Smith 9 Years Ago
Author
Message
Bob Smith
Posted 9 Years Ago
View Quick Profile
Forum Guru

Forum Guru (69 reputation)Forum Guru (69 reputation)Forum Guru (69 reputation)Forum Guru (69 reputation)Forum Guru (69 reputation)Forum Guru (69 reputation)Forum Guru (69 reputation)Forum Guru (69 reputation)Forum Guru (69 reputation)

Group: Forum Members
Last Active: 9 Years Ago
Posts: 69, Visits: 1

I have a horizontal bar chart and I would like to force the X Axis labels to wrap as they are quite long. I can't find a setting in the configuration for it but I am hoping that I might be able to use code injection to wrap the labels. It makes the chart quite wide and adds a lot of white space next to the chart.

I've attached a screenshot of my issue with important data blanked out.



Attachments
Chart_Example.gif (549 views, 21.00 KB)
Nevron Support
Posted 9 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,186 reputation)Supreme Being (4,186 reputation)Supreme Being (4,186 reputation)Supreme Being (4,186 reputation)Supreme Being (4,186 reputation)Supreme Being (4,186 reputation)Supreme Being (4,186 reputation)Supreme Being (4,186 reputation)Supreme Being (4,186 reputation)

Group: Forum Members
Last Active: 11 hours ago
Posts: 2,994, Visits: 3,512
Hi Bob,

The following code snippet shows how to force X axis labels to wrap so that their width does not exceed 100 pixels:

NOrdinalScaleConfigurator scaleX = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator;

NRangeScaleLabelStyle labelStyle = new NRangeScaleLabelStyle();
labelStyle.TickMode = RangeLabelTickMode.None;
labelStyle.WrapText = true;
labelStyle.MaxWidth = new NLength(100, NGraphicsUnit.Pixel);
labelStyle.TextStyle.StringFormatStyle.HorzAlign = Nevron.HorzAlign.Right;
scaleX.LabelStyle = labelStyle;

Hope this helps - let us know if you meet any problems...


Best Regards,
Nevron Support Team



Bob Smith
Posted 9 Years Ago
View Quick Profile
Forum Guru

Forum Guru (69 reputation)Forum Guru (69 reputation)Forum Guru (69 reputation)Forum Guru (69 reputation)Forum Guru (69 reputation)Forum Guru (69 reputation)Forum Guru (69 reputation)Forum Guru (69 reputation)Forum Guru (69 reputation)

Group: Forum Members
Last Active: 9 Years Ago
Posts: 69, Visits: 1

Thanks for getting back to me!

I always have a hard time debugging code injection routines as I don't have access to the .net libraries or visual studio at my office Here is the compile error I am receiving:

Compiling...

(1,1) : error CS0116: A namespace does not directly contain members such as fields or methods

(2,40) : error CS1518: Expected class, delegate, enum, interface, or struct

(5,27) : error CS1518: Expected class, delegate, enum, interface, or struct

Compiled with 3 error(s).



Nevron Support
Posted 9 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,186 reputation)Supreme Being (4,186 reputation)Supreme Being (4,186 reputation)Supreme Being (4,186 reputation)Supreme Being (4,186 reputation)Supreme Being (4,186 reputation)Supreme Being (4,186 reputation)Supreme Being (4,186 reputation)Supreme Being (4,186 reputation)

Group: Forum Members
Last Active: 11 hours ago
Posts: 2,994, Visits: 3,512
Hi Bob,

In SSRS / SharePoint the code should look like:

using System;
using System.Drawing;
using Nevron.GraphicsCore;
using Nevron.Chart;
using Nevron.ReportingServices;

namespace MyNamespace
{
   ///
   /// Sample class
   ///

   public class MyClass
   {
      ///
      /// Main entry point
      ///

      ///
      public static void RSMain(NRSChartCodeContext context)
      {
         NChart chart = context.Document.Charts[0];
         
         NOrdinalScaleConfigurator scaleX = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator;
         
         NRangeScaleLabelStyle labelStyle = new NRangeScaleLabelStyle();
         labelStyle.TickMode = RangeLabelTickMode.None;
         labelStyle.WrapText = true;
         labelStyle.MaxWidth = new NLength(100, NGraphicsUnit.Pixel);
         labelStyle.TextStyle.StringFormatStyle.HorzAlign = Nevron.HorzAlign.Right;
         scaleX.LabelStyle = labelStyle;
      }
   }
}


Best Regards,
Nevron Support Team



Bob Smith
Posted 9 Years Ago
View Quick Profile
Forum Guru

Forum Guru (69 reputation)Forum Guru (69 reputation)Forum Guru (69 reputation)Forum Guru (69 reputation)Forum Guru (69 reputation)Forum Guru (69 reputation)Forum Guru (69 reputation)Forum Guru (69 reputation)Forum Guru (69 reputation)

Group: Forum Members
Last Active: 9 Years Ago
Posts: 69, Visits: 1
Worked great! Thank you very much!



Similar Topics


Reading This Topic