本文整理汇总了C#中Chart.DataBind方法的典型用法代码示例。如果您正苦于以下问题:C# Chart.DataBind方法的具体用法?C# Chart.DataBind怎么用?C# Chart.DataBind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chart
的用法示例。
在下文中一共展示了Chart.DataBind方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BindChartData
private Chart BindChartData(BoundChartData data)
{
Chart chart = new Chart();
chart.Width = CHART_WIDTH;
chart.Height = CHART_HEIGHT;
chart.Attributes.Add("align", "left");
chart.Titles.Add(data.Title); // Display a Title
chart.ChartAreas.Add(new ChartArea());
chart.Legends.Add(new Legend("Legend"));
chart.Legends[0].TableStyle = LegendTableStyle.Auto;
chart.Legends[0].Docking = Docking.Bottom;
for (int index = 0; index < data.yValueMembers.Length; index++)
{
chart.Series.Add(new Series());
chart.Series[index].XValueMember = data.xValueMember;
chart.Series[index].YValueMembers = data.yValueMembers[index];
chart.Series[index].ChartType = data.ChartType; // SeriesChartType.Pie, SeriesChartType.Bar
chart.Series[index].BackGradientStyle = GradientStyle.DiagonalLeft;
chart.Series[index].BackSecondaryColor = System.Drawing.Color.LightGray;
}
chart.Series[0].Legend = chart.Legends[0].Name;
switch (data.ChartType)
{
case SeriesChartType.Pie:
{
chart.Series[0]["PieLabelStyle"] = "Inside";
chart.Series[0]["PieLabelStyle"] = "Disabled";
chart.Series[0]["PieLineColor"] = "Black";
chart.Series[0]["PieDrawingStyle"] = "Concave";
break;
}
}
chart.DataSource = data.DataSource;
chart.DataBind();
foreach (DataPoint pt in chart.Series[0].Points)
{
string pointId = !string.IsNullOrEmpty(pt.AxisLabel) ? pt.AxisLabel : (pt.XValue + "," + pt.YValues);
pt.Url = data.pointUrl + pointId;
pt.ToolTip = "Drilldown";
pt.LegendText = "#VALX: #VALY";
pt.LegendUrl = data.legendUrl + pointId;
pt.LegendToolTip = "Click to view " + pointId + "'information...";
}
return chart;
}
示例2: generarGrafico
private void generarGrafico(int orden, List<ENT_Parametro> oEnt_Parametro, Chart grafico, ENT_ProductoParametro oEntidad)
{
grafico.DataSource = oEnt_Parametro;
grafico.Series[0].XValueMember = "CodigoMuestra";
grafico.Series[0].YValueMembers = "Resultado";
grafico.Series[0].IsValueShownAsLabel = true;
grafico.Series[1].XValueMember = "CodigoMuestra";
grafico.Series[1].YValueMembers = "Resultado";
grafico.Series[1].IsValueShownAsLabel = true;
// Add striplines to Chart
string minAccion = oEnt_Parametro[0].MinAccion.ToString();
string minAdvert = oEnt_Parametro[0].MinAdvertencia.ToString();
string promedio = oEnt_Parametro[0].Promedio.ToString();
string maxAdvert = oEnt_Parametro[0].MaxAdvertencia.ToString();
string maxAccion = oEnt_Parametro[0].MaxAccion.ToString();
//double p = (double)oEnt_Parametro.Min(z => z.Resultado);
//int roundedpmin = ((int)Math.Round(p / 10.0)) * 10;
//grafico.ChartAreas[0].AxisY.Minimum = roundedpmin;
//grafico.ChartAreas[0].RecalculateAxesScale();
//grafico.ChartAreas[0].AxisY.Minimum = 20;
grafico.ChartAreas[0].AxisY.IsStartedFromZero = false;
grafico.ChartAreas[0].AxisY.StripLines.Add(new StripLine()
{
StripWidth = 0,
BorderColor = Color.Red,
BorderWidth = 2,
Interval = 0,
ToolTip = "Min Accion - " + minAccion,
IntervalOffset = Double.Parse(minAccion)
});
grafico.ChartAreas[0].AxisY.StripLines.Add(new StripLine()
{
StripWidth = 0,
BorderColor = Color.OrangeRed,
BorderWidth = 2,
Interval = 0,
ToolTip = "Min Advertencia - " + minAdvert,
IntervalOffset = Double.Parse(minAdvert)
});
grafico.ChartAreas[0].AxisY.StripLines.Add(new StripLine()
{
StripWidth = 0,
BorderColor = Color.Green,
BorderWidth = 2,
Interval = 0,
ToolTip = "Promedio - " + promedio,
IntervalOffset = Double.Parse(promedio)
});
grafico.ChartAreas[0].AxisY.StripLines.Add(new StripLine()
{
StripWidth = 0,
BorderColor = Color.OrangeRed,
BorderWidth = 2,
Interval = 0,
ToolTip = "Max Advertencia - " + maxAdvert,
IntervalOffset = Double.Parse(maxAdvert)
});
grafico.ChartAreas[0].AxisY.StripLines.Add(new StripLine()
{
StripWidth = 0,
BorderColor = Color.Red,
BorderWidth = 2,
Interval = 0,
ToolTip = "Max Accion - " + maxAccion,
IntervalOffset = Double.Parse(maxAccion)
});
grafico.Titles.Add(oEntidad.NomParametro + " (" + oEntidad.UnidadMedida + ")");
grafico.DataBind();
}