private void ControlChange(object sender, System.EventArgs e)
        {
            if (InsideCheck.Checked)
            {
                Chart1.Legends["Default"].InsideChartArea = "Default";
            }
            else
            {
                Chart1.Legends["Default"].InsideChartArea = "";
            }

            Chart1.Legends["Default"].Enabled = !DisableCheck.Checked;

            if (this.TheStyle.SelectedItem.ToString() == "Table" && !this.DisableCheck.Checked)
            {
                this.TheTableStyle.Enabled = true;
            }

            else
            {
                this.TheTableStyle.Enabled = false;
            }

            if (this.TheTableStyle.SelectedIndex >= 0)
            {
                Chart1.Legends["Default"].TableStyle = (LegendTableStyle)LegendTableStyle.Parse(typeof(LegendTableStyle), this.TheTableStyle.SelectedItem.ToString());
            }

            if (this.TheStyle.SelectedIndex >= 0)
            {
                Chart1.Legends["Default"].LegendStyle = (LegendStyle)LegendStyle.Parse(typeof(LegendStyle), this.TheStyle.SelectedItem.ToString());
            }

            if (this.TheDocking.SelectedIndex >= 0)
            {
                Chart1.Legends["Default"].Docking = (Docking)Docking.Parse(typeof(Docking), this.TheDocking.SelectedItem.ToString());
            }

            if (this.TheAlignment.SelectedIndex >= 0)
            {
                Chart1.Legends["Default"].Alignment = (StringAlignment)StringAlignment.Parse(typeof(StringAlignment), this.TheAlignment.SelectedItem.ToString());
            }

            if (this.cb_Reversed.Checked)
            {
                Chart1.Legends["Default"].LegendItemOrder = LegendItemOrder.ReversedSeriesOrder;
            }

            else
            {
                Chart1.Legends["Default"].LegendItemOrder = LegendItemOrder.SameAsSeriesOrder;
            }
        }
Example #2
0
        private void SetupChart()
        {
            // Set legend style
            Chart1.Legends["Default"].LegendStyle = (LegendStyle)LegendStyle.Parse(typeof(LegendStyle), LegendStyleList.SelectedItem.Text);

            // Set legend docking
            Chart1.Legends["Default"].Docking = (Docking)Docking.Parse(typeof(Docking), LegendDockingList.SelectedItem.Text);

            // Set legend alignment
            Chart1.Legends["Default"].Alignment = (StringAlignment)StringAlignment.Parse(typeof(StringAlignment), LegendAlinmentList.SelectedItem.Text);

            // Set whether the legend is reversed
            if (this.Reversed.Checked)
            {
                Chart1.Legends["Default"].LegendItemOrder = LegendItemOrder.ReversedSeriesOrder;
            }

            else
            {
                Chart1.Legends["Default"].LegendItemOrder = LegendItemOrder.SameAsSeriesOrder;
            }

            // Display legend in the "Default" chart area
            if (InsideChartArea.Checked)
            {
                Chart1.Legends["Default"].InsideChartArea = "ChartArea1";
            }

            // Set table style
            this.Chart1.Legends["Default"].TableStyle = (LegendTableStyle)LegendTableStyle.Parse(typeof(LegendTableStyle), this.TheTableStyle.SelectedItem.ToString());

            if (this.LegendStyleList.SelectedItem.ToString() == "Table" && !this.LegendDisabled.Checked)
            {
                this.TheTableStyle.Enabled = true;
            }

            else
            {
                this.TheTableStyle.Enabled = false;
            }
        }
