NetAdvantage 2006/UltraChart图表基础属性及数据绑定

Infragistics.Win.UltraWinChart.UltraChart chart=new Infragistics.Win.UltraWinChart.UltraChart();;
            if (Cds.Tables.Count > 0)
            {
                chart.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                                | System.Windows.Forms.AnchorStyles.Right)));

                #region chart 属性
                chart.Axis.X.Extent = 45;
                chart.Axis.X.Labels.Flip = false;
                chart.Axis.X.Labels.HorizontalAlign = System.Drawing.StringAlignment.Near;
                chart.Axis.X.Labels.Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.Horizontal;
                chart.Axis.X.Labels.OrientationAngle = 0;
                chart.Axis.X.Labels.SeriesLabels.Flip = false;
                chart.Axis.X.Labels.SeriesLabels.FormatString = DateTime.Now.ToLongTimeString();
                chart.Axis.X.Labels.SeriesLabels.HorizontalAlign = System.Drawing.StringAlignment.Center;
                chart.Axis.X.Labels.SeriesLabels.Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.VerticalLeftFacing;
                chart.Axis.X.Labels.SeriesLabels.OrientationAngle = 0;
                chart.Axis.X.Labels.SeriesLabels.VerticalAlign = System.Drawing.StringAlignment.Center;
                chart.Axis.X.Labels.VerticalAlign = System.Drawing.StringAlignment.Center;
                chart.Axis.X.LineThickness = 1;
                chart.Axis.X.MajorGridLines.AlphaLevel = ((byte)(255));
                chart.Axis.X.MajorGridLines.Color = System.Drawing.Color.Gainsboro;
                chart.Axis.X.MajorGridLines.DrawStyle = Infragistics.UltraChart.Shared.Styles.LineDrawStyle.Dot;
                chart.Axis.X.MajorGridLines.Thickness = 1;
                chart.Axis.X.MajorGridLines.Visible = true;
                chart.Axis.X.MinorGridLines.AlphaLevel = ((byte)(255));
                chart.Axis.X.MinorGridLines.Color = System.Drawing.Color.LightGray;
                chart.Axis.X.MinorGridLines.DrawStyle = Infragistics.UltraChart.Shared.Styles.LineDrawStyle.Dot;
                chart.Axis.X.MinorGridLines.Thickness = 1;
                chart.Axis.X.MinorGridLines.Visible = false;
                chart.Axis.X.ScrollScale.Height = 10;
                chart.Axis.X.ScrollScale.Visible = false;
                chart.Axis.X.ScrollScale.Width = 15;
                chart.Axis.X.TickmarkInterval = 0;
                chart.Axis.X.Visible = true;

                chart.Axis.Y.Extent = 30;
                chart.Axis.Y.Labels.Flip = false;
                chart.Axis.Y.Labels.HorizontalAlign = System.Drawing.StringAlignment.Far;
                chart.Axis.Y.Labels.ItemFormatString = "<DATA_VALUE:00.##>";
                chart.Axis.Y.Labels.Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.Horizontal;
                chart.Axis.Y.Labels.OrientationAngle = 0;
                chart.Axis.Y.Labels.SeriesLabels.Flip = false;
                chart.Axis.Y.Labels.SeriesLabels.FormatString = "";
                chart.Axis.Y.Labels.SeriesLabels.HorizontalAlign = System.Drawing.StringAlignment.Far;
                chart.Axis.Y.Labels.SeriesLabels.Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.Horizontal;
                chart.Axis.Y.Labels.SeriesLabels.OrientationAngle = 0;
                chart.Axis.Y.Labels.SeriesLabels.VerticalAlign = System.Drawing.StringAlignment.Center;
                chart.Axis.Y.Labels.VerticalAlign = System.Drawing.StringAlignment.Center;
                chart.Axis.Y.LineThickness = 1;
                chart.Axis.Y.RangeMax = 1000;
                chart.Axis.Y.RangeType = Infragistics.UltraChart.Shared.Styles.AxisRangeType.Automatic;//Y轴最大值设置为自动
                chart.Axis.Y.MajorGridLines.AlphaLevel = ((byte)(255));
                chart.Axis.Y.MajorGridLines.Color = System.Drawing.Color.Gainsboro;
                chart.Axis.Y.MajorGridLines.DrawStyle = Infragistics.UltraChart.Shared.Styles.LineDrawStyle.Dot;
                chart.Axis.Y.MajorGridLines.Thickness = 1;
                chart.Axis.Y.MajorGridLines.Visible = true;
                chart.Axis.Y.MinorGridLines.AlphaLevel = ((byte)(255));
                chart.Axis.Y.MinorGridLines.Color = System.Drawing.Color.LightGray;
                chart.Axis.Y.MinorGridLines.DrawStyle = Infragistics.UltraChart.Shared.Styles.LineDrawStyle.Dot;
                chart.Axis.Y.MinorGridLines.Thickness = 1;
                chart.Axis.Y.MinorGridLines.Visible = true;
                chart.Axis.Y.ScrollScale.Height = 10;
                chart.Axis.Y.ScrollScale.Visible = false;
                chart.Axis.Y.ScrollScale.Width = 15;
                chart.Axis.Y.TickmarkInterval = 0;
                chart.Axis.Y.Visible = true;
                chart.Border.Color = System.Drawing.Color.Silver;
                chart.Border.CornerRadius = 5;
                chart.Border.Raised = true;

                chart.ColorModel.AlphaLevel = ((byte)(150));
                chart.ColorModel.ColorBegin = System.Drawing.Color.LimeGreen;
                chart.ColorModel.ColorEnd = System.Drawing.Color.Gold;
                chart.ColorModel.ModelStyle = Infragistics.UltraChart.Shared.Styles.ColorModels.LinearRange;
                chart.ColorModel.Scaling = Infragistics.UltraChart.Shared.Styles.ColorScaling.Increasing;

                chart.Data.EmptyStyle.LineStyle.DrawStyle = Infragistics.UltraChart.Shared.Styles.LineDrawStyle.Dash;
                chart.Data.EmptyStyle.LineStyle.EndStyle = Infragistics.UltraChart.Shared.Styles.LineCapStyle.NoAnchor;
                chart.Data.EmptyStyle.LineStyle.MidPointAnchors = false;
                chart.Data.EmptyStyle.LineStyle.StartStyle = Infragistics.UltraChart.Shared.Styles.LineCapStyle.NoAnchor;
                chart.Data.MaxValue = 500;
                chart.Data.MinValue = 0;
                chart.Data.SwapRowsAndColumns = true;

                chart.Legend.BackgroundColor = System.Drawing.Color.LemonChiffon;
                chart.Legend.BorderColor = System.Drawing.Color.DimGray;
                chart.Legend.DataAssociation = Infragistics.UltraChart.Shared.Styles.ChartTypeData.ColumnData;
                chart.Legend.Location = Infragistics.UltraChart.Shared.Styles.LegendLocation.Bottom;
                chart.Legend.SpanPercentage = 5;
                chart.Legend.Visible = true;

                chart.TitleBottom.Visible = false;
                chart.TitleTop.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold);
                chart.TitleTop.FontColor = System.Drawing.Color.Red;
                chart.TitleTop.VerticalAlign = System.Drawing.StringAlignment.Center;
                chart.TitleTop.Text = "标题";

                chart.Tooltips.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F);
                chart.Tooltips.TooltipControl = null;
                chart.Tooltips.UseControl = false;

                chart.ForeColor = System.Drawing.SystemColors.ControlText;
                chart.TabIndex = 10;
                chart.Name = item.Text.ToString();
                chart.Size = new System.Drawing.Size(400, 295);//图表的大小设置
                chart.Location = new System.Drawing.Point(5, 300);//设置画图表的位置
                #endregion

                chart.ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.ColumnChart;//图表的显示样式

