Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected override NWidget CreateExampleContent()
        {
            NChartView chartView = CreateCartesianChartView();

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

            // configure chart
            m_Chart = (NCartesianChart)chartView.Surface.Charts[0];
            m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XYLinear);

            NCartesianAxis primaryX = m_Chart.Axes[ENCartesianAxis.PrimaryX];
            NCartesianAxis primaryY = m_Chart.Axes[ENCartesianAxis.PrimaryY];

            // configure axes
            NLinearScale yScale = (NLinearScale)primaryY.Scale;

            yScale.MajorGridLines = CreateDottedGrid();

            NScaleStrip yStrip = new NScaleStrip(new NColorFill(new NColor(NColor.LightGray, 40)), null, true, 0, 0, 1, 1);

            yStrip.Interlaced = true;
            yScale.Strips.Add(yStrip);

            NLinearScale xScale = (NLinearScale)primaryX.Scale;

            xScale.MajorGridLines = CreateDottedGrid();

            NScaleStrip xStrip = new NScaleStrip(new NColorFill(new NColor(NColor.LightGray, 40)), null, true, 0, 0, 1, 1);

            xStrip.Interlaced = true;
            xScale.Strips.Add(xStrip);

            // cross X and Y axes
            primaryX.Anchor = new NModelCrossCartesianAxisAnchor(0, ENAxisCrossAlignment.Center, primaryY, ENCartesianAxisOrientation.Horizontal, ENScaleOrientation.Right, 0.0f, 100.0f);

            primaryY.Anchor = new NModelCrossCartesianAxisAnchor(0, ENAxisCrossAlignment.Center, primaryX, ENCartesianAxisOrientation.Vertical, ENScaleOrientation.Left, 0.0f, 100.0f);

            // setup bubble series
            NBubbleSeries bubble = new NBubbleSeries();

            bubble.Name           = "Bubble Series";
            bubble.InflateMargins = true;
            bubble.DataLabelStyle = new NDataLabelStyle(false);
            bubble.UseXValues     = true;

            // fill with random data
            Random random = new Random();

            for (int i = 0; i < 10; i++)
            {
                bubble.DataPoints.Add(new NBubbleDataPoint(random.Next(-20, 20), random.Next(-20, 20), random.Next(1, 6)));
            }

            m_Chart.Series.Add(bubble);

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

            return(chartView);
        }
Ejemplo n.º 2
0
        private NCartesianAxis CreateLinearAxis(ENCartesianAxisDockZone dockZone, NColor color)
        {
            NCartesianAxis axis = new NCartesianAxis();

            axis.Scale  = CreateLinearScale(color);
            axis.Anchor = new NDockCartesianAxisAnchor(dockZone);

            return(axis);
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected override NWidget CreateExampleContent()
        {
            NChartView chartView = CreateCartesianChartView();

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

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

            m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.PrimaryAndSecondaryLinear);

            for (int i = 0; i < m_Chart.Axes.Count; i++)
            {
                // configure the axes
                NCartesianAxis axis = m_Chart.Axes[i];

                // set the range to [0, 100]
                axis.ViewRangeMode     = ENAxisViewRangeMode.FixedRange;
                axis.MinViewRangeValue = 0;
                axis.MaxViewRangeValue = 100;

                NLinearScale linearScale = (NLinearScale)axis.Scale;

                string title = string.Empty;
                switch (i)
                {
                case 0:
                    title = "Primary Y";
                    break;

                case 1:
                    title = "Primary X";
                    break;

                case 2:
                    title = "Secondary Y";
                    break;

                case 3:
                    title = "Secondary X";
                    break;
                }

                linearScale.Title.Text                     = title;
                linearScale.MinTickDistance                = 30;
                linearScale.Labels.Style.Angle             = new NScaleLabelAngle(ENScaleLabelAngleMode.Scale, 0, false);
                linearScale.Labels.Style.AlwaysInsideScale = true;
                linearScale.Labels.OverlapResolveLayouts   = new NDomArray <ENLevelLabelsLayout>(new ENLevelLabelsLayout[] { ENLevelLabelsLayout.Stagger2 });
            }

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

            return(chartView);
        }
