Beispiel #1
0
        /// <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);
        }
        private NScaleSection CreateSection(NColor tickColor, NColor labelColor, NRange range)
        {
            NScaleSection scaleSection = new NScaleSection();

            scaleSection.Range         = range;
            scaleSection.MajorTickFill = new NColorFill(tickColor);

            NTextStyle labelStyle = new NTextStyle();

            labelStyle.Fill             = new NColorFill(labelColor);
            labelStyle.Font             = new NFont("Arimo", 12, ENFontStyle.Bold);
            scaleSection.LabelTextStyle = labelStyle;

            return(scaleSection);
        }
Beispiel #3
0
        /// <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);
                }
            }
        }
Beispiel #4
0
        private void ApplyScaleSectionToAxis(NLinearScale scale, string text, NRange range, NColor color)
        {
            NScaleSection scaleSection = new NScaleSection();

            scaleSection.Range               = range;
            scaleSection.LabelTextStyle      = new NTextStyle();
            scaleSection.LabelTextStyle.Fill = new  NColorFill(color);
            scaleSection.LabelTextStyle.Font = new NFont("Arimo", 10, ENFontStyle.Bold | ENFontStyle.Italic);
            scaleSection.MajorTickStroke     = new NStroke(color);

            scale.Sections.Add(scaleSection);

            NCustomRangeLabel rangeLabel = new NCustomRangeLabel(range, text);

            rangeLabel.LabelStyle.AlwaysInsideScale = false;
            rangeLabel.LabelStyle.VisibilityMode    = ENScaleLabelVisibilityMode.TextInRuler;
            rangeLabel.LabelStyle.Stroke.Color      = color;
            rangeLabel.LabelStyle.TextStyle.Fill    = new NColorFill(NColor.White);
            rangeLabel.LabelStyle.Angle             = new NScaleLabelAngle(ENScaleLabelAngleMode.Scale, 0);
            rangeLabel.LabelStyle.TickMode          = ENRangeLabelTickMode.Center;

            scale.CustomLabels.Add(rangeLabel);
        }
Beispiel #5
0
        /// <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);
                }
            }
        }
Beispiel #6
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected override NWidget CreateExampleContent()
        {
            NChartView chartView = CreateCartesianChartView();

            // configure title
            chartView.Surface.Titles[0].Text = "Axis Sections";

            m_Chart = (NCartesianChart)chartView.Surface.Charts[0];

            m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XYLinear);

            // create a point series
            NPointSeries point = new NPointSeries();

            point.Name           = "Point Series";
            point.DataLabelStyle = new NDataLabelStyle(false);
            point.Size           = 5;

            Random random = new Random();

            for (int i = 0; i < 30; i++)
            {
                point.DataPoints.Add(new NPointDataPoint(random.Next(100), random.Next(100)));
            }

            point.InflateMargins = true;

            m_Chart.Series.Add(point);

            // tell the x axis to display major and minor grid lines
            NLinearScale linearScale = new NLinearScale();

            m_Chart.Axes[ENCartesianAxis.PrimaryX].Scale = linearScale;
            linearScale.MajorGridLines = new NScaleGridLines();
            linearScale.MajorGridLines.Stroke.DashStyle = ENDashStyle.Solid;
            linearScale.MinorGridLines = new NScaleGridLines();
            linearScale.MinorGridLines.Stroke.DashStyle = ENDashStyle.Dot;
            linearScale.MinorTickCount = 1;

            // tell the y axis to display major and minor grid lines
            linearScale = new NLinearScale();
            m_Chart.Axes[ENCartesianAxis.PrimaryY].Scale = linearScale;
            linearScale.MajorGridLines = new NScaleGridLines();
            linearScale.MajorGridLines.Stroke.DashStyle = ENDashStyle.Solid;
            linearScale.MinorGridLines = new NScaleGridLines();
            linearScale.MinorGridLines.Stroke.DashStyle = ENDashStyle.Dot;
            linearScale.MinorTickCount = 1;

            NTextStyle labelStyle;

            // configure the first horizontal section
            m_FirstHorizontalSection                 = new NScaleSection();
            m_FirstHorizontalSection.Range           = new NRange(2, 8);
            m_FirstHorizontalSection.RangeFill       = new NColorFill(new NColor(NColor.Red, 60));
            m_FirstHorizontalSection.MajorGridStroke = new NStroke(NColor.Red);
            m_FirstHorizontalSection.MajorTickStroke = new NStroke(NColor.DarkRed);
            m_FirstHorizontalSection.MinorTickStroke = new NStroke(1, NColor.Red, ENDashStyle.Dot);

            labelStyle            = new NTextStyle();
            labelStyle.Fill       = new NStockGradientFill(NColor.Red, NColor.DarkRed);
            labelStyle.Font.Style = ENFontStyle.Bold;
            m_FirstHorizontalSection.LabelTextStyle = labelStyle;

            // configure the second horizontal section
            m_SecondHorizontalSection                 = new NScaleSection();
            m_SecondHorizontalSection.Range           = new NRange(14, 18);
            m_SecondHorizontalSection.RangeFill       = new NColorFill(new NColor(NColor.Green, 60));
            m_SecondHorizontalSection.MajorGridStroke = new NStroke(NColor.Green);
            m_SecondHorizontalSection.MajorTickStroke = new NStroke(NColor.DarkGreen);
            m_SecondHorizontalSection.MinorTickStroke = new NStroke(1, NColor.Green, ENDashStyle.Dot);

            labelStyle            = new NTextStyle();
            labelStyle.Fill       = new NStockGradientFill(NColor.Green, NColor.DarkGreen);
            labelStyle.Font.Style = ENFontStyle.Bold;
            m_SecondHorizontalSection.LabelTextStyle = labelStyle;

            // configure the first vertical section
            m_FirstVerticalSection                 = new NScaleSection();
            m_FirstVerticalSection.Range           = new NRange(20, 40);
            m_FirstVerticalSection.RangeFill       = new NColorFill(new NColor(NColor.Blue, 60));
            m_FirstVerticalSection.MajorGridStroke = new NStroke(NColor.Blue);
            m_FirstVerticalSection.MajorTickStroke = new NStroke(NColor.DarkBlue);
            m_FirstVerticalSection.MinorTickStroke = new NStroke(1, NColor.Blue, ENDashStyle.Dot);

            labelStyle            = new NTextStyle();
            labelStyle.Fill       = new NStockGradientFill(NColor.Blue, NColor.DarkBlue);
            labelStyle.Font.Style = ENFontStyle.Bold;
            m_FirstVerticalSection.LabelTextStyle = labelStyle;

            // configure the second vertical section
            m_SecondVerticalSection                 = new NScaleSection();
            m_SecondVerticalSection.Range           = new NRange(70, 90);
            m_SecondVerticalSection.RangeFill       = new NColorFill(new NColor(NColor.Orange, 60));
            m_SecondVerticalSection.MajorGridStroke = new NStroke(NColor.Orange);
            m_SecondVerticalSection.MajorTickStroke = new NStroke(NColor.DarkOrange);
            m_SecondVerticalSection.MinorTickStroke = new NStroke(1, NColor.Orange, ENDashStyle.Dot);

            labelStyle            = new NTextStyle();
            labelStyle.Fill       = new NStockGradientFill(NColor.Orange, NColor.DarkOrange);
            labelStyle.Font.Style = ENFontStyle.Bold;
            m_SecondVerticalSection.LabelTextStyle = labelStyle;

            chartView.Document.StyleSheets.ApplyTheme(new NChartTheme(ENChartPalette.Bright, false));

            return(chartView);
        }