Example #3
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // Load these settings the first time the chart is displayed
            if (!this.IsPostBack)
            {
                this.TextBox1.Text = @"Chart";
                this.TitleSeparator.SelectedIndex = 0;

                foreach (string sepTypes in Enum.GetNames(typeof(LegendSeparatorStyle)))
                {
                    this.TitleSeparator.Items.Add(sepTypes);
                }

                foreach (string alignmentTypes in Enum.GetNames(typeof(StringAlignment)))
                {
                    this.TextAlignment.Items.Add(alignmentTypes);
                }

                this.SeparatorColor.SelectedIndex = 0;
                this.TitleSeparator.SelectedIndex = 3;
                this.TextAlignment.SelectedIndex  = 1;
                this.LegendDocking.SelectedIndex  = 2;
            }

            // Set legend title text
            string legendTitleText = this.TextBox1.Text;

            this.Chart1.Legends["Default"].Title = legendTitleText;

            // If there is no text, disable all other controls
            if (legendTitleText == String.Empty)
            {
                this.TextAlignment.Enabled  = false;
                this.TitleSeparator.Enabled = false;
                this.ForeColor.Enabled      = false;
            }

            else
            {
                this.TextAlignment.Enabled  = true;
                this.TitleSeparator.Enabled = true;
                this.ForeColor.Enabled      = true;
            }

            // Set title separator
            this.Chart1.Legends["Default"].TitleSeparator = (LegendSeparatorStyle)LegendSeparatorStyle.Parse(typeof(LegendSeparatorStyle), this.TitleSeparator.SelectedItem.ToString());

            // If no title separator, disable separtor color control
            if ((this.TitleSeparator.SelectedItem.ToString() == "None") || (legendTitleText == String.Empty))
            {
                SeparatorColor.Enabled = false;
            }
            else
            {
                SeparatorColor.Enabled = true;
            }

            // Set title color
            this.Chart1.Legends["Default"].TitleForeColor = Color.FromName(this.ForeColor.SelectedItem.ToString());

            // Set title separator color
            this.Chart1.Legends["Default"].TitleSeparatorColor = Color.FromName(this.SeparatorColor.SelectedItem.ToString());

            // Set title alignment
            this.Chart1.Legends["Default"].TitleAlignment = (StringAlignment)StringAlignment.Parse(typeof(StringAlignment), this.TextAlignment.SelectedItem.ToString());

            // Set title docking
            this.Chart1.Legends["Default"].Docking = (Docking)Docking.Parse(typeof(Docking), this.LegendDocking.SelectedItem.Text);
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!this.IsPostBack)
            {
                // Add String Alignments styles to control.
                foreach (string item in Enum.GetNames(typeof(StringAlignment)))
                {
                    TextAlignment.Items.Add(item);
                    TextLineAlignment.Items.Add(item);
                }

                // Add Colors to controls.
                foreach (String colorName in KnownColor.GetNames(typeof(KnownColor)))
                {
                    Color1.Items.Add(colorName);
                }

                Color1.Items.FindByText("Black").Selected = true;

                // Add Font Family styles to control.
                foreach (FontFamily fontName in FontFamily.Families)
                {
                    Font1.Items.Add(fontName.Name);
                }
            }

            StripLine stripLine = Chart1.ChartAreas["ChartArea1"].AxisX.StripLines[0];


            // Set Strip Lines Title Alignment
            stripLine.TextAlignment = (StringAlignment)StringAlignment.Parse(typeof(StringAlignment), TextAlignment.SelectedItem.Text);

            // Set Strip Lines Title Line Alignment
            stripLine.TextLineAlignment = (StringAlignment)StringAlignment.Parse(typeof(StringAlignment), TextLineAlignment.SelectedItem.Text);

            // Set Strip Lines Title text
            stripLine.Text = Title.Text;

            // Set Strip Lines Title Angle
            stripLine.TextOrientation = (System.Web.UI.DataVisualization.Charting.TextOrientation)
                                        System.Web.UI.DataVisualization.Charting.TextOrientation.Parse(
                typeof(System.Web.UI.DataVisualization.Charting.TextOrientation),
                TextOrientation.SelectedItem.Value);

            // Set Strip Lines Title Color
            stripLine.ForeColor = Color.FromName(Color1.SelectedItem.Value);

            // Set Font style.
            FontStyle fontStyle = FontStyle.Regular;

            if (Italic.Checked)
            {
                fontStyle = (FontStyle)FontStyle.Italic;
            }
            if (Bold.Checked)
            {
                fontStyle |= (FontStyle)FontStyle.Bold;
            }
            if (Underline.Checked)
            {
                fontStyle |= (FontStyle)FontStyle.Underline;
            }
            if (Strikeout.Checked)
            {
                fontStyle |= (FontStyle)FontStyle.Strikeout;
            }

            // Set Strip Lines Title Font
            try
            {
                stripLine.Font = new Font(Font1.SelectedItem.Text, float.Parse(TitleSize.SelectedItem.Text), fontStyle);
            }
            catch
            {
                stripLine.Font = new Font("Arial", float.Parse(TitleSize.SelectedItem.Text), fontStyle);
            }
        }