Configure chart properties through code for Multiple Chart Area charts


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

By Brian Dalwood - 11 Years Ago
Hi,

I have a chart that includes 7 chart areas (each configured as an area chart with 5 data series in each).
I want to be able to configure each of the area charts properties (i.e. No axis labels, data series colours etc.) through code so that I can easily make bulk changes to any property across all charts.

Can you please provide some sample code to get me started accessing the properties of each "Chart Area" chart.

Thanks
By Nevron Support - 11 Years Ago

Hi Brian,

The following code shows how to iterate trough all charts and series in a chart document:


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)
  {
   for (int i = 0; i < context.Document.Charts.Count; i++)
   {
    NChart chart = context.Document.Charts[i];
    
    // do something with chart
    
    for (int j = 0; j < chart.Series.Count; j++)
    {
     NSeries series = (NSeries)chart.Series[j];
     
     // do something with series
    }
   }
  }
 }
}

Hope this helps - let us know if you require something more specific...