Ejemplo n.º 1
0
        private void ConfigureAnnotations()
        {
            m_RectangularCallout                  = new NRectangularCallout();
            m_RectangularCallout.ArrowLength      = new NLength(15, NRelativeUnit.ParentPercentage);
            m_RectangularCallout.FillStyle        = new NGradientFillStyle(Color.FromArgb(125, Color.White), Color.FromArgb(125, Color.CadetBlue));
            m_RectangularCallout.UseAutomaticSize = true;
            m_RectangularCallout.Orientation      = 225;
            m_RectangularCallout.Anchor           = new NDataPointAnchor(m_Bar, 2, ContentAlignment.MiddleCenter, StringAlignment.Center);
            m_RectangularCallout.Text             = GetTextForAnnotation(m_RectangularCallout);
            nChartControl1.Panels.Add(m_RectangularCallout);

            m_RoundedRectangularCallout                  = new NRoundedRectangularCallout();
            m_RoundedRectangularCallout.ArrowLength      = new NLength(15, NRelativeUnit.ParentPercentage);
            m_RoundedRectangularCallout.FillStyle        = new NGradientFillStyle(Color.FromArgb(125, Color.White), Color.FromArgb(125, Color.LightGreen));
            m_RoundedRectangularCallout.UseAutomaticSize = true;
            m_RoundedRectangularCallout.Orientation      = 135;
            m_RoundedRectangularCallout.Anchor           = new NModelPointAnchor(m_Chart, new NVector3DF(0, 0, 0));
            m_RoundedRectangularCallout.Text             = GetTextForAnnotation(m_RoundedRectangularCallout);
            nChartControl1.Panels.Add(m_RoundedRectangularCallout);

            m_CutEdgeRectangularCallout                  = new NCutEdgeRectangularCallout();
            m_CutEdgeRectangularCallout.FillStyle        = new NGradientFillStyle(Color.FromArgb(125, Color.White), Color.FromArgb(125, Color.LightBlue));
            m_CutEdgeRectangularCallout.ArrowLength      = new NLength(40, NRelativeUnit.ParentPercentage);
            m_CutEdgeRectangularCallout.UseAutomaticSize = true;
            m_CutEdgeRectangularCallout.Orientation      = 190;
            m_CutEdgeRectangularCallout.Anchor           = new NLegendDataItemAnchor(m_Legend, 1);
            m_CutEdgeRectangularCallout.Text             = GetTextForAnnotation(m_CutEdgeRectangularCallout);
            nChartControl1.Panels.Add(m_CutEdgeRectangularCallout);

            m_OvalCallout                  = new NOvalCallout();
            m_OvalCallout.FillStyle        = new NColorFillStyle(Color.FromArgb(200, Color.AliceBlue));
            m_OvalCallout.ArrowLength      = new NLength(15, NRelativeUnit.ParentPercentage);
            m_OvalCallout.UseAutomaticSize = true;
            m_OvalCallout.Orientation      = 315;
            m_OvalCallout.Anchor           = new NScalePointAnchor(m_Chart,
                                                                   (int)StandardAxis.PrimaryX,
                                                                   (int)StandardAxis.PrimaryY,
                                                                   (int)StandardAxis.Depth,
                                                                   AxisValueAnchorMode.Clip, new NVector3DD(7, 100, 0));

            m_OvalCallout.Text = GetTextForAnnotation(m_OvalCallout);
            nChartControl1.Panels.Add(m_OvalCallout);

            m_ArrowAnnotation = new NArrowAnnotation();
            m_ArrowAnnotation.UseAutomaticSize           = true;
            m_ArrowAnnotation.ArrowHeadWidthPercent      = 30;
            m_ArrowAnnotation.TextStyle.FontStyle.EmSize = new NLength(11, NGraphicsUnit.Point);
            m_ArrowAnnotation.TextStyle.FontStyle.Style |= FontStyle.Bold;
            m_ArrowAnnotation.Orientation = 45;
            m_ArrowAnnotation.FillStyle   = new NGradientFillStyle(GradientStyle.Vertical, GradientVariant.Variant1, Color.FromArgb(125, Color.White), Color.FromArgb(125, Color.Orange));
            m_ArrowAnnotation.Anchor      = new NDataPointAnchor(m_Bar, 4, ContentAlignment.MiddleCenter, StringAlignment.Center);
            m_ArrowAnnotation.Text        = GetTextForAnnotation(m_ArrowAnnotation);
            nChartControl1.Panels.Add(m_ArrowAnnotation);

            nChartControl1.Controller.Selection.Clear();
            nChartControl1.Controller.Selection.Add(m_Chart);

            nChartControl1.Controller.Tools.Add(new NTrackballTool());
        }