Ejemplo n.º 4
0
        private void UpdateRulerStyleForAxis(NCartesianAxis axis)
        {
            NStandardScale scale = (NStandardScale)axis.Scale;

            NSize capSize = new NSize(m_SizeUpDown.Value, m_SizeUpDown.Value);

            // apply style to begin and end caps
            scale.Ruler.BeginCap           = new NRulerCapStyle((ENCapShape)m_BeginCapShapeComboBox.SelectedIndex, capSize, 0, new NColorFill(NColor.Black), new NStroke(NColor.Black));
            scale.Ruler.EndCap             = new NRulerCapStyle((ENCapShape)m_EndCapShapeComboBox.SelectedIndex, capSize, 3, new NColorFill(NColor.Black), new NStroke(NColor.Black));
            scale.Ruler.ScaleBreakCap      = new NRulerCapStyle((ENCapShape)m_ScaleBreakCapShapeComboBox.SelectedIndex, capSize, 0, new NColorFill(NColor.Black), new NStroke(NColor.Black));
            scale.Ruler.PaintOnScaleBreaks = m_PaintOnScaleBreaksCheckBox.Checked;
        }
Ejemplo n.º 5
0
        protected override NWidget CreateExampleContent()
        {
            NChartView chartView = CreateCartesianChartView();

            // configure title
            chartView.Surface.Titles[0].Text = "Area Palette";

            // configure chart
            m_Chart = (NCartesianChart)chartView.Surface.Charts[0];
            m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XOrdinalYLinear);

            // add interlace stripe
            NLinearScale linearScale = m_Chart.Axes[ENCartesianAxis.PrimaryY].Scale as NLinearScale;
            NScaleStrip  strip       = new NScaleStrip(new NColorFill(ENNamedColor.Beige), null, true, 0, 0, 1, 1);

            strip.Interlaced = true;
            linearScale.Strips.Add(strip);

            // setup an area series
            m_Area                = new NAreaSeries();
            m_Area.Name           = "Area Series";
            m_Area.InflateMargins = true;
            m_Area.UseXValues     = false;
            m_Area.DataLabelStyle = new NDataLabelStyle(false);

            m_Area.Palette = new NColorValuePalette(new NColorValuePair[] { new NColorValuePair(0, NColor.Green), new NColorValuePair(60, NColor.Yellow), new NColorValuePair(120, NColor.Red) });

            m_AxisRange = new NRange(0, 130);

            // limit the axis range to 0, 130
            NCartesianAxis yAxis = m_Chart.Axes[ENCartesianAxis.PrimaryY];

            yAxis.ViewRangeMode     = ENAxisViewRangeMode.FixedRange;
            yAxis.MinViewRangeValue = m_AxisRange.Begin;
            yAxis.MaxViewRangeValue = m_AxisRange.End;
            m_Chart.Series.Add(m_Area);

            int indicatorCount = 10;

            m_IndicatorPhase = new double[indicatorCount];

            // add some data to the area series
            for (int i = 0; i < indicatorCount; i++)
            {
                m_IndicatorPhase[i] = i * 30;
                m_Area.DataPoints.Add(new NAreaDataPoint(0));
            }

            return(chartView);
        }
Ejemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected override NWidget CreateExampleContent()
        {
            NChartView chartView = CreateCartesianChartView();

            // configure title
            chartView.Surface.Titles[0].Text = "Value Timeline Scale";

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

            // configure axes
            m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XOrdinalYLinear);

            // setup X axis
            NCartesianAxis axis = m_Chart.Axes[ENCartesianAxis.PrimaryX];

            m_TimeLineScale = new NValueTimelineScale();
            axis.Scale      = m_TimeLineScale;

            // setup primary Y axis
            axis = m_Chart.Axes[ENCartesianAxis.PrimaryY];
            NLinearScale linearScale = (NLinearScale)axis.Scale;

            // configure ticks and grid lines
            linearScale.MajorGridLines.Stroke   = new NStroke(NColor.LightGray);
            linearScale.InnerMajorTicks.Visible = false;

            // add interlaced stripe
            NScaleStrip strip = new NScaleStrip();

            strip.Fill       = new NColorFill(NColor.Beige);
            strip.Interlaced = true;
            linearScale.Strips.Add(strip);

            // Setup the stock series
            m_Stock = new NStockSeries();
            m_Chart.Series.Add(m_Stock);

            m_Stock.DataLabelStyle = new NDataLabelStyle(false);
            m_Stock.CandleShape    = ENCandleShape.Stick;
            m_Stock.CandleWidth    = 4;
            m_Stock.UseXValues     = true;

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

            OnWeeklyDataButtonClick(null);

            return(chartView);
        }
Ejemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected override NWidget CreateExampleContent()
        {
            NChartView chartView = CreateCartesianChartView();

            // configure title
            chartView.Surface.Titles[0].Text = "Candle Stock";

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

            m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XYLinear);

            // setup X axis
            NCartesianAxis axis = m_Chart.Axes[ENCartesianAxis.PrimaryX];

            axis.Scale = new NValueTimelineScale();

            // setup primary Y axis
            axis = m_Chart.Axes[ENCartesianAxis.PrimaryY];
            NLinearScale linearScale = (NLinearScale)axis.Scale;

            // configure ticks and grid lines
            linearScale.MajorGridLines.Stroke   = new NStroke(NColor.LightGray);
            linearScale.InnerMajorTicks.Visible = false;

            // add interlaced stripe
            NScaleStrip strip = new NScaleStrip();

            strip.Fill       = new NColorFill(NColor.Beige);
            strip.Interlaced = true;
            linearScale.Strips.Add(strip);

            // Setup the stock series
            m_Stock = new NStockSeries();
            m_Chart.Series.Add(m_Stock);

            m_Stock.DataLabelStyle = new NDataLabelStyle(false);
            m_Stock.CandleShape    = ENCandleShape.Rectangle;
            m_Stock.CandleWidth    = 4;
            m_Stock.UseXValues     = true;

            GenerateData();

            return(chartView);
        }
Ejemplo n.º 8
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected override NWidget CreateExampleContent()
        {
            NChartView chartView = CreateCartesianChartView();

            // configure title
            chartView.Surface.Titles[0].Text = "Chart Aspect";

            // configure chart
            NCartesianChart chart = (NCartesianChart)chartView.Surface.Charts[0];

            chart.FitMode = ENCartesianChartFitMode.Aspect;

            // Add a x linear axis
            NCartesianAxis primaryXAxis = new NCartesianAxis();

            primaryXAxis.Anchor = new NDockCartesianAxisAnchor(ENCartesianAxisDockZone.Bottom);
            NLinearScale primaryXScale = new NLinearScale();

            primaryXScale.Title.Text = "X Scale Title";
            primaryXScale.Labels.Style.AlwaysInsideScale = true;
            primaryXScale.Labels.Style.Angle             = new NScaleLabelAngle(ENScaleLabelAngleMode.View, 90, false);
            primaryXAxis.Scale = primaryXScale;
            chart.Axes.Add(primaryXAxis);

            // Add a y linear axis
            NCartesianAxis primaryYAxis = new NCartesianAxis();

            primaryYAxis.Anchor = new NDockCartesianAxisAnchor(ENCartesianAxisDockZone.Left);
            NLinearScale primaryYScale = new NLinearScale();

            primaryYScale.Title.Text  = "Y Scale Title";
            primaryYScale.Title.Angle = new NScaleLabelAngle(ENScaleLabelAngleMode.Scale, 0);
            primaryYScale.Labels.Style.AlwaysInsideScale = true;

            primaryYAxis.Scale = primaryYScale;
            chart.Axes.Add(primaryYAxis);

            // Create the x / y crossed axes
            NCartesianAxis secondaryXAxis  = new NCartesianAxis();
            NLinearScale   secondaryXScale = new NLinearScale();

            secondaryXScale.Labels.Visible = false;
            secondaryXAxis.Scale           = secondaryXScale;
            chart.Axes.Add(secondaryXAxis);

            NCartesianAxis secondaryYAxis  = new NCartesianAxis();
            NLinearScale   secondaryYScale = new NLinearScale();

            secondaryYScale.Labels.Visible = false;
            secondaryYAxis.Scale           = secondaryYScale;
            chart.Axes.Add(secondaryYAxis);

            // cross them
            secondaryXAxis.Anchor = new NValueCrossCartesianAxisAnchor(0, secondaryYAxis, ENCartesianAxisOrientation.Horizontal, ENScaleOrientation.Right, 0, 100);
            secondaryYAxis.Anchor = new NValueCrossCartesianAxisAnchor(0, secondaryXAxis, ENCartesianAxisOrientation.Vertical, ENScaleOrientation.Right, 0, 100);

            // add some dummy data
            NPointSeries point = new NPointSeries();

            chart.Series.Add(point);

            NDataLabelStyle dataLabelStyle = new NDataLabelStyle();

            dataLabelStyle.Visible = false;
            point.DataLabelStyle   = dataLabelStyle;

            point.UseXValues = true;
            point.Size       = 2;

            // add some random data in the range [-100, 100]
            Random rand = new Random();

            for (int i = 0; i < 3000; i++)
            {
                double x = rand.Next(190) - 95;
                double y = rand.Next(190) - 95;
                point.DataPoints.Add(new NPointDataPoint(x, y));
            }

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

            return(chartView);
        }
