Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                SampleFormattedLabelDropDownList.Items.Add("Font size and color");
                SampleFormattedLabelDropDownList.Items.Add("Font style control");
                SampleFormattedLabelDropDownList.Items.Add("Subscript and superscript");
                SampleFormattedLabelDropDownList.Items.Add("Shapes");
                SampleFormattedLabelDropDownList.Items.Add("Bullets");
                SampleFormattedLabelDropDownList.Items.Add("Fill Effects");
                SampleFormattedLabelDropDownList.Items.Add("Borders");
                SampleFormattedLabelDropDownList.Items.Add("Shadows");
                SampleFormattedLabelDropDownList.Items.Add("Background Fill and Stroke");
                SampleFormattedLabelDropDownList.SelectedIndex = 8;

                WebExamplesUtilities.FillComboWithFontNames(FontDropDownList, "Arial");
                WebExamplesUtilities.FillComboWithValues(FontSizeDropDownList, 8, 52, 1);

                WebExamplesUtilities.FillComboWithColorNames(FontColorDropDownList, KnownColor.Black);

                HasBackplaneCheckBox.Checked = true;
            }

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

            try
            {
                label.TextStyle.FontStyle = new NFontStyle(FontDropDownList.SelectedItem.Text, FontSizeDropDownList.SelectedIndex + 8);
            }
            catch
            {
            }

            label.Text = GetFormattedString((int)label.TextStyle.FontStyle.EmSize.Value);

            label.TextStyle.FillStyle                   = new NColorFillStyle(WebExamplesUtilities.ColorFromDropDownList(FontColorDropDownList));
            label.TextStyle.TextFormat                  = TextFormat.XML;
            label.TextStyle.BackplaneStyle.Visible      = HasBackplaneCheckBox.Checked;
            label.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Left;
            label.TextStyle.StringFormatStyle.VertAlign = VertAlign.Top;
            label.TextStyle.TextFormat                  = TextFormat.XML;
            label.Location = new NPointL(new NLength(5, NRelativeUnit.ParentPercentage),
                                         new NLength(5, NRelativeUnit.ParentPercentage));

            nChartControl1.Panels.Add(label);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LabelTextBox.Text = "Chart Title";

                WebExamplesUtilities.FillComboWithPercents(HorizontalMarginDropDownList, 10);
                HorizontalMarginDropDownList.SelectedIndex = 5;

                WebExamplesUtilities.FillComboWithPercents(VerticalMarginDropDownList, 10);
                VerticalMarginDropDownList.SelectedIndex = 1;

                ContentAlignmentDropDownList.Items.Add("BottomCenter");
                ContentAlignmentDropDownList.Items.Add("BottomLeft");
                ContentAlignmentDropDownList.Items.Add("BottomRight");
                ContentAlignmentDropDownList.Items.Add("MiddleCenter");
                ContentAlignmentDropDownList.Items.Add("MiddleLeft");
                ContentAlignmentDropDownList.Items.Add("MiddleRight");
                ContentAlignmentDropDownList.Items.Add("TopCenter");
                ContentAlignmentDropDownList.Items.Add("TopLeft");
                ContentAlignmentDropDownList.Items.Add("TopRight");
                ContentAlignmentDropDownList.SelectedIndex = 0;

                WebExamplesUtilities.FillComboWithFontNames(FontDropDownList, "Arial");
                WebExamplesUtilities.FillComboWithValues(FontSizeDropDownList, 8, 52, 1);
                FontSizeDropDownList.SelectedIndex = 2;

                WebExamplesUtilities.FillComboWithColorNames(FontColorDropDownList, KnownColor.Black);
                WebExamplesUtilities.FillComboWithValues(FontOrientationDropDownList, 0, 360, 10);

                HasBackplaneCheckBox.Checked = true;

                BackplaneStyleDropDownList.Items.Add("Rectangle");
                BackplaneStyleDropDownList.Items.Add("Ellipse");
                BackplaneStyleDropDownList.Items.Add("Circle");
                BackplaneStyleDropDownList.Items.Add("Cut Edge Rectangle");
                BackplaneStyleDropDownList.Items.Add("Smooth Edge Rectangle");
                BackplaneStyleDropDownList.SelectedIndex = 0;
            }

            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // setup the label
            NLabel label = new NLabel();

            nChartControl1.Panels.Add(label);
            label.Text = LabelTextBox.Text;
            label.TextStyle.FillStyle              = new NColorFillStyle(WebExamplesUtilities.ColorFromDropDownList(FontColorDropDownList));
            label.TextStyle.Orientation            = FontOrientationDropDownList.SelectedIndex * 10;
            label.TextStyle.BackplaneStyle.Visible = HasBackplaneCheckBox.Checked;
            label.ContentAlignment = (ContentAlignment)Enum.Parse(typeof(ContentAlignment), ContentAlignmentDropDownList.SelectedItem.Text);
            label.Location         = new NPointL(
                new NLength(HorizontalMarginDropDownList.SelectedIndex * 10, NRelativeUnit.ParentPercentage),
                new NLength(VerticalMarginDropDownList.SelectedIndex * 10, NRelativeUnit.ParentPercentage));

            try
            {
                label.TextStyle.FontStyle = new NFontStyle(FontDropDownList.SelectedItem.Text, FontSizeDropDownList.SelectedIndex + 8);;
            }
            catch
            {
            }

            BackplaneStyleDropDownList.Enabled = HasBackplaneCheckBox.Checked;

            if (HasBackplaneCheckBox.Checked)
            {
                label.TextStyle.BackplaneStyle.Shape = (BackplaneShape)BackplaneStyleDropDownList.SelectedIndex;
            }

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

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

            chart.BoundsMode = BoundsMode.Fit;
            chart.Axis(StandardAxis.PrimaryX).Visible = false;
            chart.Axis(StandardAxis.PrimaryY).Visible = false;
            chart.Location = new NPointL(
                new NLength(15, NRelativeUnit.ParentPercentage),
                new NLength(20, NRelativeUnit.ParentPercentage));
            chart.Size = new NSizeL(
                new NLength(70, NRelativeUnit.ParentPercentage),
                new NLength(60, NRelativeUnit.ParentPercentage));

            NBarSeries series = (NBarSeries)chart.Series.Add(SeriesType.Bar);

            series.DataLabelStyle.Visible = false;
            series.Values.AddRange(new double[] { 16, 42, 56, 23, 47, 38 });

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

            styleSheet.Apply(series);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                WebExamplesUtilities.FillComboWithPercents(HorizontalMarginDropDownList, 10);
                HorizontalMarginDropDownList.SelectedIndex = 0;

                ContentAlignmentDropDownList.Items.Add("BottomCenter");
                ContentAlignmentDropDownList.Items.Add("BottomLeft");
                ContentAlignmentDropDownList.Items.Add("BottomRight");
                ContentAlignmentDropDownList.Items.Add("MiddleCenter");
                ContentAlignmentDropDownList.Items.Add("MiddleLeft");
                ContentAlignmentDropDownList.Items.Add("MiddleRight");
                ContentAlignmentDropDownList.Items.Add("TopCenter");
                ContentAlignmentDropDownList.Items.Add("TopLeft");
                ContentAlignmentDropDownList.Items.Add("TopRight");
                ContentAlignmentDropDownList.SelectedIndex = 2;

                WebExamplesUtilities.FillComboWithPercents(VerticalMarginDropDownList, 10);
                VerticalMarginDropDownList.SelectedIndex = 0;

                WebExamplesUtilities.FillComboWithFontNames(DataFontDropDownList, "Arial");
                WebExamplesUtilities.FillComboWithValues(DataFontSizeDropDownList, 9, 30, 1);

                HasShadowCheckBox.Checked      = true;
                ShowLegendGridCheckBox.Checked = true;

                WebExamplesUtilities.FillComboWithPercents(BackplaneTransparencyDropDownList, 10);
                BackplaneTransparencyDropDownList.SelectedIndex = 0;
            }

            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // add panels
            nChartControl1.Panels.Clear();

            NLabel title = new NLabel("Legend Position");

            nChartControl1.Panels.Add(title);

            NPieChart chart = new NPieChart();

            nChartControl1.Panels.Add(chart);

            NLegend legend = new NLegend();

            nChartControl1.Panels.Add(legend);

            // setup the chart title
            title.TextStyle.FontStyle        = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
            title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;
            title.ContentAlignment           = ContentAlignment.BottomCenter;
            title.Location = new NPointL(
                new NLength(50, NRelativeUnit.ParentPercentage),
                new NLength(2, NRelativeUnit.ParentPercentage));

            // setup the legend
            legend.ShadowStyle.Type   = HasShadowCheckBox.Checked ? ShadowType.GaussianBlur : ShadowType.None;
            legend.ShadowStyle.Offset = new NPointL(2, 2);
            legend.ShadowStyle.Color  = Color.FromArgb(64, 64, 64, 64);
            legend.FillStyle          = new NColorFillStyle(Color.FromArgb(255 - (int)(BackplaneTransparencyDropDownList.SelectedIndex * 255 / 10.0f), 255, 255, 255));
            legend.ContentAlignment   = (ContentAlignment)Enum.Parse(typeof(ContentAlignment), ContentAlignmentDropDownList.SelectedItem.Text);
            legend.Location           = new NPointL(
                new NLength(HorizontalMarginDropDownList.SelectedIndex * 10, NRelativeUnit.ParentPercentage),
                new NLength(VerticalMarginDropDownList.SelectedIndex * 10, NRelativeUnit.ParentPercentage));

            if (ShowLegendGridCheckBox.Checked == true)
            {
                legend.HorizontalBorderStyle.Width = new NLength(1, NGraphicsUnit.Pixel);
                legend.VerticalBorderStyle.Width   = new NLength(1, NGraphicsUnit.Pixel);
            }
            else
            {
                legend.HorizontalBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel);
                legend.VerticalBorderStyle.Width   = new NLength(0, NGraphicsUnit.Pixel);
            }

            // setup the pie chart
            chart.DisplayOnLegend = legend;
            chart.BoundsMode      = BoundsMode.Fit;
            chart.Location        = new NPointL(
                new NLength(10, NRelativeUnit.ParentPercentage),
                new NLength(20, NRelativeUnit.ParentPercentage));
            chart.Size = new NSizeL(
                new NLength(80, NRelativeUnit.ParentPercentage),
                new NLength(60, NRelativeUnit.ParentPercentage));

            NPieSeries pie = (NPieSeries)chart.Series.Add(SeriesType.Pie);

            pie.DataLabelStyle.Visible            = false;
            pie.Legend.Mode                       = SeriesLegendMode.DataPoints;
            pie.Legend.Format                     = "<label> <percent>";
            pie.Legend.TextStyle.FontStyle.Name   = DataFontDropDownList.SelectedItem.Text;
            pie.Legend.TextStyle.FontStyle.EmSize = new NLength(DataFontSizeDropDownList.SelectedIndex + 9, NGraphicsUnit.Point);

            for (int i = 0; i < 6; i++)
            {
                pie.Values.Add(10 + Random.NextDouble() * 30);
                pie.Labels.Add("Item " + i.ToString());
            }

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

            styleSheet.Apply(chart);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                WebExamplesUtilities.FillComboWithFontNames(YAxisFontDropDownList, "Arial");
                WebExamplesUtilities.FillComboWithFontNames(XAxisFontDropDownList, "Arial");
                WebExamplesUtilities.FillComboWithValues(YOffsetDropDownList, 0, 30, 5);
                WebExamplesUtilities.FillComboWithValues(XOffsetDropDownList, 0, 30, 5);
                YTitleTextBox.Text = "Y Axis Title";
                XTitleTextBox.Text = "X Axis Title";
            }

            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // set a chart title
            NLabel header = nChartControl1.Labels.AddHeader("Axis Titles");

            header.TextStyle.FontStyle        = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
            header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;
            header.ContentAlignment           = ContentAlignment.BottomRight;
            header.Location = new NPointL(
                new NLength(2, NRelativeUnit.ParentPercentage),
                new NLength(2, NRelativeUnit.ParentPercentage));

            nChart            = nChartControl1.Charts[0];
            nChart.BoundsMode = BoundsMode.Stretch;
            nChart.Location   = new NPointL(
                new NLength(4, NRelativeUnit.ParentPercentage),
                new NLength(12, NRelativeUnit.ParentPercentage));
            nChart.Size = new NSizeL(
                new NLength(90, NRelativeUnit.ParentPercentage),
                new NLength(84, NRelativeUnit.ParentPercentage));

            NStandardScaleConfigurator scaleConfiguratorY = (NStandardScaleConfigurator)nChart.Axis(StandardAxis.PrimaryY).ScaleConfigurator;

            scaleConfiguratorY.Title.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.View, 90);

            // add interlaced stripe
            NScaleStripStyle stripStyle = new NScaleStripStyle();

            stripStyle.FillStyle = new NColorFillStyle(Color.Beige);
            stripStyle.SetShowAtWall(ChartWallType.Back, true);
            stripStyle.SetShowAtWall(ChartWallType.Left, true);
            stripStyle.Interlaced = true;
            scaleConfiguratorY.StripStyles.Add(stripStyle);

            NStandardScaleConfigurator scaleConfiguratorX = (NStandardScaleConfigurator)nChart.Axis(StandardAxis.PrimaryX).ScaleConfigurator;

            scaleConfiguratorX.Title.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.View, 0);

            NBarSeries bar = (NBarSeries)nChart.Series.Add(SeriesType.Bar);

            bar.Values.FillRandom(Random, 20);
            bar.Name = "Bars";
            bar.DataLabelStyle.Visible = false;
            bar.Legend.Mode            = SeriesLegendMode.None;

            scaleConfiguratorY            = (NStandardScaleConfigurator)nChart.Axis(StandardAxis.PrimaryY).ScaleConfigurator;
            scaleConfiguratorY.Title.Text = YTitleTextBox.Text;

            scaleConfiguratorX            = (NStandardScaleConfigurator)nChart.Axis(StandardAxis.PrimaryX).ScaleConfigurator;
            scaleConfiguratorX.Title.Text = XTitleTextBox.Text;

            SetTitle();

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

            styleSheet.Apply(nChartControl1.Document);
        }