multiple bar colors


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

By Hong Tran - 7 Years Ago
OLD Chart:
This is a chart that works correctly in Nevron chart.

 
NEW Charts
 Today we have a new requirement to update the chart with "Your Performance" - X axis to a number of bars with different colors as shown. 

  
Would you please confirm is this requirement doable?  How would I solve/update the chart?  Thank you in advance.
Hong Tran
  
By Nevron Support - 7 Years Ago
Hi Hong,
Yes this requirement is doable - you need to do the following:
1. Go to Chart \ Chart Areas \ Chart Area 0 \ Appearance.
2. Select Color Mode = DataPoint.
at this point the chart palette will be applied per data point (not per series) and the bar clusters will have different color. Then you need to modify the color of the second bar with custom code. To do this select the code tab and paste the following code:

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[1] as NBarSeries;
   bar.FillStyles.Clear();
   bar.BorderStyles.Clear();
   
   bar.BorderStyle = new NStrokeStyle(0, Color.Gray);
   bar.FillStyle = new NColorFillStyle(Color.Gray);
  }
 }
}

This code overrides the fill / border styles applied on data points from the designer and specifies another color for the bars (in this case Color.Gray).
Hope this helps - let us know if you have any questions or meet any problems.