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; } }
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; } }
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); }