private void AddCharts() { if (CLB_Fields.CheckedItems.Count < 1) { return; } VectorLayer aLayer = (VectorLayer)_mapLayer; aLayer.ChartSet.ChartType = (ChartTypes)Enum.Parse(typeof(ChartTypes), CB_ChartType.Text); List <string> fieldNames = new List <string>(); int i, j; for (i = 0; i < CLB_Fields.CheckedItems.Count; i++) { fieldNames.Add(CLB_Fields.CheckedItems[i].ToString()); } aLayer.ChartSet.FieldNames = fieldNames; aLayer.ChartSet.LegendScheme = legendView_Chart.LegendScheme; aLayer.ChartSet.MinSize = int.Parse(TB_MinSize.Text); aLayer.ChartSet.MaxSize = int.Parse(TB_MaxSize.Text); aLayer.ChartSet.BarWidth = int.Parse(TB_BarWidth.Text); aLayer.ChartSet.XShift = int.Parse(TB_XShift.Text); aLayer.ChartSet.YShift = int.Parse(TB_YShift.Text); aLayer.ChartSet.AvoidCollision = CHB_Collision.Checked; aLayer.ChartSet.AlignType = (AlignType)Enum.Parse(typeof(AlignType), CB_Align.Text); aLayer.ChartSet.View3D = CHB_View3D.Checked; aLayer.ChartSet.Thickness = int.Parse(TB_Thickness.Text); List <List <float> > values = new List <List <float> >(); List <float> minList = new List <float>(); List <float> maxList = new List <float>(); List <float> sumList = new List <float>(); for (i = 0; i < aLayer.ShapeNum; i++) { List <float> vList = new List <float>(); float sum = 0; float v; for (j = 0; j < fieldNames.Count; j++) { v = float.Parse(aLayer.GetCellValue(fieldNames[j], i).ToString()); vList.Add(v); sum += v; } values.Add(vList); minList.Add(vList.Min()); maxList.Add(vList.Max()); sumList.Add(sum); } switch (aLayer.ChartSet.ChartType) { case ChartTypes.BarChart: aLayer.ChartSet.MinValue = minList.Min(); aLayer.ChartSet.MaxValue = maxList.Max(); break; case ChartTypes.PieChart: aLayer.ChartSet.MinValue = sumList.Min(); aLayer.ChartSet.MaxValue = sumList.Max(); break; } aLayer.AddCharts(); }