Ejemplo n.º 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;
            nChartControl1.Panels.Clear();

            // set a chart title
            NLabel header = new NLabel("Axis Ruler Caps<br/> <font size = '9pt'>Demonstrates how to change the caps of the axis ruler</font>");

            header.DockMode                              = PanelDockMode.Top;
            header.TextStyle.FontStyle                   = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
            header.TextStyle.ShadowStyle.Type            = ShadowType.LinearBlur;
            header.TextStyle.TextFormat                  = TextFormat.XML;
            header.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Left;
            header.FitAlignment                          = ContentAlignment.MiddleLeft;
            header.Margins = new NMarginsL(5, 0, 0, 5);

            nChartControl1.Panels.Add(header);

            NCartesianChart chart = new NCartesianChart();

            chart.DockMode   = PanelDockMode.Fill;
            chart.BoundsMode = BoundsMode.Stretch;
            chart.Margins    = new NMarginsL(5, 10, 10, 5);
            nChartControl1.Panels.Add(chart);

            Random random = new Random();

            // feed some random data
            NPointSeries point = new NPointSeries();

            point.DataLabelStyle.Visible = false;
            point.UseXValues             = true;
            point.Size = new NLength(5);
            point.BorderStyle.Width = new NLength(0);

            // fill in some random data
            for (int j = 0; j < 30; j++)
            {
                point.Values.Add(5 + random.Next(90));
                point.XValues.Add(5 + random.Next(90));
            }

            chart.Series.Add(point);

            // configure scales
            NLinearScaleConfigurator xScale = new NLinearScaleConfigurator();

            xScale.RoundToTickMax = true;
            xScale.RoundToTickMin = true;
            xScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
            xScale.ScaleBreaks.Add(new NCustomScaleBreak(new NLineScaleBreakStyle(new NColorFillStyle(Color.FromArgb(124, Color.Orange)), null, new NLength(10)), new NRange1DD(29, 41)));

            // add an interlaced strip to the X axis
            NScaleStripStyle xInterlacedStrip = new NScaleStripStyle();

            xInterlacedStrip.SetShowAtWall(ChartWallType.Back, true);
            xInterlacedStrip.Interlaced = true;
            xInterlacedStrip.FillStyle  = new NColorFillStyle(Color.FromArgb(40, Color.LightGray));
            xScale.StripStyles.Add(xInterlacedStrip);

            NCartesianAxis xAxis = (NCartesianAxis)chart.Axis(StandardAxis.PrimaryX);

            xAxis.ScaleConfigurator = xScale;
            xAxis.View = new NRangeAxisView(new NRange1DD(0, 100));

            NDockAxisAnchor xAxisAnchor = new NDockAxisAnchor(AxisDockZone.FrontBottom);

            xAxisAnchor.BeforeSpace = new NLength(10);
            xAxis.Anchor            = xAxisAnchor;

            NLinearScaleConfigurator yScale = new NLinearScaleConfigurator();

            yScale.RoundToTickMax = true;
            yScale.RoundToTickMin = true;
            yScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
            yScale.ScaleBreaks.Add(new NCustomScaleBreak(new NLineScaleBreakStyle(new NColorFillStyle(Color.FromArgb(124, Color.Orange)), null, new NLength(10)), new NRange1DD(29, 41)));

            // add an interlaced strip to the Y axis
            NScaleStripStyle yInterlacedStrip = new NScaleStripStyle();

            yInterlacedStrip.SetShowAtWall(ChartWallType.Back, true);
            yInterlacedStrip.Interlaced = true;
            yInterlacedStrip.FillStyle  = new NColorFillStyle(Color.FromArgb(40, Color.LightGray));
            yScale.StripStyles.Add(yInterlacedStrip);

            NCartesianAxis yAxis = (NCartesianAxis)chart.Axis(StandardAxis.PrimaryY);

            yAxis.ScaleConfigurator = yScale;
            yAxis.View = new NRangeAxisView(new NRange1DD(0, 100));

            NDockAxisAnchor yAxisAnchor = new NDockAxisAnchor(AxisDockZone.FrontLeft);

            yAxisAnchor.BeforeSpace = new NLength(10);
            yAxis.Anchor            = yAxisAnchor;

            // apply style sheet
            NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh);

            styleSheet.Apply(nChartControl1.Document);

            // update form controls
            if (!IsPostBack)
            {
                PaintOnScaleBreaksCheckBox.Checked = false;

                WebExamplesUtilities.FillComboWithEnumValues(BeginCapStyleDropDownList, typeof(CapStyle));
                BeginCapStyleDropDownList.SelectedIndex = (int)CapStyle.Ellipse;

                WebExamplesUtilities.FillComboWithEnumValues(ScaleBreakCapStyleDropDownList, typeof(CapStyle));
                ScaleBreakCapStyleDropDownList.SelectedIndex = (int)CapStyle.LeftCrossLine;

                WebExamplesUtilities.FillComboWithEnumValues(EndCapStyleDropDownList, typeof(CapStyle));
                EndCapStyleDropDownList.SelectedIndex = (int)CapStyle.Arrow;
            }

            UpdateRulerStyleForAxis(xAxis);
            UpdateRulerStyleForAxis(yAxis);
        }
