Пример #1
0
        private void UpdateScale()
        {
            // add custom labels to the X axis
            NHierarchicalScaleConfigurator   scale = new NHierarchicalScaleConfigurator();
            NHierarchicalScaleNodeCollection nodes = scale.Nodes;;

            scale.FirstRowGridStyle           = (FirstRowGridStyle)FirstRowSeparatorModeComboBox.SelectedIndex;
            scale.GroupRowGridStyle           = (GroupRowGridStyle)GroupRowSeparatorModeComboBox.SelectedIndex;
            scale.InnerMajorTickStyle.Visible = false;
            scale.OuterMajorTickStyle.Visible = false;

            string[] months = new string[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };

            for (int i = 0; i < 2; i++)
            {
                NHierarchicalScaleNode yearNode = new NHierarchicalScaleNode(0, (i + 2007).ToString());
                yearNode.LabelStyle.TickMode = (RangeLabelTickMode)GroupRowIndividualModeComboBox.SelectedIndex;
                nodes.AddChild(yearNode);

                for (int j = 0; j < 4; j++)
                {
                    NHierarchicalScaleNode quarterNode = new NHierarchicalScaleNode(3, "Q" + (j + 1).ToString());
                    quarterNode.LabelStyle.TickMode = (RangeLabelTickMode)GroupRowIndividualModeComboBox.SelectedIndex;
                    yearNode.ChildNodes.AddChild(quarterNode);

                    for (int k = 0; k < 3; k++)
                    {
                        NHierarchicalScaleNode monthNode = new NHierarchicalScaleNode(1, months[j * 3 + k]);
                        monthNode.LabelStyle.Angle    = new NScaleLabelAngle(90);
                        monthNode.LabelStyle.TickMode = (RangeLabelTickMode)FirstRowIndividualModeComboBox.SelectedIndex;
                        quarterNode.ChildNodes.AddChild(monthNode);
                    }
                }
            }

            // update control state
            FirstRowIndividualModeComboBox.Enabled = ((FirstRowGridStyle)FirstRowSeparatorModeComboBox.SelectedIndex) == FirstRowGridStyle.Individual;
            GroupRowIndividualModeComboBox.Enabled = ((GroupRowGridStyle)GroupRowSeparatorModeComboBox.SelectedIndex) == GroupRowGridStyle.Individual;

            NScaleStripStyle stripStyle = new NScaleStripStyle();

            stripStyle.Length    = 3;
            stripStyle.Interval  = 3;
            stripStyle.FillStyle = new NColorFillStyle(Color.FromArgb(125, Color.LightGray));
            stripStyle.SetShowAtWall(ChartWallType.Back, true);
            scale.StripStyles.Add(stripStyle);

            scale.CreateSeparatorForEachLevel = CreateSeparatorForEachLevelCheckBox.Checked;

            nChartControl1.Charts[0].Axis(StandardAxis.PrimaryX).ScaleConfigurator = scale;
            nChartControl1.Refresh();
        }
        void OnUpdateScale(NValueChangeEventArgs arg)
        {
            // add custom labels to the X axis
            NHierarchicalScale scale = new NHierarchicalScale();
            NHierarchicalScaleNodeCollection nodes = scale.ChildNodes;

            scale.FirstRowGridStyle       = (ENFirstRowGridStyle)m_FirstRowGridStyleComboBox.SelectedIndex;
            scale.GroupRowGridStyle       = (ENGroupRowGridStyle)m_GroupRowGridStyleComboBox.SelectedIndex;
            scale.InnerMajorTicks.Visible = false;
            scale.OuterMajorTicks.Visible = false;

            string[] months = new string[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };

            for (int i = 0; i < 2; i++)
            {
                NHierarchicalScaleNode yearNode = new NHierarchicalScaleNode(0, (i + 2007).ToString());
                yearNode.LabelStyle.TickMode = (ENRangeLabelTickMode)m_GroupRowTickModeComboBox.SelectedIndex;
                nodes.AddChild(yearNode);

                for (int j = 0; j < 4; j++)
                {
                    NHierarchicalScaleNode quarterNode = new NHierarchicalScaleNode(3, "Q" + (j + 1).ToString());
                    quarterNode.LabelStyle.TickMode = (ENRangeLabelTickMode)m_GroupRowTickModeComboBox.SelectedIndex;
                    yearNode.Nodes.Add(quarterNode);

                    for (int k = 0; k < 3; k++)
                    {
                        NHierarchicalScaleNode monthNode = new NHierarchicalScaleNode(1, months[j * 3 + k]);
                        monthNode.LabelStyle.Angle    = new NScaleLabelAngle(90);
                        monthNode.LabelStyle.TickMode = (ENRangeLabelTickMode)m_FirstRowTickModeComboBox.SelectedIndex;
                        quarterNode.Nodes.Add(monthNode);
                    }
                }
            }

            // update control state
            m_FirstRowTickModeComboBox.Enabled = ((ENFirstRowGridStyle)m_FirstRowGridStyleComboBox.SelectedIndex) == ENFirstRowGridStyle.Individual;
            m_GroupRowTickModeComboBox.Enabled = ((ENGroupRowGridStyle)m_GroupRowGridStyleComboBox.SelectedIndex) == ENGroupRowGridStyle.Individual;

            NScaleStrip stripStyle = new NScaleStrip();

            stripStyle.Length   = 3;
            stripStyle.Interval = 3;
            stripStyle.Fill     = new NColorFill(NColor.FromColor(NColor.LightGray, 0.5f));
            scale.Strips.Add(stripStyle);

            scale.CreateSeparatorForEachLevel = m_CreateSeparatorForEachLevelCheckBox.Checked;

            m_Chart.Axes[ENCartesianAxis.PrimaryX].Scale = scale;
        }
        private NHierarchicalScaleNode CreateSubScaleNode(string text, bool beginSeparator, bool endSeparator)
        {
            NHierarchicalScaleNode node = new NHierarchicalScaleNode(1, text);

            if (beginSeparator && endSeparator)
            {
                node.LabelStyle.TickMode = RangeLabelTickMode.Separators;
            }
            else if (beginSeparator)
            {
                node.LabelStyle.TickMode = RangeLabelTickMode.BeginSeparator;
            }
            else if (endSeparator)
            {
                node.LabelStyle.TickMode = RangeLabelTickMode.EndSeparator;
            }

            return(node);
        }
