Set custom color and zone range for the Grid Surface Chart in SSRS

Applies to: Nevron Chart for Reporting Services (SSRS 2005, 2008, 2012)

How to set custom color and zone range for the Grid Surface Chart in SSRS?

Nevron Chart for SSRS provides support for plotting Grid Surface Charts. The surface coloring is controlled by the following properties in the Chart Designer:
  • Palette Mode - defines the mode in which the surface zoning palette is determined. Possible values are:
    • Sync With Axis Scale - the palette is automatically synchronized with axis scale.
    • Custom Steps Count - the palette is automatically calibrated to the elevation data [min:max] range, but has the number of steps defined by the Palette Steps setting.

  • Palette Steps - defines the number of steps in the palette when the Palette Mode is set to Custom Steps Count.


However, you may need to configure custom color and zone range for your Grid Surface. You can achieve this by using custom code injection in the Code tab of the Chart Designer.





The following code will modify the standard colors and the zone range:

[C#]
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)
        {
            if (context.Document.Charts.Count == 0)
                return;
  
            // get the first chart in the document
            NChart chart = context.Document.Charts[0];
  
            if (chart.Series.Count == 0)
                return;       
             
            NGridSurfaceSeries surface = chart.Series[0] as NGridSurfaceSeries;
            if (surface == null)
                return;
                 
            // setup a custom palette
            surface.AutomaticPalette = false;
            surface.Palette.Clear();
             
            surface.Palette.Add(100, Color.FromArgb(255, 121, 0));
            surface.Palette.Add(13.5, Color.FromArgb(255, 126, 0));
            surface.Palette.Add(12.0, Color.FromArgb(255, 180, 107));
            surface.Palette.Add(10.5, Color.FromArgb(255, 187, 120));
            surface.Palette.Add(9.0, Color.FromArgb(255, 190, 126));
            surface.Palette.Add(7.5, Color.FromArgb(255, 211, 168));
            surface.Palette.Add(6.0, Color.FromArgb(255, 228, 206));
            surface.Palette.Add(5.0, Color.FromArgb(255, 239, 230));
            surface.Palette.Add(4.5, Color.FromArgb(255, 249, 253));
            surface.Palette.Add(2.5, Color.FromArgb(228, 234, 255));
            surface.Palette.Add(0.0, Color.FromArgb(168, 197, 255));
        }
    }
}

Article ID: 228, Created On: 12/6/2012, Modified: 12/6/2012