Ejemplo n.º 10
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected override NWidget CreateExampleContent()
        {
            NChartView chartView = CreateCartesianChartView();

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

            // configure chart
            m_Chart         = (NCartesianChart)chartView.Surface.Charts[0];
            m_Chart.Padding = new NMargins(20);

            // configure axes
            m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XYLinear);

            // feed some random data
            NPointSeries point = new NPointSeries();

            point.UseXValues     = true;
            point.DataLabelStyle = new NDataLabelStyle(false);

            // fill in some random data
            Random random = new Random();

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

            m_Chart.Series.Add(point);

            // X Axis
            NLinearScale xScale = new NLinearScale();

            xScale.MajorGridLines = CreateScaleGrid();

            NCustomScaleBreak xScaleBreak = new NCustomScaleBreak();

            xScaleBreak.Style  = ENScaleBreakStyle.Line;
            xScaleBreak.Fill   = new NColorFill(new NColor(NColor.Orange, 124));
            xScaleBreak.Length = 20;
            xScaleBreak.Range  = new NRange(29, 41);

            xScale.ScaleBreaks.Add(xScaleBreak);

            // add an interlaced strip to the X axis
            NScaleStrip xInterlacedStrip = new NScaleStrip();

            xInterlacedStrip.Interlaced = true;
            xInterlacedStrip.Fill       = new NColorFill(new NColor(NColor.LightGray, 125));

            xScale.Strips.Add(xInterlacedStrip);

            NCartesianAxis xAxis = m_Chart.Axes[ENCartesianAxis.PrimaryX];

            xAxis.Scale = xScale;

