UltraChart 相关设置

    技术2022-05-11  9

    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。。。)

    区二、

    //创建绘图区域ChartArea myChartArea = new ChartArea();myChartArea.BoundsMeasureType = MeasureType.Percentage;myChartArea.Bounds =  new Rectangle( 0, 0, 100, 80 );myChartArea.Border.Thickness = 0;表明ChartArea绘图区域占整个UltraChart的比例:宽100%,高80%,位置呢从左顶点(0,0)起

    //创建X轴线AxisItem xAxis = new AxisItem();xAxis.axisNumber = AxisNumber.X_Axis;xAxis.Labels.Orientation = TextOrientation.VerticalLeftFacing;xAxis.DataType = AxisDataType.String;xAxis.SetLabelAxisType = SetLabelAxisType.GroupBySeries;xAxis.Labels.ItemFormatString = "<ITEM_LABEL>";xAxis.Extent = 10;此处Extent决定着X轴线偏离绘图区域边界的大小,恰当设置轴线的Extent值可以调整图表区域的大小

    //控件默认数据绑定Infragistics.UltraChart.Resources.Util.DemoSetup(this.UltraChart1);Infragistics的UltraChart为其每个图表类型定制了完美的数据,这可以从其图表向导里看到。我们并没有指定图表的数据,但是我们所设置好图表属性后,生成的图表默认就绑定了些数据,这就是控件所定制而来。

    //图表轴向间距:可以按百分比控制设置this.UltraChart1.Axis.Y.TickmarkStyle = AxisTickStyle.Percentage;this.UltraChart1.Axis.Y.TickmarkPercentage = 20;

    //图表轴向间距:可以按照指定数据间隔设置this.UltraChart1.Axis.Y.TickmarkStyle = AxisTickStyle.DataInterval;this.UltraChart1.Axis.Y.TickmarkInterval=25;

    //设置图表轴向标签倾角this.UltraChart1.Axis.X.Labels.Orientation =Infragistics.UltraChart.Shared.Styles.TextOrientation.Custom;this.UltraChart1.Axis.X.Labels.OrientationAngle = 240;this.UltraChart1.Axis.X.Labels.Flip = true; 

    //在饼图上显示提示信息来代替显示数据百分比值this.ultraChart1.PieChart.Labels.Format = Infragistics.UltraChart.Shared.Styles.PieLabelFormat.ItemLabel;this.ultraChart1.PieChart.Labels.FormatString = "<ITEM_LABEL>";


    最新回复(0)