protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ShowRowInterlacingCheckBox.Checked = true; ShowColumnInterlacingCheckBox.Checked = true; ShowRowHeadersCheckBox.Checked = true; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Legends[0].Visible = false; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Table Scale"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // configure the chart NChart chart = nChartControl1.Charts[0]; chart.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalHalf); chart.Axis(StandardAxis.Depth).Visible = false; // add interlace stripe NAxis yAxis = chart.Axis(StandardAxis.PrimaryY); NLinearScaleConfigurator linearScale = yAxis.ScaleConfigurator as NLinearScaleConfigurator; NScaleStripStyle strip = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); strip.Interlaced = true; strip.SetShowAtWall(ChartWallType.Back, true); linearScale.StripStyles.Add(strip); // create two series with random data Random random = new System.Random(); NBarSeries alcoholSales = new NBarSeries(); alcoholSales.Name = "Alcohol"; alcoholSales.MultiBarMode = MultiBarMode.Stacked; alcoholSales.Values.FillRandom(random, 12); alcoholSales.DataLabelStyle.Visible = false; chart.Series.Add(alcoholSales); NBarSeries beveragesSales = new NBarSeries(); beveragesSales.Name = "Beverages"; beveragesSales.MultiBarMode = MultiBarMode.Stacked; beveragesSales.Values.FillRandom(random, 12); beveragesSales.DataLabelStyle.Visible = false; chart.Series.Add(beveragesSales); // create a table scale NTableScaleConfigurator tableScale = new NTableScaleConfigurator(); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = tableScale; NCustomTableScaleRow customRow = new NCustomTableScaleRow(); customRow.Items = new object[] { "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D" }; tableScale.Rows.Add(customRow); for (int i = 0; i < chart.Series.Count; i++) { NSeriesTableScaleRow row = new NSeriesTableScaleRow(); row.Series = chart.Series[i]; // whether to show row headers row.ShowLeftRowHeader = ShowRowHeadersCheckBox.Checked; tableScale.Rows.Add(row); } // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, nChartControl1.Legends[0]); // row interlacing if (ShowRowInterlacingCheckBox.Checked) { NTableInterlaceStyle interlaceStyle = new NTableInterlaceStyle(); interlaceStyle.Type = TableInterlaceStyleType.Row; interlaceStyle.Length = 1; interlaceStyle.Interval = 1; interlaceStyle.FillStyle = new NColorFillStyle(Color.FromArgb(124, Color.Beige)); tableScale.InterlaceStyles.Add(interlaceStyle); } // col interlacing if (ShowColumnInterlacingCheckBox.Checked) { NTableInterlaceStyle interlaceStyle = new NTableInterlaceStyle(); interlaceStyle.Type = TableInterlaceStyleType.Col; interlaceStyle.Length = 1; interlaceStyle.Interval = 1; interlaceStyle.FillStyle = new NColorFillStyle(Color.FromArgb(124, Color.Red)); tableScale.InterlaceStyles.Add(interlaceStyle); } }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Table Scale"); 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)); // setup chart m_Chart = nChartControl1.Charts[0]; m_Chart.BoundsMode = BoundsMode.Stretch; m_Chart.Location = new NPointL(new NLength(10, NRelativeUnit.ParentPercentage), new NLength(10, NRelativeUnit.ParentPercentage)); m_Chart.Size = new NSizeL(new NLength(80, NRelativeUnit.ParentPercentage), new NLength(80, NRelativeUnit.ParentPercentage)); m_Chart.Axis(StandardAxis.Depth).Visible = false; // configure the y axis NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator(); m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = linearScale; linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true); // add a strip line style NScaleStripStyle stripStyle = new NScaleStripStyle(); stripStyle.FillStyle = new NColorFillStyle(Color.Beige); stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); stripStyle.Interlaced = true; linearScale.StripStyles.Add(stripStyle); Random random = new Random(); // create two series with random data NBarSeries alcoholSales = new NBarSeries(); alcoholSales.Name = "Alcohol"; alcoholSales.MultiBarMode = MultiBarMode.Stacked; alcoholSales.Values.FillRandom(random, 12); alcoholSales.DataLabelStyle.Visible = false; m_Chart.Series.Add(alcoholSales); NBarSeries beveragesSales = new NBarSeries(); beveragesSales.Name = "Beverages"; beveragesSales.MultiBarMode = MultiBarMode.Stacked; beveragesSales.Values.FillRandom(random, 12); beveragesSales.DataLabelStyle.Visible = false; m_Chart.Series.Add(beveragesSales); // create a table scale m_TableScale = new NTableScaleConfigurator(); m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = m_TableScale; NCustomTableScaleRow customRow = new NCustomTableScaleRow(); customRow.Items = new object[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; m_TableScale.Rows.Add(customRow); for (int i = 0; i < m_Chart.Series.Count; i++) { NSeriesTableScaleRow row = new NSeriesTableScaleRow(); row.Series = m_Chart.Series[i]; m_TableScale.Rows.Add(row); } // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // apply layout ConfigureStandardLayout(m_Chart, title, nChartControl1.Legends[0]); // init form controls LabelFormatComboBox.Items.Add("<value>"); LabelFormatComboBox.Items.Add("<percent>"); LabelFormatComboBox.SelectedIndex = 0; ShowRowHeadersCheckBox.Checked = true; ShowColumnInterlacingCheckBox.Checked = true; ShowRowInterlacingCheckBox.Checked = true; }