此为简单的双向(X,Y)坐标图表,绘制多维图表可增加相应的坐标参数,如(X2,Y2,Z,Z2。。。)


绑定到数据源

1.创建一个DataTable

DataTable table = new DataTable();
                table.Columns.AddRange(
                    new DataColumn[]
    {
     new DataColumn("Day", Type.GetType("System.String")),
     new DataColumn("inMaxValue", Type.GetType("System.Double")),
     new DataColumn("inAVGValue", Type.GetType("System.Double")),
     new DataColumn("OutMaxValue", Type.GetType("System.Double")),
     new DataColumn("OutAVGValue", Type.GetType("System.Double"))
    });//创建5列
                DataRow dr = table.NewRow();//创建行如DataSet关联
                for (int i = 0; i < Dataset.Tables[0].Rows.Count; i++)
                {
                    if (Dataset.Tables[0].Rows[i][0].ToString().Split(Convert.ToChar(':'))[1] == item.Text)
                    {
                        dr["Day"] = Dataset.Tables[0].Rows[i][0].ToString();
                        dr["inMaxValue"] = Dataset.Tables[0].Rows[i][1].ToString();
                        dr["inAVGValue"] = Dataset.Tables[0].Rows[i][2].ToString();
                        dr["OutMaxValue"] = Dataset.Tables[0].Rows[i][3].ToString();
                        dr["OutAVGValue"] = Dataset.Tables[0].Rows[i][4].ToString();
                    }

                } table.Rows.Add(dr);
                chart.DataSource = table;//绑定


如有问题也可以到我的论坛去发布,http://www.w766.com


 
阅读更多
换一批

没有更多推荐了,返回首页