Пример #4
0
        private void UpdateScale()
        {
            // add custom labels to the X axis
            NHierarchicalScaleConfigurator   hirarchicalScale = new NHierarchicalScaleConfigurator();
            NHierarchicalScaleNodeCollection nodes            = hirarchicalScale.Nodes;;

            string[]           months        = new string[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
            RangeLabelTickMode labelTickMode = RangeLabelTickMode.Separators;

            for (int i = 0; i < 2; i++)
            {
                if (!Show2007DataCheckBox.Checked && i == 0)
                {
                    continue;
                }

                NHierarchicalScaleNode yearNode = new NHierarchicalScaleNode(0, (i + 2007).ToString());
                yearNode.LabelStyle.TickMode = labelTickMode;
                nodes.AddChild(yearNode);

                for (int j = 0; j < 4; j++)
                {
                    NHierarchicalScaleNode quarterNode = new NHierarchicalScaleNode(3, "Q" + (j + 1).ToString());
                    quarterNode.LabelStyle.TickMode = labelTickMode;
                    yearNode.ChildNodes.AddChild(quarterNode);

                    for (int k = 0; k < 3; k++)
                    {
                        NHierarchicalScaleNode monthNode = new NHierarchicalScaleNode(1, months[j * 3 + k]);
                        monthNode.LabelStyle.Angle    = new NScaleLabelAngle(90);
                        monthNode.LabelStyle.TickMode = labelTickMode;
                        monthNode.LabelStyle.Offset   = new NLength(1);
                        quarterNode.ChildNodes.AddChild(monthNode);
                    }
                }
            }

            hirarchicalScale.CreateSeparatorForEachLevel = ShowLevelSeparatorsCheckBox.Checked;

            nChartControl1.Charts[0].Axis(StandardAxis.PrimaryX).ScaleConfigurator = hirarchicalScale;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                WebExamplesUtilities.FillComboWithEnumValues(ViewRangeInflateModeDropDownList, typeof(ScaleViewRangeInflateMode));
                ViewRangeInflateModeDropDownList.SelectedIndex = (int)ScaleViewRangeInflateMode.MajorTick;

                InflateMinCheckBox.Checked = true;
                InflateMaxCheckBox.Checked = true;

                WebExamplesUtilities.FillComboWithValues(LogicalInflateMinMaxDropDownList, 0, 200, 10);
                WebExamplesUtilities.FillComboWithValues(AbsoluteInflateMinMaxDropDownList, 0, 20, 2);
            }

            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;
            nChartControl1.Panels.Clear();

            // set a chart title
            NLabel header = new NLabel("Volume Change vs. Last Year<br/> <font size = '9pt'>Demonstrates different view range modes</font>");

            header.TextStyle.TextFormat       = TextFormat.XML;
            header.TextStyle.FontStyle        = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
            header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;
            header.DockMode = PanelDockMode.Top;
            header.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Center;
            header.Margins = new NMarginsL(10, 2, 10, 10);
            nChartControl1.Panels.Add(header);

            // add some data to the control
            NCartesianChart chart = new NCartesianChart();

            chart.DockMode   = PanelDockMode.Fill;
            chart.BoundsMode = BoundsMode.Stretch;

            NBarSeries bar = new NBarSeries();

            bar.DataLabelStyle.Visible = false;

            NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Nevron);

            bar.Values.Add(100);
            bar.FillStyles[0] = new NColorFillStyle(palette.SeriesColors[0]);

            bar.Values.Add(200);
            bar.FillStyles[1] = new NColorFillStyle(palette.SeriesColors[0]);

            bar.Values.Add(-180);
            bar.FillStyles[3] = new NColorFillStyle(palette.SeriesColors[1]);

            bar.Values.Add(200);
            bar.FillStyles[4] = new NColorFillStyle(palette.SeriesColors[1]);

            bar.Values.Add(400);
            bar.FillStyles[5] = new NColorFillStyle(palette.SeriesColors[1]);

            chart.Series.Add(bar);

            chart.Margins = new NMarginsL(10, 0, 10, 10);

            // configure y axis
            NLinearScaleConfigurator linearScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator;

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

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

            // configure the x axis
            NHierarchicalScaleConfigurator hierarchicalScale = new NHierarchicalScaleConfigurator();

            hierarchicalScale.CreateSeparatorForEachLevel = false;

            // create utilization group
            NHierarchicalScaleNode utilization = new NHierarchicalScaleNode(0, "Cash Utilisation");

            utilization.LabelStyle.TickMode = RangeLabelTickMode.Separators;
            utilization.LabelStyle.TextStyle.FontStyle.EmSize = new NLength(11);
            utilization.LabelStyle.TextStyle.FontStyle.Style  = FontStyle.Bold;

            utilization.ChildNodes.Add(CreateSubScaleNode("Cash at ATM", true, false));
            utilization.ChildNodes.Add(CreateSubScaleNode("Cash at desk", true, false));
            hierarchicalScale.Nodes.Add(utilization);

            // create payments group
            NHierarchicalScaleNode payments = new NHierarchicalScaleNode(0, "Payments");

            payments.LabelStyle.TickMode = RangeLabelTickMode.Separators;
            payments.LabelStyle.TextStyle.FontStyle.EmSize = new NLength(11);
            payments.LabelStyle.TextStyle.FontStyle.Style  = FontStyle.Bold;

            payments.ChildNodes.Add(CreateSubScaleNode("Cheque", true, false));
            payments.ChildNodes.Add(CreateSubScaleNode("Direct debit", true, false));
            payments.ChildNodes.Add(CreateSubScaleNode("Wire transfer", true, true));
            hierarchicalScale.Nodes.Add(payments);

            chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = hierarchicalScale;
            nChartControl1.Panels.Add(chart);

            // update form controls
            NAxis yAxis = nChartControl1.Charts[0].Axis(StandardAxis.PrimaryY);
            NNumericScaleConfigurator scale = (NNumericScaleConfigurator)yAxis.ScaleConfigurator;

            scale.Title.Text = "Volume in Thousands USD";

            scale.ViewRangeInflateMode  = (ScaleViewRangeInflateMode)ViewRangeInflateModeDropDownList.SelectedIndex;
            scale.InflateViewRangeBegin = InflateMinCheckBox.Checked;
            scale.InflateViewRangeEnd   = InflateMaxCheckBox.Checked;

            switch (scale.ViewRangeInflateMode)
            {
            case ScaleViewRangeInflateMode.MajorTick:
                break;

            case ScaleViewRangeInflateMode.Logical:
                double logicalInflate = LogicalInflateMinMaxDropDownList.SelectedIndex * 10;
                scale.LogicalInflate = new NRange1DD(logicalInflate, logicalInflate);
                break;

            case ScaleViewRangeInflateMode.Absolute:
                float absoluteInflate = AbsoluteInflateMinMaxDropDownList.SelectedIndex * 2;
                scale.AbsoluteInflate = new NRange1DL(new NLength(absoluteInflate, NGraphicsUnit.Point),
                                                      new NLength(absoluteInflate, NGraphicsUnit.Point));
                break;
            }

            // assign scale configurator to y axis
            yAxis.ScaleConfigurator = scale;

            // update controls state
            LogicalInflateMinMaxDropDownList.Enabled  = scale.ViewRangeInflateMode == ScaleViewRangeInflateMode.Logical;
            AbsoluteInflateMinMaxDropDownList.Enabled = scale.ViewRangeInflateMode == ScaleViewRangeInflateMode.Absolute;
        }
        public override void Initialize()
        {
            base.Initialize();

            nChartControl1.Panels.Clear();

            // set a chart title
            NLabel title = new NLabel("Bank Product and Service Volume Change vs. Last Year<br/> <font size = '9pt'>Demonstrates how to use the view range inflate mode property</font>");

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

            nChartControl1.Panels.Add(title);

            // add some data to the control
            NCartesianChart chart = new NCartesianChart();

            chart.DockMode   = PanelDockMode.Fill;
            chart.BoundsMode = BoundsMode.Stretch;

            NBarSeries bar = new NBarSeries();

            bar.DataLabelStyle.Visible = false;

            NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Fresh);

            bar.Values.Add(100);
            bar.FillStyles[0] = new NColorFillStyle(palette.SeriesColors[0]);

            bar.Values.Add(200);
            bar.FillStyles[1] = new NColorFillStyle(palette.SeriesColors[0]);

            bar.Values.Add(1100);
            bar.FillStyles[2] = new NColorFillStyle(palette.SeriesColors[0]);

            bar.Values.Add(-200);
            bar.FillStyles[3] = new NColorFillStyle(palette.SeriesColors[1]);

            bar.Values.Add(200);
            bar.FillStyles[4] = new NColorFillStyle(palette.SeriesColors[1]);

            bar.Values.Add(1800);
            bar.FillStyles[5] = new NColorFillStyle(palette.SeriesColors[1]);

            bar.Values.Add(1000);
            bar.FillStyles[6] = new NColorFillStyle(palette.SeriesColors[1]);

            bar.Values.Add(-320);
            bar.FillStyles[7] = new NColorFillStyle(palette.SeriesColors[1]);

            chart.Series.Add(bar);

            chart.Margins = new NMarginsL(10, 0, 10, 10);

            // configure y axis
            NLinearScaleConfigurator linearScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator;

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

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

            // configure the x axis
            NHierarchicalScaleConfigurator hierarchicalScale = new NHierarchicalScaleConfigurator();

            hierarchicalScale.CreateSeparatorForEachLevel = false;

            // create utilization group
            NHierarchicalScaleNode utilization = new NHierarchicalScaleNode(0, "Cash Utilisation");

            utilization.LabelStyle.TickMode = RangeLabelTickMode.Separators;
            utilization.LabelStyle.TextStyle.FontStyle.EmSize = new NLength(13);
            utilization.LabelStyle.TextStyle.FontStyle.Style  = FontStyle.Bold;

            utilization.ChildNodes.Add(CreateSubScaleNode("Cash at ATM", true, false));
            utilization.ChildNodes.Add(CreateSubScaleNode("Cash at desk", true, false));
            utilization.ChildNodes.Add(CreateSubScaleNode("Cash at other banks' ATM networks", true, false));
            hierarchicalScale.Nodes.Add(utilization);

            // create payments group
            NHierarchicalScaleNode payments = new NHierarchicalScaleNode(0, "Payments");

            payments.LabelStyle.TickMode = RangeLabelTickMode.Separators;
            payments.LabelStyle.TextStyle.FontStyle.EmSize = new NLength(13);
            payments.LabelStyle.TextStyle.FontStyle.Style  = FontStyle.Bold;

            payments.ChildNodes.Add(CreateSubScaleNode("Cheque", true, false));
            payments.ChildNodes.Add(CreateSubScaleNode("Direct debit", true, false));
            payments.ChildNodes.Add(CreateSubScaleNode("External wire transfer", true, false));
            payments.ChildNodes.Add(CreateSubScaleNode("Internal wire transfer", true, false));
            payments.ChildNodes.Add(CreateSubScaleNode("Standing order ", true, true));
            hierarchicalScale.Nodes.Add(payments);

            chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = hierarchicalScale;
            nChartControl1.Panels.Add(chart);

            // update form controls
            NAxis yAxis = nChartControl1.Charts[0].Axis(StandardAxis.PrimaryY);
            NNumericScaleConfigurator scale = (NNumericScaleConfigurator)yAxis.ScaleConfigurator;

            scale.Title.Text = "Volume in Thousands USD";

            m_Updating = true;

            InflateViewRangeMinCheckBox.Checked = scale.InflateViewRangeBegin;
            InflateViewRangeMaxCheckBox.Checked = scale.InflateViewRangeEnd;

            ViewRangeInflateModeComboBox.FillFromEnum(typeof(ScaleViewRangeInflateMode));
            ViewRangeInflateModeComboBox.SelectedIndex = (int)scale.ViewRangeInflateMode;

            LogicalInflateMinNumericUpDown.Value = (decimal)scale.LogicalInflate.Begin;
            LogicalInflateMaxNumericUpDown.Value = (decimal)scale.LogicalInflate.End;

            AbsoluteInflateMinNumericUpDown.Value = (decimal)scale.AbsoluteInflate.Begin.Value;
            AbsoluteInflateMaxNumericUpDown.Value = (decimal)scale.AbsoluteInflate.End.Value;

            m_Updating = false;

            UpdateScale();
        }