//			xAxis.ViewRangeMode = ENAxisViewRangeMode.FixedRange;
//			xAxis.MinViewRangeValue = 0;
//			xAxis.MaxViewRangeValue = 100;

            NDockCartesianAxisAnchor xAxisAnchor = new NDockCartesianAxisAnchor(ENCartesianAxisDockZone.Bottom);

            xAxisAnchor.BeforeSpace = 10;
            xAxis.Anchor            = xAxisAnchor;

            // Y Axis
            NLinearScale yScale = new NLinearScale();

            yScale.MajorGridLines = CreateScaleGrid();

            NCustomScaleBreak yScaleBreak = new NCustomScaleBreak();

            yScaleBreak.Style  = ENScaleBreakStyle.Line;
            yScaleBreak.Fill   = new NColorFill(new NColor(NColor.Orange, 124));
            yScaleBreak.Length = 20;
            yScaleBreak.Range  = new NRange(29, 41);

            yScale.ScaleBreaks.Add(yScaleBreak);

            // add an interlaced strip to the Y axis
            NScaleStrip yInterlacedStrip = new NScaleStrip();

            yInterlacedStrip.Interlaced = true;
            yInterlacedStrip.Fill       = new NColorFill(new NColor(NColor.LightGray, 125));
            yInterlacedStrip.Interval   = 1;
            yInterlacedStrip.Length     = 1;
            yScale.Strips.Add(yInterlacedStrip);

            NCartesianAxis yAxis = m_Chart.Axes[ENCartesianAxis.PrimaryY];

            yAxis.Scale = yScale;

//			yAxis.ViewRangeMode = ENAxisViewRangeMode.FixedRange;
//			yAxis.MinViewRangeValue = 0;
//			yAxis.MaxViewRangeValue = 100;

            NDockCartesianAxisAnchor yAxisAnchor = new NDockCartesianAxisAnchor(ENCartesianAxisDockZone.Left);

            yAxisAnchor.BeforeSpace = 10;
            yAxis.Anchor            = yAxisAnchor;

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

            return(chartView);
        }
