Applies to: Nevron Chart for Reporting Services (SSRS 2005 and 2008)
How to use a chart predefined color palette based on report parameter?
You need to create a custom code parameter that is later checked by code in order to modify the currently applied style sheet.
From the Chart Properties – Code tab, you can create a custom code parameter:
The following code applies a style sheet to the chart based on the palette specified as parameter:
[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)
{
int
palette = context.GetInt32Parameter(
"colorPalette"
);
NChartPalette chartPalette =
new
NChartPalette((ChartPredefinedPalette)palette);
NStyleSheet sheet = NStyleSheet.CreateFromPalette(chartPalette,
true
);
sheet.Apply(context.Document);
}
}
}
Following is a list of the available palettes and their values:
// <summary>
// Enumerates the predefined palettes
// </summary>
public
enum
ChartPredefinedPalette
{
/// <summary>
/// Nevron
/// </summary>
Nevron = 0,
/// <summary>
/// Winter
/// </summary>
Winter = 1,
/// <summary>
/// Autumn
/// </summary>
Autumn = 2,
/// <summary>
/// Bright
/// </summary>
Bright = 3,
/// <summary>
/// Cool
/// </summary>
Cool = 4,
/// <summary>
/// Dark
/// </summary>
Dark = 5,
/// <summary>
/// Nature
/// </summary>
Nature = 6,
/// <summary>
/// Pale
/// </summary>
Pale = 7,
/// <summary>
/// Pastel
/// </summary>
Pastel = 8,
/// <summary>
/// Rose
/// </summary>
Rose = 9,
/// <summary>
/// White backgrounds and black / gray fillings
/// </summary>
White = 10,
/// <summary>
/// Black backgrounds and white fillings
/// </summary>
Black = 11
}
Article ID: 146, Created On: 11/30/2010, Modified: 12/1/2010