Custom code to add stripes to a floating bar chart


https://www.nevron.com/Forum/Topic4806.aspx
Print Topic | Close Window

By Clare Moore - 13 Years Ago

I am trying to add some stripes to my floating bar chart using custom code.

NAxisStripe s1 = chart.Axis(StandardAxis.PrimaryY).Stripes.Add(2, 3);

s1.FillStyle = new NColorFillStyle(Color.FromArgb(125, Color.SteelBlue));

s1.SetShowAtWall(ChartWallType.Back, true);

 

This doesnt show anything, though if i change the code to Primary X, it does show a horizontal line, I am not sure why I cant get a vertical line to show up.

My other question is, can I access my dataset from the embedded code?  I actually want to highlight sections of activities based on the person who performed the activity, but i am unsure how to go about this or even if this is possible?

 

By Nevron Support - 13 Years Ago

Hi Clare,

Most likely your axis scales date / time values - if this is the case 2 and 3 are somewhere in the begging of last century as 0 is 1899 in OA date format. Just tested with the following code snippet inside the float bar example report:

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];
   
NAxisStripe s1 = chart.Axis(StandardAxis.PrimaryY).Stripes.Add(new DateTime(2009, 3, 1).ToOADate(), new DateTime(2009, 4, 1).ToOADate());

s1.FillStyle = new NColorFillStyle(Color.FromArgb(125, Color.SteelBlue));

s1.SetShowAtWall(ChartWallType.Back, true);


  }
 }
}

and it was working OK.

By Clare Moore - 13 Years Ago

Thanks very much I realised shortly after posting that it would probable be that the values i was using werent valid ones!

Thanks again

By Clare Moore - 13 Years Ago

I added a test to check for empty values and my code no longer errors, however i put in some test code to add in a stripe for each start and end value.

I only end up with one stripe added to that chart, for the very first set of values.

It seems that only one BeginValue and EndValue is populated.

Could this be caused by grouping? how do i access my other values??