Ejemplo n.º 11
0
        public override void Initialize()
        {
            base.Initialize();

            nChartControl1.Panels.Clear();

            // set a chart title
            NLabel title = new NLabel("Axis Ruler Caps<br/> <font size = '9pt'>Demonstrates how to change the caps of the axis ruler</font>");

            title.DockMode             = PanelDockMode.Top;
            title.Margins              = new NMarginsL(10, 10, 10, 10);
            title.TextStyle.TextFormat = TextFormat.XML;
            title.TextStyle.FontStyle  = new NFontStyle("Times New Roman", 18, FontStyle.Italic);
            title.FitAlignment         = ContentAlignment.BottomCenter;
            title.Location             = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage));

            nChartControl1.Panels.Add(title);

            NCartesianChart chart = new NCartesianChart();

            chart.DockMode   = PanelDockMode.Fill;
            chart.BoundsMode = BoundsMode.Stretch;
            chart.Margins    = new NMarginsL(10, 0, 20, 10);
            nChartControl1.Panels.Add(chart);

            Random random = new Random();

            // feed some random data
            NPointSeries point = new NPointSeries();

            point.DataLabelStyle.Visible = false;
            point.UseXValues             = true;
            point.Size = new NLength(5);
            point.BorderStyle.Width = new NLength(0);

            // fill in some random data
            for (int j = 0; j < 30; j++)
            {
                point.Values.Add(5 + random.Next(90));
                point.XValues.Add(5 + random.Next(90));
            }

            chart.Series.Add(point);

            // configure scales
            NLinearScaleConfigurator xScale = new NLinearScaleConfigurator();

            xScale.RoundToTickMax = true;
            xScale.RoundToTickMin = true;
            xScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
            xScale.ScaleBreaks.Add(new NCustomScaleBreak(new NLineScaleBreakStyle(new NColorFillStyle(Color.FromArgb(124, Color.Orange)), null, new NLength(10)), new NRange1DD(29, 41)));

            // add an interlaced strip to the X axis
            NScaleStripStyle xInterlacedStrip = new NScaleStripStyle();

            xInterlacedStrip.SetShowAtWall(ChartWallType.Back, true);
            xInterlacedStrip.Interlaced = true;
            xInterlacedStrip.FillStyle  = new NColorFillStyle(Color.FromArgb(40, Color.LightGray));
            xScale.StripStyles.Add(xInterlacedStrip);

            NCartesianAxis xAxis = (NCartesianAxis)chart.Axis(StandardAxis.PrimaryX);

            xAxis.ScaleConfigurator = xScale;
            xAxis.View = new NRangeAxisView(new NRange1DD(0, 100));

            NDockAxisAnchor xAxisAnchor = new NDockAxisAnchor(AxisDockZone.FrontBottom);

            xAxisAnchor.BeforeSpace = new NLength(10);
            xAxis.Anchor            = xAxisAnchor;

            NLinearScaleConfigurator yScale = new NLinearScaleConfigurator();

            yScale.RoundToTickMax = true;
            yScale.RoundToTickMin = true;
            yScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
            yScale.ScaleBreaks.Add(new NCustomScaleBreak(new NLineScaleBreakStyle(new NColorFillStyle(Color.FromArgb(124, Color.Orange)), null, new NLength(10)), new NRange1DD(29, 41)));

            // add an interlaced strip to the Y axis
            NScaleStripStyle yInterlacedStrip = new NScaleStripStyle();

            yInterlacedStrip.SetShowAtWall(ChartWallType.Back, true);
            yInterlacedStrip.Interlaced = true;
            yInterlacedStrip.FillStyle  = new NColorFillStyle(Color.FromArgb(40, Color.LightGray));
            yScale.StripStyles.Add(yInterlacedStrip);

            NCartesianAxis yAxis = (NCartesianAxis)chart.Axis(StandardAxis.PrimaryY);

            yAxis.ScaleConfigurator = yScale;
            yAxis.View = new NRangeAxisView(new NRange1DD(0, 100));

            NDockAxisAnchor yAxisAnchor = new NDockAxisAnchor(AxisDockZone.FrontLeft);

            yAxisAnchor.BeforeSpace = new NLength(10);
            yAxis.Anchor            = yAxisAnchor;

            // apply style sheet
            NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh);

            styleSheet.Apply(nChartControl1.Document);

            // Init form controls
            BeginCapComboBox.FillFromEnum(typeof(CapStyle));
            EndCapComboBox.FillFromEnum(typeof(CapStyle));
            ScaleBreakCapComboBox.FillFromEnum(typeof(CapStyle));

            BeginCapComboBox.SelectedIndex      = (int)CapStyle.Ellipse;
            EndCapComboBox.SelectedIndex        = (int)CapStyle.Arrow;
            ScaleBreakCapComboBox.SelectedIndex = (int)CapStyle.LeftCrossLine;
            WidthNumericUpDown.Value            = (decimal)5;
            HeightNumericUpDown.Value           = (decimal)5;
        }
        protected override NWidget CreateExampleContent()
        {
            NMemoryDataTable dataTable = new NMemoryDataTable(
                new NFieldInfo("Company", typeof(String)),
                new NFieldInfo("RegionSales", typeof(Double[])));

            Random rnd = new Random();

            for (int i = 0; i < 1000; i++)
            {
                Double[] arr = new Double[10];
                for (int j = 0; j < 10; j++)
                {
                    arr[j] = rnd.Next(100);
                }

                dataTable.AddRow(NDummyDataSource.RandomCompanyName(), arr);
            }

            // create a view and get its grid
            NTableGridView view = new NTableGridView();
            NTableGrid     grid = view.Grid;

            grid.AutoCreateColumn += delegate(NAutoCreateColumnEventArgs arg)
            {
                if (arg.DataColumn.FieldName == "RegionSales")
                {
                    NCustomColumnFormat pieColumnFormat = new NCustomColumnFormat();
                    pieColumnFormat.FormatDefaultDataCellDelegate = delegate(NDataCell theDataCell)
                    {
                        NWidget widget = new NWidget();
                        widget.PreferredSize = new NSize(400, 300);
                    };

                    pieColumnFormat.CreateValueDataCellViewDelegate = delegate(NDataCell theDataCell, object value)
                    {
                        double[] values = (double[])value;

                        NChartView chartView = new NChartView();
                        chartView.PreferredSize = new NSize(300, 60);

                        NCartesianChart cartesianChart = new NCartesianChart();

                        NDockLayout.SetDockArea(cartesianChart, ENDockArea.Center);
                        chartView.Surface.Content = cartesianChart;

                        cartesianChart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XOrdinalYLinear);
                        cartesianChart.Legend = null;

                        cartesianChart.Axes[ENCartesianAxis.PrimaryX].Visible = false;
                        NCartesianAxis yAxis = cartesianChart.Axes[ENCartesianAxis.PrimaryY];

                        NValueScaleLabelStyle labelStyle = new NValueScaleLabelStyle();
                        labelStyle.TextStyle.Font = new NFont("Arimo", 8);
                        ((NLinearScale)yAxis.Scale).Labels.Style = labelStyle;

                        NBarSeries barSeries = new NBarSeries();
                        barSeries.DataLabelStyle = new NDataLabelStyle(false);
                        barSeries.InflateMargins = false;
                        cartesianChart.Series.Add(barSeries);

                        int count = values.Length;
                        for (int i = 0; i < count; i++)
                        {
                            barSeries.DataPoints.Add(new NBarDataPoint(values[i]));
                        }

                        return(chartView);
                    };

                    arg.DataColumn.Format = pieColumnFormat;
                }
            };

            grid.DataSource = new NDataSource(dataTable);
            return(view);
        }
