Ensuring axis increments in whole numbers


Author
Message
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K
Hi Nick,

Please contact support by e-mail and ask to schedule a web meeting - there must be something small we're missing here, but we cannot determine it by exchanging messages in the forum...



Best Regards,
Nevron Support Team


nick thompson
nick thompson
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)
Group: Forum Members
Posts: 6, Visits: 1
Hi

This doesn't work, we get:-

"NChart Rendering Failed. Exception was: Exception has been thrown by the target of an invocation."

Please could you help?

Thanks
Nick
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Hi Nick,

It's kind of hard to predict the output of the automatic tick calculator because it depends on both the range of the values and the size of the control on the screen. The following code snippet shows how to conditionally modify the step settings:

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

namespace MyNamespace
{
 /// <summary>
 /// Sample class
 /// </summary>
 public class MyClass
 {
  /// <summary>
  /// Main entry point
  /// </summary>
  /// <param name="context"></param>
  public static void RSMain(NRSChartCodeContext context)
  {
   NChart chart = context.Document.Charts[0];
   
   NBarSeries bar = chart.Series[0] as NBarSeries;
   if (bar != null)
   {
    int maxValueIndex = bar.Values.FindMaxValue();
                double maxValue = (double)bar.Values[maxValueIndex];
                double minValue = 0;
               
                double length = Math.Abs(maxValue - minValue);
               
                if (length < 10)
                {
     NLinearScaleConfigurator scale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator;
        scale.MajorTickMode = MajorTickMode.CustomStep;
        scale.CustomStep = 1;
                }
   }
  }
 }
}

In this code snippet the custom step 1 is enabled when the range of the data is less that 10. 

We would also recommend to take a look at the chart for .NET API - it is identical with the SSRS API used above and there are 200+ examples showing all aspects of the control features you can touch with source code in SSRS.



Best Regards,
Nevron Support Team


nick thompson
nick thompson
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)
Group: Forum Members
Posts: 6, Visits: 1
Hi

What we want is it to not go less than 1 or be a decimal in the Y-axis, but otherwise the automatic calculator is fine. Sorry to be a pain, but how would we go about that? I had a word with my developers and they don't know where to start!

Thanks
Nick
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Nick,

You can eaither leave the automatic step calculation or provide custom step, based on some custom rule. In the case above since the major tick mode is forced to CustomStep the axis will generate many labels when the range of the data displayed on it is large - for example for a range [0, 100] it will generate 100 ticks. We recommend to stick to the automatic step calculator, but you can also write your own based on the range of the data.



Best Regards,
Nevron Support Team


nick thompson
nick thompson
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)
Group: Forum Members
Posts: 6, Visits: 1
Actually, it didn't work at all when there is lots of data! See below - how do we resolve this?
Attachments
custom-step.png (320 views, 22.00 KB)
nick thompson
nick thompson
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)
Group: Forum Members
Posts: 6, Visits: 1
That worked, thank you!
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Hi Nick,

The post is in the Nevron Chart for .NET topic - (this is why we assumed we are talking about .NET integration, not SSRS). The code is the same generally - in SSRS it should look like:

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

namespace MyNamespace
{
 /// <summary>
 /// Sample class
 /// </summary>
 public class MyClass
 {
  /// <summary>
  /// Main entry point
  /// </summary>
  /// <param name="context"></param>
  public static void RSMain(NRSChartCodeContext context)
  {
   NChart chart = context.Document.Charts[0];
   
   NLinearScaleConfigurator scale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator;
   scale.MajorTickMode = MajorTickMode.CustomStep;
   scale.CustomStep = 1;
  }
 }
}

Please take a look at the code embedding topic shipped with the documentation of the component:

http://helpssrsvision.nevron.com/Chart_Code_Embedding.html

Let us know if you meet any problems...



Best Regards,
Nevron Support Team


nick thompson
nick thompson
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)
Group: Forum Members
Posts: 6, Visits: 1
Hi

Thanks for this, but how would Michelle actually implement that? I assume you mean to paste that code within the chart code section. She has done that, clicked on the "build" button and you can see there's an error. Where do we go from there?

Kind regards
Nick
Attachments
chart code.png (284 views, 50.00 KB)
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Hi Michelle,

Currently there is no way to restrict the automatic step calculator to a particular min / max step (though is will be a nice feeature and is easy to implement as well). You can however specify custom step to the scale:

NLinearScaleConfigurator scale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator;
scale.MajorTickMode = MajorTickMode.CustomStep;
scale.CustomStep = 1;

We're going to implement min max step restriction in the upcoming version.



Best Regards,
Nevron Support Team


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search