Sorry for my english.
There two piechart in one picture, and the ChartType is Composite mode.
Problem appears, plz see the following picture:
Can i change the "Others" to a custom letter, such as "Other datas,<1%".
I try to set it as:webchart.PieChart.OthersCategoryPercent = 1;webchart.PieChart.OthersCategoryText = "Other datas,<1%";
but the "Others" still appears, nothing has been changed.
All source code:
private Infragistics.WebUI.UltraWebChart.UltraChart GetChart(DataTable table1, DataTable table2, string DW, string year) { UltraChart webchart = new Infragistics.WebUI.UltraWebChart.UltraChart();//实例化对象 webchart.ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.Composite;//指定webchart的类型为混合型 //创建area ChartArea area1 = new Infragistics.UltraChart.Resources.Appearance.ChartArea();//创建chartarea ChartArea area2 = new Infragistics.UltraChart.Resources.Appearance.ChartArea();//创建chartarea area1.Bounds = new System.Drawing.Rectangle(12, 30, 275, 220);//设置area的位置大小 area2.Bounds = new System.Drawing.Rectangle(320, 30, 275, 220); area1.Border.Thickness = 0;//设置边框线不显示 area2.Border.Thickness = 0; webchart.CompositeChart.ChartAreas.Add(area1); webchart.CompositeChart.ChartAreas.Add(area2);
//创建Series NumericSeries series1 = new Infragistics.UltraChart.Resources.Appearance.NumericSeries();//创建Series series1.Data.DataSource = table1; series1.Data.LabelColumn = "类型"; series1.Data.ValueColumn = "数值"; webchart.CompositeChart.Series.Add(series1); if (GetSumCount(table1, "数值") == 0) { EmptyDataShow(webchart, 30, 46);//无数据显示注释信息的位置 }
NumericSeries series2 = new Infragistics.UltraChart.Resources.Appearance.NumericSeries();//创建Series series2.Data.DataSource = table2; series2.Data.LabelColumn = "类型"; series2.Data.ValueColumn = "数值"; webchart.CompositeChart.Series.Add(series2); if (GetSumCount(table2, "数值") == 0) { EmptyDataShow(webchart, 70, 46);//无数据显示注释信息的位置 }
//创建layer ChartLayerAppearance layer1 = new Infragistics.UltraChart.Resources.Appearance.ChartLayerAppearance(); layer1.ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.PieChart;//指定为饼图 layer1.ChartArea = area1; layer1.Series.Add(series1); webchart.CompositeChart.ChartLayers.Add(layer1);
ChartLayerAppearance layer2 = new Infragistics.UltraChart.Resources.Appearance.ChartLayerAppearance(); layer2.ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.PieChart;//指定为饼图 layer2.ChartArea = area2; layer2.Series.Add(series2); webchart.CompositeChart.ChartLayers.Add(layer2);
#region 指定Legend并指定显示位置 CompositeLegend legend1 = new CompositeLegend(); legend1.ChartLayers.Add(layer1); legend1.Bounds = new System.Drawing.Rectangle(35, 11, 15, 20);//设置位置 legend1.BoundsMeasureType = Infragistics.UltraChart.Shared.Styles.MeasureType.Percentage;//百分比显示位置 legend1.PE.ElementType = Infragistics.UltraChart.Shared.Styles.PaintElementType.Gradient; legend1.PE.FillGradientStyle = Infragistics.UltraChart.Shared.Styles.GradientStyle.ForwardDiagonal; legend1.PE.Fill = System.Drawing.Color.CornflowerBlue; legend1.PE.FillStopColor = System.Drawing.Color.Transparent; legend1.Border.CornerRadius = 5; legend1.Border.Thickness = 0; webchart.CompositeChart.Legends.Add(legend1);
CompositeLegend legend2 = new CompositeLegend(); legend2.ChartLayers.Add(layer2); legend2.Bounds = new System.Drawing.Rectangle(80, 11, 15, 20);//设置位置 legend2.BoundsMeasureType = Infragistics.UltraChart.Shared.Styles.MeasureType.Percentage;//百分比显示位置 legend2.PE.ElementType = Infragistics.UltraChart.Shared.Styles.PaintElementType.Gradient; legend2.PE.FillGradientStyle = Infragistics.UltraChart.Shared.Styles.GradientStyle.ForwardDiagonal; legend2.PE.Fill = System.Drawing.Color.CornflowerBlue; legend2.PE.FillStopColor = System.Drawing.Color.Transparent; legend2.Border.CornerRadius = 5; legend2.Border.Thickness = 0; webchart.CompositeChart.Legends.Add(legend2); #endregion
webchart.Width = 700; webchart.TitleTop.Text = year + "“" + DW + "” PieChart"; webchart.TitleTop.Font = new System.Drawing.Font("Arial", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134))); webchart.TitleTop.HorizontalAlign = System.Drawing.StringAlignment.Center; webchart.ColorModel.ModelStyle = Infragistics.UltraChart.Shared.Styles.ColorModels.CustomLinear;//指定生成图的颜色 webchart.ColorModel.ColorBegin = System.Drawing.Color.DarkGoldenrod; webchart.ColorModel.ColorEnd = System.Drawing.Color.Navy; webchart.ColorModel.Skin.ApplyRowWise = true; webchart.ColorModel.AlphaLevel = 150; webchart.CrossHairColor = System.Drawing.Color.Blue; webchart.EnableViewState = false; //webchart.Legend.FormatString = "<ITEM_LABEL>(<DATA_VALUE:##>个)"; webchart.EmptyChartText = "No data!"; webchart.PieChart.OthersCategoryPercent = 1; webchart.PieChart.OthersCategoryText = "Other datas,<1%"; return webchart;}
add this code and you should be all set:
PieChartAppearance pieApp1 = layer1.ChartTypeAppearance as PieChartAppearance; PieChartAppearance pieApp2 = layer2.ChartTypeAppearance as PieChartAppearance; pieApp1.OthersCategoryPercent = pieApp2.OthersCategoryPercent = 1; pieApp1.OthersCategoryText = pieApp2.OthersCategoryText = "Other datas,<1%";