Hello Suwit,
You need to drop a NChartControl on the form. Make sure that you have the following references added to your project:
Nevron.Chart.dll
Nevron.Chart.WinForm.dll
Nevron.Presentation.dll
Nevron.System.dll
The following code can help you achieve similar gauge:
using Nevron.Chart;
using Nevron.Chart.WinForm;
using Nevron.GraphicsCore;
…
private void Form1_Load(object sender, EventArgs e)
{
nChartControl1.Panels.Clear();
NRadialGaugePanel radialGauge = new NRadialGaugePanel();
nChartControl1.Panels.Add(radialGauge);
radialGauge.BeginAngle = 129;
radialGauge.SweepAngle = 282;
radialGauge.AutoBorder = RadialGaugeAutoBorder.RoundedOutline;
radialGauge.CenterBorderRounding = new NLength(72);
radialGauge.EdgeBorderRounding = new NLength(10);
// Gauge cap style
radialGauge.CapStyle.Visible = true;
radialGauge.CapStyle.Size = new NSizeL(25, 25);
radialGauge.CapStyle.Shape.FillStyle = new NGradientFillStyle(GradientStyle.DiagonalUp, GradientVariant.Variant1, Color.White, Color.DimGray);
radialGauge.CapStyle.Shape.StrokeStyle.Color = Color.DarkGray;
// apply background and glass effect to the gauge
NEdgeBorderStyle borderStyle = new NEdgeBorderStyle(BorderShape.Auto);
borderStyle.OuterBevelWidth = new NLength(8);
borderStyle.OuterBevelFillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant4, Color.White, Color.Black);
borderStyle.InnerBevelWidth = new NLength(4);
borderStyle.InnerBevelFillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant3, Color.White, Color.DimGray);
borderStyle.MiddleBevelWidth = new NLength(0);
radialGauge.BorderStyle = borderStyle;
NGlassEffectStyle glass = new NGlassEffectStyle();
glass.CornerRounding = new NLength(10);
glass.DarkColor = Color.FromArgb(200, Color.LightGray);
glass.LightColor = Color.FromArgb(200, Color.White);
glass.EdgeDepth = new NLength(6);
glass.EdgeOffset = new NLength(3);
glass.LightDirection = -39;
glass.LightSpread = 66;
radialGauge.PaintEffect = glass;
radialGauge.BackgroundFillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant2, Color.WhiteSmoke, Color.DimGray);
// add some indicators
NNeedleValueIndicator needle = new NNeedleValueIndicator(67);
needle.OffsetFromScale = new NLength(10);
needle.Width = new NLength(10);
needle.Shape.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.White, Color.Red);
needle.Shape.StrokeStyle.Color = Color.Red;
radialGauge.Indicators.Add(needle);
// configure axis
NGaugeAxis axis = (NGaugeAxis)radialGauge.Axes[0];
// modify the anchor so that labels appear after the scale
axis.Anchor = new NDockGaugeAxisAnchor(GaugeAxisDockZone.Top, true, RulerOrientation.Left, 3, 97);
// apply settings to the gauge scale
NLinearScaleConfigurator linearScale = axis.ScaleConfigurator as NLinearScaleConfigurator;
linearScale.SetPredefinedScaleStyle(PredefinedScaleStyle.PresentationNoStroke);
linearScale.LabelFitModes = new LabelFitMode[0];
CreateSection(radialGauge, linearScale, Color.LimeGreen, new NRange1DD(0, 30));
CreateSection(radialGauge, linearScale, Color.Yellow, new NRange1DD(30, 70));
CreateSection(radialGauge, linearScale, Color.Red, new NRange1DD(70, 100));
NNumericDisplayPanel numericDisplay = CreateDisplayPanel();
numericDisplay.Size = new NSizeL(100, 60);
numericDisplay.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage),
new NLength(55, NRelativeUnit.ParentPercentage));
numericDisplay.ContentAlignment = ContentAlignment.BottomCenter;
numericDisplay.UseAutomaticSize = false;
numericDisplay.BoundsMode = BoundsMode.Fit;
numericDisplay.BackgroundFillStyle = new NColorFillStyle(Color.Transparent);
numericDisplay.Value = 12.22;
radialGauge.ChildPanels.Add(numericDisplay);
}
private void CreateSection(NRadialGaugePanel radialGauge, NLinearScaleConfigurator scale, Color color, NRange1DD range)
{
// add range indicator
NRangeIndicator indicator = new NRangeIndicator();
indicator.Value = range.End;
indicator.OriginMode = OriginMode.Custom;
indicator.Origin = range.Begin;
indicator.FillStyle = new NColorFillStyle(Color.FromArgb(225, color));
indicator.OffsetFromScale = new NLength(0);
indicator.BeginWidth = new NLength(10);
indicator.EndWidth = new NLength(10);
indicator.PaintOrder = IndicatorPaintOrder.BeforeScale;
radialGauge.Indicators.Add(indicator);
// add scale section
NScaleSectionStyle scaleSection = new NScaleSectionStyle();
scaleSection.Range = range;
scaleSection.MajorGridStrokeStyle = new NStrokeStyle(color);
scaleSection.MajorTickStrokeStyle = new NStrokeStyle(color);
scaleSection.MinorTickStrokeStyle = new NStrokeStyle(1, color, LinePattern.Dot, 2, 1);
NTextStyle labelStyle = new NTextStyle();
labelStyle.FontStyle = new NFontStyle("Verdana", 12, FontStyle.Bold);
scaleSection.LabelTextStyle = labelStyle;
scale.Sections.Add(scaleSection);
scale.RulerStyle.FillStyle.SetTransparencyPercent(40);
scale.RulerStyle.BorderStyle.Width = new NLength(0);
}
private NNumericDisplayPanel CreateDisplayPanel()
{
NNumericDisplayPanel numericDisplay = new NNumericDisplayPanel();
numericDisplay.Value = 0;
numericDisplay.CellCountMode = DisplayCellCountMode.Fixed;
numericDisplay.CellCount = 7;
numericDisplay.Margins = new NMarginsL(10, 10, 10, 10);
numericDisplay.Padding = new NMarginsL(10, 10, 10, 10);
numericDisplay.BackgroundFillStyle = new NColorFillStyle(Color.Black);
// adjust cell fill styles
numericDisplay.LitFillStyle = new NColorFillStyle(Color.DarkGray);
numericDisplay.DimFillStyle = new NColorFillStyle(Color.Transparent);
numericDisplay.DecimalLitFillStyle = new NColorFillStyle(Color.White);
numericDisplay.DecimalDimFillStyle = new NColorFillStyle(Color.Transparent);
return numericDisplay;
}
We hope this helps.
Kind regards,
Nevron Support Team
Best Regards,
Nevron Support Team