private void ApplyInterlaceStyles()
        {
            NLegendInterlaceStylesCollection interlaceStyles = new NLegendInterlaceStylesCollection();

            if (m_HorizontalInterlaceStripesCheckBox.Checked)
            {
                NLegendInterlaceStyle horzInterlaceStyle = new NLegendInterlaceStyle();
                horzInterlaceStyle.Fill     = new NColorFill(NColor.FromColor(NColor.LightBlue, 0.5f));
                horzInterlaceStyle.Type     = ENLegendInterlaceStyleType.Row;
                horzInterlaceStyle.Length   = 1;
                horzInterlaceStyle.Interval = 1;

                interlaceStyles.Add(horzInterlaceStyle);
            }

            if (m_VerticalInterlaceStripesCheckBox.Checked)
            {
                NLegendInterlaceStyle vertInterlaceStyle = new NLegendInterlaceStyle();
                vertInterlaceStyle.Fill     = new NColorFill(NColor.FromColor(NColor.DarkGray, 0.5f));
                vertInterlaceStyle.Type     = ENLegendInterlaceStyleType.Col;
                vertInterlaceStyle.Length   = 1;
                vertInterlaceStyle.Interval = 1;

                interlaceStyles.Add(vertInterlaceStyle);
            }

            m_Legend.InterlaceStyles = interlaceStyles;
        }
Example #2
0
        public override void Initialize()
        {
            base.Initialize();

            nChartControl1.Panels.Clear();

            // set a chart title
            NLabel header = new NLabel("Legend Row and Column Interlacing");

            header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic);
            header.ContentAlignment    = ContentAlignment.BottomRight;
            header.Location            = new NPointL(new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage));
            header.DockMode            = PanelDockMode.Top;
            header.Margins             = new NMarginsL(10, 10, 10, 10);
            nChartControl1.Panels.Add(header);

            m_bUpdate = false;

            // configure the legend
            NLegend legend = new NLegend();

            legend.UseAutomaticSize = true;
            legend.Margins          = new NMarginsL(10, 10, 10, 10);
            nChartControl1.Panels.Add(legend);

            legend.Mode            = LegendMode.Automatic;
            legend.Location        = new NPointL(new NLength(90, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage));
            legend.Data.ExpandMode = LegendExpandMode.RowsFixed;
            legend.Data.RowCount   = 12;
            legend.FillStyle.SetTransparencyPercent(100);
            legend.OuterLeftBorderStyle.Width   = new NLength(0);
            legend.OuterTopBorderStyle.Width    = new NLength(0);
            legend.OuterRightBorderStyle.Width  = new NLength(0);
            legend.OuterBottomBorderStyle.Width = new NLength(0);
            legend.HorizontalBorderStyle.Width  = new NLength(0);
            legend.VerticalBorderStyle.Width    = new NLength(0);

            legend.DockMode = PanelDockMode.Right;

            m_RowInterlaceStyle           = new NLegendInterlaceStyle();
            m_RowInterlaceStyle.Type      = LegendInterlaceStyleType.Row;
            m_RowInterlaceStyle.FillStyle = new NColorFillStyle(Color.FromArgb(125, Color.DimGray));
            legend.InterlaceStyles.Add(m_RowInterlaceStyle);

            m_ColInterlaceStyle           = new NLegendInterlaceStyle();
            m_ColInterlaceStyle.Type      = LegendInterlaceStyleType.Col;
            m_ColInterlaceStyle.FillStyle = new NColorFillStyle(Color.FromArgb(125, Color.Gainsboro));
            legend.InterlaceStyles.Add(m_ColInterlaceStyle);

            // init form controls depending on control style
            // configure layout
            ExpandModeComboBox.Items.Add("Rows only");
            ExpandModeComboBox.Items.Add("Cols only");
            ExpandModeComboBox.Items.Add("Rows fixed");
            ExpandModeComboBox.Items.Add("Cols fixed");
            ExpandModeComboBox.SelectedIndex = (int)legend.Data.ExpandMode;
            RowCountUpDown.Value             = (decimal)legend.Data.RowCount;
            ColCountUpDown.Value             = (decimal)legend.Data.ColCount;

            // configure horizontal interlacing
            legend.InterlaceStyles.Clear();

            // configure the chart
            NChart chart = new NCartesianChart();

            nChartControl1.Panels.Add(chart);
            chart.DisplayOnLegend = legend;
            chart.BoundsMode      = BoundsMode.Fit;
            chart.DockMode        = PanelDockMode.Fill;
            chart.Margins         = new NMarginsL(10, 10, 10, 10);

            for (int i = 0; i < 4; i++)
            {
                // create bar series
                NBarSeries series = (NBarSeries)chart.Series.Add(SeriesType.Bar);
                series.Name = "Series " + i.ToString();
                series.Values.FillRandomRange(Random, 6, 50, 90);
                series.Legend.Format          = series.Name + " <value>";
                series.Legend.Mode            = SeriesLegendMode.DataPoints;
                series.MultiBarMode           = MultiBarMode.Stacked;
                series.DataLabelStyle.Visible = false;
            }

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

            styleSheet.Apply(nChartControl1.Document);

            RowInterlacingEnabledCheckBox.Checked     = true;
            RowInterlacingBeginNumericUpDown.Value    = (decimal)m_RowInterlaceStyle.Begin;
            RowInterlacingEndNumericUpDown.Value      = (decimal)m_RowInterlaceStyle.End;
            RowInterlacingInfiniteCheckBox.Checked    = m_RowInterlaceStyle.Infinite;
            RowInterlacingLengthNumericUpDown.Value   = (decimal)m_RowInterlaceStyle.Length;
            RowInterlacingIntervalNumericUpDown.Value = (decimal)m_RowInterlaceStyle.Interval;

            // configure vertical interlacing
            ColumnInterlacingEnabledCheckBox.Checked     = true;
            ColumnInterlacingBeginNumericUpDown.Value    = (decimal)m_ColInterlaceStyle.Begin;
            ColumnInterlacingEndNumericUpDown.Value      = (decimal)m_ColInterlaceStyle.End;
            ColumnInterlacingInfiniteCheckBox.Checked    = m_ColInterlaceStyle.Infinite;
            ColumnInterlacingLengthNumericUpDown.Value   = (decimal)m_ColInterlaceStyle.Length;
            ColumnInterlacingIntervalNumericUpDown.Value = (decimal)m_ColInterlaceStyle.Interval;

            m_bUpdate = true;

            ConfigureLegend();
        }