Create a Linear Gauge with multiple gradients


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

By Vahid Mesri - 6 Years Ago
Hi,
I would like to create a linear gauge with its background colour set based on 3 thresholds as shown in the below image.
There colour changes should use gradients as oppose to sudden changes to the colour.
There are two pointers in the plot, one has a diamond shape and the other one is a dashed line.


I've tried to replicate the plot using Nevron gauges (see the image below) but so far I have had issues setting the width of the gauge or setting multiple gradients at a precise cut-off point. To increase the width I've added extra axes but I cannot replicate the gradients as the maximum allowed gradient uses 2 colours and I couldn't give the precise value for the start and end point for the colours.
https://www.nevron.com/forum/uploads/images/21036f16-c6b9-41a6-9542-24ef.png

Could you please tell me how such a plot/gauge can be replicated in Nevron?
Should I use a Gauge or a Nevron chart? 

Thanks a lot in advance.

By Nevron Support - 6 Years Ago

Hi Vahid,
You need to use the chart control for this purpose as indeed the gauge only supports two colors per gradient. To replicate the attached picture you can use a bar series with one bar (bar width percent should be set to 100%) and then use the following custom 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 = (NBarSeries)chart.Series[0];
   
   bar.Palette = new NPalette();
   bar.Palette.SmoothPalette = true;
   bar.Palette.Mode = PaletteMode.Custom;
   bar.Palette.Add(0, Color.Red);
   bar.Palette.Add(0.5, Color.Green);
   bar.Palette.Add(1.0, Color.Blue);
  }
 }
}
It shows how to apply a 3 color gradient to a bar series. Hope this helps - let us know if you meet any problems or have any questions.

By Vahid Mesri - 6 Years Ago
Hi,
Thanks a lot for the solution.
It did work indeed on my local PC with the most recent version of Nevron in which the NBarSeries has the Palette property.
Unfortunately on our server, we do not have the latest version of Nevron (it is Nevron Vision 2012) hence the report doesn't get rendered.
Is there any way we could have this functionality on prior versions or do we have to upgrade?

Cheers!


By Nevron Support - 6 Years Ago
Hi Vahid,
You'll have to update the version on the server with the most recent release as 2012 indeed does not support the Palette option (it was added in later versions). Let us know if you have any questions.