protected void Page_Load(object sender, EventArgs e)
        {
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Cluster Bar Chart");

            title.TextStyle.FontStyle        = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
            title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;

            // setup chart
            nChart            = nChartControl1.Charts[0];
            nChart.BoundsMode = BoundsMode.Stretch;

            // add interlace stripe
            NLinearScaleConfigurator linearScale = nChart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator;
            NScaleStripStyle         stripStyle  = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1);

            stripStyle.Interlaced  = true;
            stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back };
            linearScale.StripStyles.Add(stripStyle);

            // add the first bar
            nBar1              = (NBarSeries)nChart.Series.Add(SeriesType.Bar);
            nBar1.Name         = "Bar1";
            nBar1.MultiBarMode = MultiBarMode.Series;
            nBar1.Legend.TextStyle.FontStyle.EmSize         = new NLength(8);
            nBar1.DataLabelStyle.Format                     = "<value>";
            nBar1.DataLabelStyle.TextStyle.FontStyle.EmSize = new NLength(7);
            nBar1.FillStyle             = new NColorFillStyle(Color.DarkSeaGreen);
            nBar1.Values.ValueFormatter = new NNumericValueFormatter("0");

            // add the second bar
            nBar2              = (NBarSeries)nChart.Series.Add(SeriesType.Bar);
            nBar2.Name         = "Bar2";
            nBar2.MultiBarMode = MultiBarMode.Clustered;
            nBar2.Legend.TextStyle.FontStyle.EmSize         = new NLength(8);
            nBar2.DataLabelStyle.Format                     = "<value>";
            nBar2.DataLabelStyle.TextStyle.FontStyle.EmSize = new NLength(7);
            nBar2.FillStyle             = new NColorFillStyle(Color.MediumSlateBlue);
            nBar2.Values.ValueFormatter = new NNumericValueFormatter("0");

            // fill with random data
            nBar1.Values.FillRandomRange(Random, 5, 10, 100);
            nBar2.Values.FillRandomRange(Random, 5, 10, 500);

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

            styleSheet.Apply(nChartControl1.Document);

            // apply layout
            ApplyLayoutTemplate(0, nChartControl1, nChart, title, nChartControl1.Legends[0]);

            if (!IsPostBack)
            {
                WebExamplesUtilities.FillComboWithPercents(GapPercentDropDownList, 10);
                WebExamplesUtilities.FillComboWithPercents(WidthPercentDropDownList, 10);

                GapPercentDropDownList.SelectedIndex   = 0;
                WidthPercentDropDownList.SelectedIndex = 8;
            }
            else
            {
                nBar1.GapPercent = WebExamplesUtilities.GetPercentFromCombo(GapPercentDropDownList, 10);
                nBar2.GapPercent = WebExamplesUtilities.GetPercentFromCombo(GapPercentDropDownList, 10);

                nBar1.WidthPercent = WebExamplesUtilities.GetPercentFromCombo(WidthPercentDropDownList, 10);
                nBar2.WidthPercent = WebExamplesUtilities.GetPercentFromCombo(WidthPercentDropDownList, 10);

                if (ScaleSecondaryClusterCheckBox.Checked == true)
                {
                    nBar2.DisplayOnAxis(StandardAxis.PrimaryY, false);
                    nBar2.DisplayOnAxis(StandardAxis.SecondaryY, true);

                    nChart.Axis(StandardAxis.SecondaryY).Visible = true;
                }
                else
                {
                    nBar2.DisplayOnAxis(StandardAxis.PrimaryY, true);
                    nBar2.DisplayOnAxis(StandardAxis.SecondaryY, false);

                    nChart.Axis(StandardAxis.SecondaryY).Visible = false;
                }
            }
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Multi Series Area Chart");

            title.TextStyle.FontStyle        = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
            title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;

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

            chart.Enable3D = true;
            chart.Width    = 70;
            chart.Height   = 30;
            chart.Depth    = 50;
            chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted);
            chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft);

            // setup Y axis
            NLinearScaleConfigurator linearScaleConfigurator = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator;

            linearScaleConfigurator.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot;

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

            stripStyle.Interlaced  = true;
            stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back, ChartWallType.Left };
            linearScaleConfigurator.StripStyles.Add(stripStyle);

            // setup X axis
            NOrdinalScaleConfigurator ordinalScaleConfigurator = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator;

            ordinalScaleConfigurator.DisplayDataPointsBetweenTicks = false;
            ordinalScaleConfigurator.MajorTickMode = MajorTickMode.AutoMaxCount;
            ordinalScaleConfigurator.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot;
            ordinalScaleConfigurator.MajorGridStyle.ShowAtWalls       = new ChartWallType[] { ChartWallType.Back, ChartWallType.Floor };

            // setup Z axis
            ordinalScaleConfigurator = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.Depth).ScaleConfigurator;
            ordinalScaleConfigurator.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot;
            ordinalScaleConfigurator.MajorGridStyle.ShowAtWalls       = new ChartWallType[] { ChartWallType.Left, ChartWallType.Floor };

            // add the first Area
            NAreaSeries area1 = (NAreaSeries)chart.Series.Add(SeriesType.Area);

            area1.Name                              = "Area 1";
            area1.MultiAreaMode                     = MultiAreaMode.Series;
            area1.DataLabelStyle.Visible            = false;
            area1.Legend.TextStyle.FontStyle.EmSize = new NLength(8);

            // add the second Area
            NAreaSeries area2 = (NAreaSeries)chart.Series.Add(SeriesType.Area);

            area2.Name                              = "Area 2";
            area2.MultiAreaMode                     = MultiAreaMode.Series;
            area2.DataLabelStyle.Visible            = false;
            area2.Legend.TextStyle.FontStyle.EmSize = new NLength(8);

            // add the third Area
            NAreaSeries area3 = (NAreaSeries)chart.Series.Add(SeriesType.Area);

            area3.Name                              = "Area 3";
            area3.MultiAreaMode                     = MultiAreaMode.Series;
            area3.DataLabelStyle.Visible            = false;
            area3.Legend.TextStyle.FontStyle.EmSize = new NLength(8);

            // fill with random data
            area1.Values.FillRandomRange(Random, 10, 10, 40);
            area2.Values.FillRandomRange(Random, 10, 30, 60);
            area3.Values.FillRandomRange(Random, 10, 50, 80);

            if (!IsPostBack)
            {
                WebExamplesUtilities.FillComboWithPercents(AreaDepthDropDownList, 10);

                AreaDepthDropDownList.SelectedIndex = 5;
            }

            // modify the depth percent
            area1.DepthPercent = WebExamplesUtilities.GetPercentFromCombo(AreaDepthDropDownList, 10);
            area2.DepthPercent = WebExamplesUtilities.GetPercentFromCombo(AreaDepthDropDownList, 10);
            area3.DepthPercent = WebExamplesUtilities.GetPercentFromCombo(AreaDepthDropDownList, 10);

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

            styleSheet.Apply(nChartControl1.Document);

            // apply layout
            ApplyLayoutTemplate(0, nChartControl1, chart, title, nChartControl1.Legends[0]);
        }