日期:2014-05-19  浏览次数:21143 次

zedgraph绘制直方图,直方图数据不能显示小数
我的y轴是字符型,x轴是数字型,
结果22.15总是显示为22,小数显示不出来,
看了有一天了,还是做不出来,请大家帮帮忙,


代码如下:
GraphPane   myPane   =   zgc.GraphPane;

//先清空
myPane.Title.Text= " ";              
myPane.XAxis.Title.Text= " ";
myPane.YAxis.Title.Text= " ";
myPane.CurveList.Clear();
myPane.GraphObjList.Clear();

//   设置图表的说明文字
myPane.Title.Text   =   "直方图 ";
myPane.Title.FontSpec.FontColor=Color.Blue;

//   设置横坐标的说明文字
myPane.XAxis.Title.Text   =   "效率(%) ";
myPane.XAxis.Title.FontSpec.Size=15;

//   设置纵坐标的说明文字
myPane.YAxis.Title.Text   =   "车间 ";
myPane.YAxis.Title.FontSpec.Size=15;

//设置基于y轴排列柱状图
myPane.BarSettings.Base=BarBase.Y;

//y轴刻度显示为文本类型
myPane.YAxis.Type=AxisType.Text;

//   turn   off   the   opposite   tics   so   the   Y   tics   don 't   show   up   on   the   Y2   axis
myPane.YAxis.MajorTic.IsOpposite   =   false;
myPane.YAxis.MinorTic.IsOpposite   =   false;

myPane.XAxis.MajorTic.IsOpposite   =   false;
myPane.XAxis.MinorTic.IsOpposite   =   false;


//设置y轴显示“柱子”的起始和终止位置
myPane.YAxis.Scale.Max=10;
myPane.YAxis.Scale.Min=0;

myPane.XAxis.Scale.Min=0;
myPane.XAxis.Scale.Max=100;



string   []   machine={ "L13 ", "L15 ", "L16 ", "L17 "};
double   []   efficiency={22.15,13.66,56.93,7.02};

myPane.YAxis.MajorTic.IsBetweenLabels=false;

myPane.YAxis.Scale.TextLabels=machine;

BarItem   myCurve=myPane.AddBar( " ",efficiency,null,Color.Green);

//设置bar的颜色
myCurve.Bar.Fill=new   Fill(Color.Green,Color.White,Color.Green,90);


//   设置背景颜色
myPane.Chart.Fill   =   new   Fill(   Color.White,
Color.FromArgb(   255,   255,   166),   45.0F   );

zgc.AxisChange();

//   创建每条bar的label,其中第2个参数表示是否显示在bar的中心位置,第3个参数表示label的排列方向
BarItem.CreateBarLabels(   myPane,   false,   "f0 "   );

//刷新页面
zgc.Refresh();

------解决方案--------------------
图表组件wsChart4.6(DLL版)
------解决方案--------------------
将数值型改为浮点型行不行啊?
整数没有小数点的。