當前位置: 首頁>>代碼示例>>C#>>正文


C# Chart.DataBind方法代碼示例

本文整理匯總了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;
        }
開發者ID:bedford603067,項目名稱:Augment,代碼行數:55,代碼來源:Dashboard.cs

示例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();
        }
開發者ID:ozzner,項目名稱:LapaSystem,代碼行數:74,代碼來源:Producto.aspx.cs


注:本文中的Chart.DataBind方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。