Profile Picture

Ensuring axis increments in whole numbers

Posted By Michelle Timmons 13 Years Ago
Author
Message
Michelle Timmons
Posted 13 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: Forum Members
Last Active: 13 Years Ago
Posts: 1, Visits: 1
I have a chart where the y-axis represents a number which will only ever be whole numbers. If, when the report is run, the maxiumum value happens to be a low number such as 2, then the y-axis increments in steps of 0.5. I've attached an example.

Is there a way to force the axes to increment in whole numbers only?

I've played around with the Range Inflate settings, but to be honest I don't undestand what effect they are supposed to have.


Attachments
nevron.png (279 views, 21.00 KB)
Nevron Support
Posted 13 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 3,039, Visits: 3,746

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



nick thompson
Posted 13 Years Ago
View Quick Profile
Forum Newbie

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
Last Active: 13 Years Ago
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 (238 views, 50.00 KB)
Nevron Support
Posted 13 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 3,039, Visits: 3,746

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
Posted 13 Years Ago
View Quick Profile
Forum Newbie

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
Last Active: 13 Years Ago
Posts: 6, Visits: 1
That worked, thank you!

nick thompson
Posted 13 Years Ago
View Quick Profile
Forum Newbie

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
Last Active: 13 Years Ago
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 (274 views, 22.00 KB)
Nevron Support
Posted 13 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 3,039, Visits: 3,746

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
Posted 13 Years Ago
View Quick Profile
Forum Newbie

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
Last Active: 13 Years Ago
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
Posted 13 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 3,039, Visits: 3,746

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
Posted 13 Years Ago
View Quick Profile
Forum Newbie

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
Last Active: 13 Years Ago
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



Similar Topics


Reading This Topic