本文整理汇总了C#中System.Windows.Forms.DataVisualization.Charting.Legend类的典型用法代码示例。如果您正苦于以下问题:C# Legend类的具体用法?C# Legend怎么用?C# Legend使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Legend类属于System.Windows.Forms.DataVisualization.Charting命名空间,在下文中一共展示了Legend类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateChart
private void GenerateChart(SeriesCreator creator, string filePath)
{
IEnumerable<Series> serieses = creator.ToSerieses();
using (var ch = new Chart())
{
ch.Size = new Size(1300, 800);
ch.AntiAliasing = AntiAliasingStyles.All;
ch.TextAntiAliasingQuality = TextAntiAliasingQuality.High;
ch.Palette = ChartColorPalette.BrightPastel;
ChartArea area = new ChartArea();
area.AxisX.MajorGrid.Enabled = false;
area.AxisY.MajorGrid.Enabled = false;
area.AxisY.Minimum = creator.GetMinimumY();
ch.ChartAreas.Add(area);
Legend legend = new Legend();
legend.Font = new Font("Microsoft Sans Serif", 12, FontStyle.Regular);
ch.Legends.Add(legend);
foreach (var s in serieses)
{
ch.Series.Add(s);
}
string savePath = filePath + ".png";
ch.SaveImage(savePath, ChartImageFormat.Png);
}
}
示例2: Form1
public Form1()
{
InitializeComponent();
creationBox.BringToFront();
initLegend = chart1.Legends[0];
this.Text = "Assistant aux QCMs - ";
restart.Visible = false;
toolTip.SetToolTip(saveChart, "Cliquer pour sauvegarder en image");
saveChart.Visible = false;
toolTip.SetToolTip(zoomChart, "Cliquer pour mettre en plein écran");
zoomChart.Visible = false;
toolTip.SetToolTip(showLegend, "Cliquer pour cacher/montrer la légende");
showLegend.Visible = false;
notes.Visible = false;
notesBox.Visible = false;
date.Text = "";
currentPage = 1;
labels = new Label[] { label1, label2, label3, label4, label5 };
checkedList = new CheckedListBox[] { checkedListBox1, checkedListBox2, checkedListBox3, checkedListBox4, checkedListBox5 };
for (int i = 0; i < 5; i++)
{
checkedList[i].Items.Clear();
checkedList[i].Items.Add("Pas du tout d'accord");
checkedList[i].Items.Add("Pas d'accord");
checkedList[i].Items.Add("D'accord");
checkedList[i].Items.Add("Tout à fait d'accord");
}
chart1.Visible = false;
}
示例3: AddChartsToProgressControl
/* Adds one tab containing a chart to this.progressTabControl for each member in chartName.
* Returns a list of the added charts.
*/
private List<Chart> AddChartsToProgressControl(List<string> chartNames)
{
int i = 0;
List<Chart> charts = new List<Chart>();
foreach (string chartName in chartNames)
{
Legend legend = new Legend();
legend.Name = "legend";
legend.Docking = Docking.Right;
ChartArea ca = new ChartArea();
ca.Name = "chartArea";
Chart chart = new Chart();
chart.Legends.Add(legend);
chart.ChartAreas.Add(ca);
chart.Name = chartName;
chart.Dock = DockStyle.Fill;
chart.Text = chartName;
TabPage tPage = new TabPage();
tPage.Name = chartName;
tPage.Text = chartName;
tPage.Controls.Add(chart);
this.progressTabControl.Controls.Add(tPage);
charts.Add(chart);
i++;
}
return charts;
}
示例4: PrettyChart
public PrettyChart()
{
var title1 = new Title {Name = "Title1", Text = "<TITLE>"};
Titles.Add(title1);
var area = new ChartArea();
area.AxisY.LabelStyle.Enabled = true;
area.AxisY.Interval = 1.0;
area.AxisX.LabelStyle.Enabled = true;
area.Name = "ChartArea2";
var legend1 = new Legend {Alignment = StringAlignment.Center, Docking = Docking.Top, Name = "Legend1"};
Legends.Add(legend1);
var series2 = new Series
{
ChartArea = "ChartArea2",
Color = Color.Blue,
Legend = "Legend1",
Name = "Series2",
XValueType = ChartValueType.Int32
};
ChartAreas.Add(area);
Series.Add(series2);
Dock = DockStyle.Fill;
Location = new Point(0, 0);
Titles[0].Text = "Age Distribution";
Series[0].Name = "Number of People";
}
示例5: CreatePieChart
private Chart CreatePieChart(Legend legend, Title title, Dictionary<string, int> dpc)
{
var chart = new Chart();
chart.Size = new Size(600, 450);
chart.Titles.Add(title);
var chartArea = new ChartArea();
chart.ChartAreas.Add(chartArea);
var series = new Series();
series.Name = "series";
series.ChartType = SeriesChartType.Pie;
//chart.Legends.Add(legend);
chart.Series.Add(series);
foreach (var entry in dpc)
{
if(entry.Value > 0)
chart.Series["series"].Points.AddXY(entry.Key, entry.Value);
}
chart.Dock = DockStyle.Fill;
return chart;
}
示例6: InitializeChart
public void InitializeChart()
{
this.components = new System.ComponentModel.Container();
ChartArea chartArea1 = new ChartArea();
Legend legend1 = new Legend() { BackColor = Color.Green, ForeColor = Color.Black, Title = "Salary" };
Legend legend2 = new Legend() { BackColor = Color.Green, ForeColor = Color.Black, Title = "Salary" };
barChart = new Chart();
((ISupportInitialize)(barChart)).BeginInit();
SuspendLayout();
//====Bar Chart
chartArea1 = new ChartArea();
chartArea1.Name = "BarChartArea";
barChart.ChartAreas.Add(chartArea1);
barChart.Dock = System.Windows.Forms.DockStyle.Fill;
legend2.Name = "Legend3";
barChart.Legends.Add(legend2);
AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
//this.ClientSize = new System.Drawing.Size(284, 262);
this.Load += new EventHandler(Form3_Load);
((ISupportInitialize)(this.barChart)).EndInit();
this.ResumeLayout(false);
}
开发者ID:statavarthy,项目名称:Project-Life-Expectancy-Based-on-SocioEconomic-Indicators,代码行数:26,代码来源:Form3.cs
示例7: Init
private void Init()
{
ChartArea chartArea = new ChartArea();
Legend legend = new Legend();
((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
chartArea.Name = "ChartArea1";
this.ChartAreas.Add(chartArea);
legend.Name = "Legend1";
this.Legends.Add(legend);
Series.Clear();
m_series = new Series
{
Name = "Series1",
Color = System.Drawing.Color.Green,
IsVisibleInLegend = false,
IsXValueIndexed = true,
ChartType = SeriesChartType.Line
};
Series.Add(m_series);
for (int i = 10; i < 23; i++)
{
m_series.Points.AddXY(i, f(i));
}
}
示例8: graphView
public override void graphView()
{
//MessageBox.Show("ypDayo");
base.chartClear();
base.graphView();
ChartArea area = new ChartArea("area1");
area.AxisX.Title = "月";
area.AxisX.TitleFont = new Font("@MS ゴシック", 10, FontStyle.Bold);
area.AxisY.Title = "金額";
area.AxisY.TitleFont = new Font("@MS ゴシック", 10, FontStyle.Bold);
area.AxisY.TitleAlignment = StringAlignment.Far;
area.AxisY.TextOrientation = TextOrientation.Stacked;
graph.Titles.Add(date.Year + "年");
area.AxisX.MajorGrid.Enabled = false;
area.AxisY.MajorGrid.Enabled = false;
graph.ChartAreas.Add(area);
Legend leg = new Legend(date.Year.ToString());
leg.Alignment = StringAlignment.Near;
leg.DockedToChartArea = "area1";
//一つ目
setSeries(date.Year);
//比較用
dateCombo.Text = string.IsNullOrWhiteSpace(dateCombo.Text) ? "未選択" : dateCombo.Text;
if (dateCombo.Text != "未選択")
{
string select = dateCombo.SelectedItem.ToString();
setSeries(int.Parse(select));
dateCombo.SelectedIndexChanged -= DateCombo_SelectedIndexChanged;
dateCombo.Text = select;
}
area.AxisY.Maximum = double.NaN;
area.AxisX.Maximum = 12;
area.AxisX.Minimum = 0;
area.AxisX.Interval = 1;
double max = area.AxisY.Maximum;
area.AxisY.Interval = max / 10;
}
示例9: CreatePlotAndSave
private static void CreatePlotAndSave(TestItem testItem)
{
// Create a Chart
var chart = new Chart();
// Chart title
var chartTitle = new Title(testItem.Label);
chart.Titles.Add(chartTitle);
// Create Chart Area
ChartArea chartArea = new ChartArea();
chartArea.AxisX.Title = "Milestone title";
chartArea.AxisY.Title = "ms";
chartArea.AxisX.IsMarginVisible = false;
for (int i = 0; i < testItem.MilestoneLabels.Length;i++)
{
chartArea.AxisX.CustomLabels.Add(i + 0.5, i + 1.5, testItem.MilestoneLabels[i]);
}
// Legend
Legend legend = new Legend("default");
legend.Docking = Docking.Bottom;
chart.Legends.Add(legend);
// Add Chart Area to the Chart
chart.ChartAreas.Add(chartArea);
foreach (var line in testItem.Lines)
{
Series series = new Series();
series.Legend = "default";
series.LegendText = line.Label;
series.ChartType = SeriesChartType.Line;
series.MarkerStyle = MarkerStyle.Circle;
series.BorderWidth = 2;
series.MarkerSize = 5;
for (int i = 0; i < line.Points.Length; i++)
{
series.Points.Add(line.Points[i].GetMinTime());
}
chart.Series.Add(series);
}
// Set chart control location
chart.Location = new System.Drawing.Point(16, 48);
// Set Chart control size
chart.Size = new System.Drawing.Size(400, 300);
var fileName = GenerateFileName(testItem);
var file = new FileStream(fileName, FileMode.Create);
chart.SaveImage(file, ChartImageFormat.Png);
file.Close();
Console.WriteLine(String.Format("Report: \"{0}\" created.", fileName));
}
示例10: AddLegend
public static void AddLegend(Chart chart, LegendStyle style)
{
var legend = new Legend();
legend.Enabled = true;
legend.LegendStyle = style;
legend.Name = "MyLegend";
legend.Position.Auto = true;
chart.Legends.Add(legend);
}
示例11: AddLegend
private void AddLegend(Chart chart)
{
var legend = new Legend
{
Docking = Docking.Right,
Alignment = StringAlignment.Center,
Font = new Font("Arial", 7f),
};
chart.Legends.Add(legend);
}
示例12: BuildChartPie
private void BuildChartPie()
{
ChartArea chartArea1 = new ChartArea();
chartArea1.Area3DStyle.IsClustered = true;
chartArea1.Area3DStyle.IsRightAngleAxes = false;
chartArea1.Area3DStyle.Perspective = 10;
chartArea1.Area3DStyle.PointGapDepth = 0;
chartArea1.Area3DStyle.Rotation = 0;
chartArea1.Area3DStyle.WallWidth = 0;
chartArea1.AxisX.LabelStyle.Font = new System.Drawing.Font("Trebuchet MS", 8.25F, System.Drawing.FontStyle.Bold);
chartArea1.AxisX.LineColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
chartArea1.AxisX.MajorGrid.LineColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
chartArea1.AxisY.LabelStyle.Font = new System.Drawing.Font("Trebuchet MS", 8.25F, System.Drawing.FontStyle.Bold);
chartArea1.AxisY.LineColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
chartArea1.AxisY.MajorGrid.LineColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
chartArea1.BackColor = System.Drawing.Color.Transparent;
chartArea1.BackSecondaryColor = System.Drawing.Color.Transparent;
chartArea1.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
chartArea1.BorderWidth = 0;
chartArea1.Name = "Default";
chartArea1.ShadowColor = System.Drawing.Color.Transparent;
this.chartPie.ChartAreas.Add(chartArea1);
Legend legend1 = new Legend();
legend1.Alignment = System.Drawing.StringAlignment.Center;
legend1.BackColor = System.Drawing.Color.Transparent;
legend1.Docking = Docking.Bottom;
legend1.Enabled = true;
legend1.Font = new System.Drawing.Font("Trebuchet MS", 8.25F, System.Drawing.FontStyle.Bold);
legend1.IsTextAutoFit = true;
legend1.Name = "Default";
this.chartPie.Legends.Add(legend1);
Title title1 = new Title();
title1.Font = new System.Drawing.Font("Trebuchet MS", 14.25F, System.Drawing.FontStyle.Bold);
title1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(26)))), ((int)(((byte)(59)))), ((int)(((byte)(105)))));
title1.Name = "Title";
title1.ShadowColor = System.Drawing.Color.FromArgb(((int)(((byte)(32)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
title1.ShadowOffset = 3;
title1.Text = "销量前十的产品统计饼图";
this.chartPie.Titles.Add(title1);
Series series1 = new Series();
series1.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(26)))), ((int)(((byte)(59)))), ((int)(((byte)(105)))));
series1.ChartArea = "Default";
series1["PieLabelStyle"] = "Outside";
series1["PieDrawingStyle"] = "Concave";
series1.ChartType = SeriesChartType.Pie;
series1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(65)))), ((int)(((byte)(140)))), ((int)(((byte)(240)))));
series1.Legend = "Default";
series1.Name = "Default";
this.chartPie.Series.Add(series1);
}
示例13: InitializeComponent
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
this.MonitorGrap = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.btnClose = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.MonitorGrap)).BeginInit();
this.SuspendLayout();
//
// MonitorGrap
//
this.MonitorGrap.BorderlineColor = System.Drawing.Color.Black;
this.MonitorGrap.BorderlineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Solid;
chartArea1.Name = "ChartArea1";
this.MonitorGrap.ChartAreas.Add(chartArea1);
legend1.Name = "Legend1";
this.MonitorGrap.Legends.Add(legend1);
this.MonitorGrap.Location = new System.Drawing.Point(12, 11);
this.MonitorGrap.Name = "MonitorGrap";
this.MonitorGrap.Size = new System.Drawing.Size(837, 280);
this.MonitorGrap.TabIndex = 0;
this.MonitorGrap.Text = "chart1";
//
// btnClose
//
this.btnClose.Location = new System.Drawing.Point(774, 298);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(75, 28);
this.btnClose.TabIndex = 1;
this.btnClose.Tag = "Common_Close";
this.btnClose.Text = "Close";
this.btnClose.UseVisualStyleBackColor = true;
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// FrmServerMonitor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(880, 339);
this.Controls.Add(this.btnClose);
this.Controls.Add(this.MonitorGrap);
this.Name = "FrmServerMonitor";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "ServerMonitor";
this.Load += new System.EventHandler(this.frmServerMonitor_Load);
((System.ComponentModel.ISupportInitialize)(this.MonitorGrap)).EndInit();
this.ResumeLayout(false);
}
示例14: GenerarReporte
private void GenerarReporte(List<Cita> list_citas, DateTime desde, DateTime hasta)
{
int i = 0; int j = 1; int iguales = 0;
this.chtGrafico.Titles.Clear();
this.chtGrafico.Legends.Clear();
this.chtGrafico.Series.Clear();
this.chtGrafico.Titles.Add(" Reportes Pacientes Atendidos - Generado el día: " + DateTime.Now + " " + System.Environment.NewLine + " " + System.Environment.NewLine + "Desde el día " + desde + " hasta el día " + hasta);
ArrayList list_iguales = new ArrayList();
foreach (Cita cita in list_citas)
{
this.list_fechas.Add(cita.Fecha);
}
SortedSet<DateTime> set = new SortedSet<DateTime>(list_fechas);
foreach (DateTime val in set)
{
iguales = 0;
foreach (Cita cita in list_citas)
{
if (cita.Fecha == val)
{
++iguales;
}
}
list_iguales.Add(iguales);
}
int x = list_fechas.Count;
int y = set.Count;
foreach (DateTime val in set)
{
Series serie = new Series();
Legend legend = new Legend();
serie.Legend = val.ToString();
legend.Name = "Hora-" + val;
legend.Title = "Horas de Atención";
this.chtGrafico.Legends.Add(legend);
this.chtGrafico.Series.Add(val.ToString());
this.chtGrafico.Series[i].Points.AddXY(j,list_iguales[i]);
this.chtGrafico.Series[i].ChartType = SeriesChartType.Bar;
this.chtGrafico.Series[i]["PointWidth"] = "0.6";
this.chtGrafico.Series[i].IsValueShownAsLabel = true;
this.chtGrafico.Series[i]["BarLabelStyle"] = "Center";
this.chtGrafico.Series[i]["DrawingStyle"] = "Emboss";
++i;++j;
}
chtGrafico.Update();
chtGrafico.UpdateAnnotations();
MessageBox.Show("Registro total de pacientes atendidos: " + list_citas.Count + "." + " " + System.Environment.NewLine + " " + System.Environment.NewLine + "Desde el día " + desde + " hasta el día " + hasta, "SFH Administración de Reportes y Estadísticas - Reportes de Pacientes", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
示例15: Show_MSChart
public Bitmap Show_MSChart()
{
try
{
if (!Check_Chart())
return null;
ChartArea chartArea = new ChartArea("chartArea");
Grid grid = new Grid();
grid.LineDashStyle = ChartDashStyle.Solid;
grid.LineColor = Color.Black;
Legend lengend = new Legend();
lengend.Docking = Docking.Right;
chartArea.AxisX.MajorGrid = grid;
chartArea.AxisY.MajorGrid = grid;
chartArea.AxisX.Interval = 1;
chartArea.AxisX.IsLabelAutoFit = false;
chartArea.BackColor = Color.FromArgb(0xEF, 0xEF, 0xEF);
Series series = new Series("危险度");
series.ChartType = SeriesChartType.Column;
//series.IsValueShownAsLabel = true;
series.Color = dataColor;
series.BorderWidth = 0;
SmartLabelStyle smartLabelStyle = new SmartLabelStyle();
smartLabelStyle.AllowOutsidePlotArea = LabelOutsidePlotAreaStyle.Yes;
series.SmartLabelStyle = smartLabelStyle;
series.Points.DataBindXY(dataTable.DefaultView, dataX, dataTable.DefaultView, dataY);
Chart chart = new Chart();
chart.Width = width;
chart.Height = height;
chart.ChartAreas.Add(chartArea);
chart.Series.Add(series);
chart.Legends.Add(lengend);
MemoryStream memoryStream = new MemoryStream();
chart.SaveImage(memoryStream, ChartImageFormat.Jpeg);
Bitmap bitmap = new Bitmap(memoryStream);
return bitmap;
}
catch (Exception ex)
{
return null;
}
}