/// <summary> /// /// </summary> /// <param name="gauge"></param> private void InitSections(NGauge gauge) { gauge.Axes.Clear(); NGaugeAxis axis = new NGaugeAxis(); gauge.Axes.Add(axis); axis.Anchor = new NDockGaugeAxisAnchor(ENGaugeAxisDockZone.Top); NStandardScale scale = (NStandardScale)axis.Scale; // init text style for regular labels scale.Labels.Style.TextStyle.Fill = new NColorFill(NColor.White); scale.Labels.Style.TextStyle.Font = new NFont("Arimo", 10, ENFontStyle.Bold); // init ticks scale.MajorGridLines.Visible = true; scale.MinTickDistance = 25; scale.MinorTickCount = 1; scale.SetPredefinedScale(ENPredefinedScaleStyle.Scientific); // create sections NScaleSection blueSection = new NScaleSection(); blueSection.Range = new NRange(0, 20); blueSection.RangeFill = new NColorFill(NColor.FromColor(NColor.Blue, 0.5f)); blueSection.MajorGridStroke = new NStroke(NColor.Blue); blueSection.MajorTickStroke = new NStroke(NColor.DarkBlue); blueSection.MinorTickStroke = new NStroke(1, NColor.Blue, ENDashStyle.Dot); NTextStyle labelStyle = new NTextStyle(); labelStyle.Fill = new NColorFill(NColor.Blue); labelStyle.Font = new NFont("Arimo", 10, ENFontStyle.Bold); blueSection.LabelTextStyle = labelStyle; scale.Sections.Add(blueSection); NScaleSection redSection = new NScaleSection(); redSection.Range = new NRange(80, 100); redSection.RangeFill = new NColorFill(NColor.FromColor(NColor.Red, 0.5f)); redSection.MajorGridStroke = new NStroke(NColor.Red); redSection.MajorTickStroke = new NStroke(NColor.DarkRed); redSection.MinorTickStroke = new NStroke(1, NColor.Red, ENDashStyle.Dot); labelStyle = new NTextStyle(); labelStyle.Fill = new NColorFill(NColor.Red); labelStyle.Font = new NFont("Arimo", 10.0, ENFontStyle.Bold); redSection.LabelTextStyle = labelStyle; scale.Sections.Add(redSection); }
/// <summary> /// /// </summary> /// <param name="gauge"></param> private void AddRangeIndicatorToGauge(NGauge gauge) { // add some indicators NRangeIndicator rangeIndicator = new NRangeIndicator(new NRange(75, 100)); rangeIndicator.Fill = new NColorFill(NColor.Red); rangeIndicator.Stroke.Width = 0.0; rangeIndicator.BeginWidth = 5.0; rangeIndicator.EndWidth = 10.0; rangeIndicator.PaintOrder = ENIndicatorPaintOrder.BeforeScale; gauge.Indicators.Add(rangeIndicator); }
/// <summary> /// /// </summary> /// <param name="arg"></param> void UpdateSections(NValueChangeEventArgs arg) { NGauge[] gauges = new NGauge[] { m_RadialGauge, m_LinearGauge }; for (int i = 0; i < gauges.Length; i++) { NGauge gauge = gauges[i]; NGaugeAxis axis = (NGaugeAxis)gauge.Axes[0]; NStandardScale scale = (NStandardScale)axis.Scale; if (scale.Sections.Count == 2) { NScaleSection blueSection = (NScaleSection)scale.Sections[0]; blueSection.Range = new NRange(m_BlueSectionBeginUpDown.Value, m_BlueSectionEndUpDown.Value); NScaleSection redSection = (NScaleSection)scale.Sections[1]; redSection.Range = new NRange(m_RedSectionBeginUpDown.Value, m_RedSectionEndUpDown.Value); } } }
/// <summary> /// /// </summary> void OnDataFeedTimerTick() { // update linear gauge NGauge[] gauges = new NGauge[] { m_RadialGauge, m_LinearGauge }; for (int i = 0; i < gauges.Length; i++) { NGauge gauge = gauges[i]; NValueIndicator valueIndicator = (NValueIndicator)gauge.Indicators[0]; NStandardScale scale = (NStandardScale)gauge.Axes[0].Scale; NScaleSection blueSection = (NScaleSection)scale.Sections[0]; NScaleSection redSection = (NScaleSection)scale.Sections[1]; m_FirstIndicatorAngle += 0.02; valueIndicator.Value = 50.0 - Math.Cos(m_FirstIndicatorAngle) * 50.0; // FIX: Smart Shapes if (blueSection.Range.Contains(valueIndicator.Value)) { // valueIndicator.Shape.FillStyle = new NStockGradientFill(ENGradientStyle.Horizontal, ENGradientVariant.Variant1, NColor.White, NColor.Blue); // valueIndicator.Shape.StrokeStyle = new NStrokeStyle(Color.Blue); } else if (redSection.Range.Contains(valueIndicator.Value)) { // valueIndicator.Shape.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.White, Color.Red); // valueIndicator.Shape.StrokeStyle = new NStrokeStyle(Color.Red); } else { // valueIndicator.Shape.FillStyle = new NColorFillStyle(Color.LightGreen); // valueIndicator.Shape.StrokeStyle = new NStrokeStyle(Color.DarkGreen); } } }