private void AddRangeIndicatorToGauge(NGaugePanel gauge)
        {
            // add some indicators
            NRangeIndicator rangeIndicator = new NRangeIndicator(new NRange1DD(75, 100));

            rangeIndicator.FillStyle         = new NColorFillStyle(Color.Red);
            rangeIndicator.StrokeStyle.Width = new NLength(0);
            rangeIndicator.BeginWidth        = new NLength(5);
            rangeIndicator.EndWidth          = new NLength(10);
            rangeIndicator.OffsetFromScale   = new NLength(-10);
            rangeIndicator.PaintOrder        = IndicatorPaintOrder.BeforeScale;

            gauge.Indicators.Add(rangeIndicator);
        }
        protected static void UpdateIndicators(NDocument document)
        {
            NLineSeries line = (NLineSeries)document.RootPanel.Charts[0].Series[0];

            double min = (double)line.Values[line.Values.FindMinValue()];
            double max = (double)line.Values[line.Values.FindMaxValue()];

            NGaugePanel panel1 = document.RootPanel.ChildPanels[2] as NGaugePanel;
            NGaugePanel panel2 = document.RootPanel.ChildPanels[3] as NGaugePanel;
            NGaugePanel panel3 = document.RootPanel.ChildPanels[4] as NGaugePanel;

            NNeedleValueIndicator minIndicator = panel1.Indicators[1] as NNeedleValueIndicator;
            NNeedleValueIndicator maxIndicator = panel2.Indicators[1] as NNeedleValueIndicator;
            NNeedleValueIndicator avgIndicator = panel3.Indicators[1] as NNeedleValueIndicator;

            minIndicator.OffsetOriginMode = IndicatorOffsetOriginMode.ScaleBegin;
            maxIndicator.OffsetOriginMode = IndicatorOffsetOriginMode.ScaleBegin;
            avgIndicator.OffsetOriginMode = IndicatorOffsetOriginMode.ScaleBegin;

            minIndicator.Value = min;
            maxIndicator.Value = max;

            int    count = line.Values.Count;
            double sum   = 0;

            for (int i = 0; i < count; i++)
            {
                sum += (double)line.Values[i];
            }

            if (count > 0)
            {
                avgIndicator.Value = sum / count;
            }
            else
            {
                avgIndicator.Value = 0;
            }
        }
Exemplo n.º 3
0
        private void UpdateSections()
        {
            for (int i = 0; i < nChartControl1.Panels.Count; i++)
            {
                NGaugePanel panel = nChartControl1.Panels[i] as NGaugePanel;

                if (panel != null)
                {
                    NGaugeAxis axis = (NGaugeAxis)panel.Axes[0];
                    NStandardScaleConfigurator scale = (NStandardScaleConfigurator)axis.ScaleConfigurator;

                    if (scale.Sections.Count == 2)
                    {
                        NScaleSectionStyle blueSection = (NScaleSectionStyle)scale.Sections[0];
                        blueSection.Range = new NRange1DD((double)BlueSectionBeginUpDown.Value, (double)BlueSectionEndUpDown.Value);

                        NScaleSectionStyle redSection = (NScaleSectionStyle)scale.Sections[1];
                        redSection.Range = new NRange1DD((double)RedSectionBeginUpDown.Value, (double)RedSectionEndUpDown.Value);
                    }
                }
            }

            nChartControl1.Refresh();
        }
 void INIndicatorDragCallback.OnIndicatorValueChanged(NThinChartControl control, NGaugePanel gauge, NIndicator indicator, double oldValue, double newValue)
 {
     control.NumericDisplays[0].Value = indicator.Value;
 }
Exemplo n.º 5
0
        private void CalculateIndicatorValue(NGaugePanel gauge, NSeries series)
        {
            NNeedleValueIndicator needle = gauge.Indicators[0] as NNeedleValueIndicator;

            needle.Value = 50;            // CalculateIndicatorValue(series);
        }
Exemplo n.º 6
0
 void INIndicatorDragCallback.OnIndicatorValueChanged(NThinChartControl control, NGaugePanel gauge, NIndicator indicator, double oldValue, double newValue)
 {
     control.AddCustomClientCommand(newValue.ToString("00.00"));
 }
Exemplo n.º 7
0
        private void timer1_Tick(object sender, System.EventArgs e)
        {
            if (nChartControl1.Panels.Count < 3)
            {
                return;
            }

            // update linear gauge
            NGaugePanel panel = nChartControl1.Panels[1] as NGaugePanel;

            if (panel != null)
            {
                NValueIndicator            valueIndicator = (NValueIndicator)panel.Indicators[0];
                NStandardScaleConfigurator scale          = (NStandardScaleConfigurator)((NGaugeAxis)panel.Axes[0]).ScaleConfigurator;
                NScaleSectionStyle         blueSection    = (NScaleSectionStyle)scale.Sections[0];
                NScaleSectionStyle         redSection     = (NScaleSectionStyle)scale.Sections[1];

                m_FirstIndicatorAngle += 0.02f;
                valueIndicator.Value   = 50 - Math.Cos(m_FirstIndicatorAngle) * 50;

                if (blueSection.Range.Contains(valueIndicator.Value))
                {
                    valueIndicator.Shape.FillStyle   = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.White, Color.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);
                }
            }

            // update radial gauge
            panel = nChartControl1.Panels[2] as NGaugePanel;
            if (panel != null)
            {
                NStandardScaleConfigurator scale          = (NStandardScaleConfigurator)((NGaugeAxis)panel.Axes[0]).ScaleConfigurator;
                NValueIndicator            valueIndicator = (NValueIndicator)panel.Indicators[0];
                NScaleSectionStyle         blueSection    = (NScaleSectionStyle)scale.Sections[0];
                NScaleSectionStyle         redSection     = (NScaleSectionStyle)scale.Sections[1];

                m_SecondIndicatorAngle += 0.02f;
                valueIndicator.Value    = 50 - Math.Cos(m_SecondIndicatorAngle) * 50;

                if (blueSection.Range.Contains(valueIndicator.Value))
                {
                    valueIndicator.Shape.FillStyle   = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.White, Color.Blue);
                    valueIndicator.Shape.StrokeStyle = new NStrokeStyle(Color.DarkBlue);
                }
                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.DarkRed);
                }
                else
                {
                    valueIndicator.Shape.FillStyle   = new NColorFillStyle(Color.LightGreen);
                    valueIndicator.Shape.StrokeStyle = new NStrokeStyle(Color.DarkGreen);
                }

                valueIndicator.Shape.StrokeStyle = new NStrokeStyle(Color.White);
            }

            nChartControl1.Refresh();
        }