Ejemplo n.º 13
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected override NWidget CreateExampleContent()
        {
            NChartView chartView = CreateCartesianChartView();

            // configure title
            chartView.Surface.Titles[0].Text = "Combo Chart";

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

            m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XOrdinalYLinear);

            // Setup the primary Y axis
            m_Chart.Axes[ENCartesianAxis.PrimaryY].Scale.Title.Text = "Number of Occurences";

            // add interlace stripe
            NScaleStrip strip = new NScaleStrip(new NColorFill(NColor.Beige), null, true, 0, 0, 1, 1);

            strip.Interlaced = true;
            m_Chart.Axes[ENCartesianAxis.PrimaryY].Scale.Strips.Add(strip);

            // Setup the secondary Y axis
            NLinearScale scaleY2 = new NLinearScale();

            scaleY2.Labels.TextProvider = new NFormattedScaleLabelTextProvider(new NNumericValueFormatter("0%"));
            scaleY2.Title.Text          = "Cumulative Percent";

            NCartesianAxis axisY2 = new NCartesianAxis();

            m_Chart.Axes.Add(axisY2);

            axisY2.Anchor            = new NDockCartesianAxisAnchor(ENCartesianAxisDockZone.Right);
            axisY2.Visible           = true;
            axisY2.Scale             = scaleY2;
            axisY2.ViewRangeMode     = ENAxisViewRangeMode.FixedRange;
            axisY2.MinViewRangeValue = 0;
            axisY2.MaxViewRangeValue = 1;

            // add the bar series
            NBarSeries bar = new NBarSeries();

            m_Chart.Series.Add(bar);
            bar.Name           = "Bar Series";
            bar.DataLabelStyle = new NDataLabelStyle(false);

            // add the line series
            NLineSeries line = new NLineSeries();

            m_Chart.Series.Add(line);
            line.Name           = "Cumulative %";
            line.DataLabelStyle = new NDataLabelStyle(false);

            NMarkerStyle markerStyle = new NMarkerStyle();

            markerStyle.Visible = true;
            markerStyle.Shape   = ENPointShape.Ellipse;
            markerStyle.Size    = new NSize(10, 10);
            markerStyle.Fill    = new NColorFill(NColor.Orange);

            line.MarkerStyle = markerStyle;

            line.VerticalAxis = axisY2;

            // fill with random data and sort in descending order
            int            count        = 10;
            NList <double> randomValues = new NList <double>();
            Random         random       = new Random();

            for (int i = 0; i < count; i++)
            {
                randomValues.Add(random.Next(100, 700));
            }

            randomValues.Sort();

            for (int i = 0; i < randomValues.Count; i++)
            {
                bar.DataPoints.Add(new NBarDataPoint(randomValues[i]));
            }

            // calculate cumulative sum of the bar values
            double cs = 0;

            double[] arrCumulative = new double[count];

            for (int i = 0; i < count; i++)
            {
                cs += randomValues[i];
                arrCumulative[i] = cs;
            }

            if (cs > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    arrCumulative[i] /= cs;
                    line.DataPoints.Add(new NLineDataPoint(arrCumulative[i]));
                }
            }

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

            return(chartView);
        }