Ejemplo n.º 2
0
        private void GenerateDateLabels(int nTotalDays)
        {
            // the chart starts with the first monday of june 2003
            DateTime   dt        = new DateTime(2003, 6, 2);
            TimeSpan   daySpan   = new TimeSpan(1, 0, 0, 0);
            NFontStyle labelFont = new NFontStyle("Arial", 9, FontStyle.Bold);
            NAxis      axisX1    = m_Chart.Axis(StandardAxis.PrimaryX);
            NLinearScaleConfigurator linearScale = axisX1.ScaleConfigurator as NLinearScaleConfigurator;
            int nCurCategory = 0;

            m_Chart.ChildPanels.Clear();

            for (int i = 0; i < nTotalDays; i++)
            {
                // add a custom label for the first work day of the month
                if ((dt.Day == 1) ||
                    ((dt.DayOfWeek == DayOfWeek.Monday) && (dt.Day == 2 || dt.Day == 3)))
                {
                    NRectangularCallout callout = new NRectangularCallout();
                    callout.Anchor      = new NAxisValueAnchor(axisX1, AxisValueAnchorMode.Clamp, nCurCategory);
                    callout.Orientation = 270;

                    callout.TextStyle.FontStyle = labelFont;
                    callout.Text = dt.ToString("MMM yyyy");
                    callout.StrokeStyle.Color   = Color.DarkSeaGreen;
                    callout.StrokeStyle.Pattern = LinePattern.Dot;
                    callout.ArrowBasePercent    = 0;
                    callout.UseAutomaticSize    = true;

                    m_Chart.ChildPanels.Add(callout);

                    NAxisConstLine cl = axisX1.ConstLines.Add();
                    cl.Value             = nCurCategory;
                    cl.StrokeStyle.Color = Color.DarkSeaGreen;
                }

                if (dt.DayOfWeek == DayOfWeek.Monday)
                {
                    if ((dt.Day == 1) || (dt.Day == 2) || (dt.Day == 3))
                    {
                        linearScale.Labels.Add("");
                        nCurCategory++;
                    }
                    else
                    {
                        linearScale.Labels.Add(dt.Day.ToString());
                        nCurCategory++;
                    }
                }
                else if (dt.DayOfWeek == DayOfWeek.Saturday)
                {
                }
                else if (dt.DayOfWeek == DayOfWeek.Sunday)
                {
                }
                else
                {
                    nCurCategory++;
                }

                dt += daySpan;
            }
        }
Ejemplo n.º 3
0
        public override void Initialize()
        {
            base.Initialize();

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Annotation Drag Tool");

            title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic);
            title.ContentAlignment    = ContentAlignment.BottomCenter;
            title.Location            = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage));

            // no legend
            nChartControl1.Legends.Clear();

            // setup chart
            NChart chart = nChartControl1.Charts[0];

            chart.BoundsMode = BoundsMode.Stretch;

            // configure the x scale
            NLinearScaleConfigurator xScale = new NLinearScaleConfigurator();

            xScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
            chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = xScale;

            // configure the y scale
            NLinearScaleConfigurator yScale = new NLinearScaleConfigurator();

            NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1);

            stripStyle.SetShowAtWall(ChartWallType.Back, true);
            stripStyle.SetShowAtWall(ChartWallType.Left, true);
            stripStyle.Interlaced = true;
            yScale.StripStyles.Add(stripStyle);

            yScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
            chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = yScale;

            // Create a point series
            NPointSeries point = (NPointSeries)chart.Series.Add(SeriesType.Point);

            point.InflateMargins         = true;
            point.UseXValues             = true;
            point.Name                   = "Series 1";
            point.DataLabelStyle.Visible = false;

            // Add some data
            point.Values.Add(31);
            point.Values.Add(67);
            point.Values.Add(12);
            point.Values.Add(84);
            point.Values.Add(90);

            point.XValues.Add(5);
            point.XValues.Add(36);
            point.XValues.Add(51);
            point.XValues.Add(76);
            point.XValues.Add(93);

            m_Callout1 = new NRectangularCallout();
            m_Callout1.UseAutomaticSize = true;
            m_Callout1.Text             = "Annotation 1";
            m_Callout1.Orientation      = 125;
            m_Callout1.ArrowLength      = new NLength(40, NGraphicsUnit.Point);
            m_Callout1.Anchor           = new NScalePointAnchor(chart, (int)StandardAxis.PrimaryX, (int)StandardAxis.PrimaryY, (int)StandardAxis.Depth, AxisValueAnchorMode.Clip, new Nevron.GraphicsCore.NVector3DD(36, 67, 0));
            chart.ChildPanels.Add(m_Callout1);

            m_Callout2 = new NRectangularCallout();
            m_Callout2.UseAutomaticSize = true;
            m_Callout2.Text             = "Annotation 2";
            m_Callout1.Orientation      = 45;
            m_Callout2.ArrowLength      = new NLength(40, NGraphicsUnit.Point);
            m_Callout2.Anchor           = new NScalePointAnchor(chart, (int)StandardAxis.PrimaryX, (int)StandardAxis.PrimaryY, (int)StandardAxis.Depth, AxisValueAnchorMode.Clip, new Nevron.GraphicsCore.NVector3DD(76, 84, 0));
            chart.ChildPanels.Add(m_Callout2);

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

            styleSheet.Apply(nChartControl1.Document);

            nChartControl1.Controller.Tools.Add(new NSelectorTool());
            nChartControl1.Controller.Tools.Add(new NCalloutDragTool());

            AllowDragAnnotation1CheckBox.Checked = true;
            AllowDragAnnotation2CheckBox.Checked = true;
        }
        private void ConfigureAnnotations()
        {
            if (rectPanelCheck.Checked)
            {
                nRectangularCallout                            = new NRectangularCallout();
                nRectangularCallout.ArrowLength                = new NLength(15, NRelativeUnit.ParentPercentage);
                nRectangularCallout.FillStyle                  = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.FromArgb(125, Color.White), Color.FromArgb(125, Color.CadetBlue));
                nRectangularCallout.UseAutomaticSize           = true;
                nRectangularCallout.Orientation                = 225;
                nRectangularCallout.Anchor                     = new NDataPointAnchor(nBar, 2, ContentAlignment.MiddleCenter, StringAlignment.Center);
                nRectangularCallout.Text                       = GetTextForAnnotation(nRectangularCallout);
                nRectangularCallout.TextStyle.FontStyle.EmSize = new NLength(8);
                nChartControl1.Panels.Add(nRectangularCallout);
            }

            if (roundRectCalloutCheck.Checked)
            {
                nRoundedRectangularCallout                            = new NRoundedRectangularCallout();
                nRoundedRectangularCallout.ArrowLength                = new NLength(15, NRelativeUnit.ParentPercentage);
                nRoundedRectangularCallout.FillStyle                  = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.FromArgb(125, Color.White), Color.FromArgb(125, Color.LightGreen));
                nRoundedRectangularCallout.UseAutomaticSize           = true;
                nRoundedRectangularCallout.Orientation                = 135;
                nRoundedRectangularCallout.Anchor                     = new NModelPointAnchor(nChart, new NVector3DF(0, 0, 0));
                nRoundedRectangularCallout.Text                       = GetTextForAnnotation(nRoundedRectangularCallout);
                nRoundedRectangularCallout.TextStyle.FontStyle.EmSize = new NLength(8);
                nChartControl1.Panels.Add(nRoundedRectangularCallout);
            }

            if (cutedgeRectPanelCheck.Checked)
            {
                nCutEdgeRectangularCallout                            = new NCutEdgeRectangularCallout();
                nCutEdgeRectangularCallout.FillStyle                  = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.FromArgb(125, Color.White), Color.FromArgb(125, Color.LightBlue));
                nCutEdgeRectangularCallout.ArrowLength                = new NLength(40, NRelativeUnit.ParentPercentage);
                nCutEdgeRectangularCallout.UseAutomaticSize           = true;
                nCutEdgeRectangularCallout.Orientation                = 190;
                nCutEdgeRectangularCallout.Anchor                     = new NLegendDataItemAnchor(nLegend, 1);
                nCutEdgeRectangularCallout.Text                       = GetTextForAnnotation(nCutEdgeRectangularCallout);
                nCutEdgeRectangularCallout.TextStyle.FontStyle.EmSize = new NLength(8);
                nChartControl1.Panels.Add(nCutEdgeRectangularCallout);
            }

            if (ovalPanelCheck.Checked)
            {
                nOvalCallout                  = new NOvalCallout();
                nOvalCallout.FillStyle        = new NColorFillStyle(Color.FromArgb(200, Color.AliceBlue));
                nOvalCallout.ArrowLength      = new NLength(15, NRelativeUnit.ParentPercentage);
                nOvalCallout.UseAutomaticSize = true;
                nOvalCallout.Orientation      = 315;
                nOvalCallout.Anchor           = new NScalePointAnchor(nChart,
                                                                      (int)StandardAxis.PrimaryX,
                                                                      (int)StandardAxis.PrimaryY,
                                                                      (int)StandardAxis.Depth,
                                                                      AxisValueAnchorMode.Clip,
                                                                      new NVector3DD(7, 100, 0));
                nOvalCallout.Text = GetTextForAnnotation(nOvalCallout);
                nOvalCallout.TextStyle.FontStyle.EmSize = new NLength(8);
                nChartControl1.Panels.Add(nOvalCallout);
            }

            if (arrowCheck.Checked)
            {
                nArrowAnnotation = new NArrowAnnotation();
                nArrowAnnotation.UseAutomaticSize           = true;
                nArrowAnnotation.ArrowHeadWidthPercent      = 30;
                nArrowAnnotation.TextStyle.FontStyle.EmSize = new NLength(11, NGraphicsUnit.Point);
                nArrowAnnotation.TextStyle.FontStyle.Style |= FontStyle.Bold;
                nArrowAnnotation.Orientation = 45;
                nArrowAnnotation.FillStyle   = new NGradientFillStyle(GradientStyle.Vertical, GradientVariant.Variant1, Color.FromArgb(125, Color.White), Color.FromArgb(125, Color.Orange));
                nArrowAnnotation.Anchor      = new NDataPointAnchor(nBar, 4, ContentAlignment.MiddleCenter, StringAlignment.Center);
                nArrowAnnotation.Text        = GetTextForAnnotation(nArrowAnnotation);
                nArrowAnnotation.TextStyle.FontStyle.EmSize = new NLength(8);
                nChartControl1.Panels.Add(nArrowAnnotation);
            }
        }