自定义MSCHART标签

时间:2012-04-09 21:09:54

标签: label mschart

如何格式化mschart中的标签,使其包含数据库中的X-Value和其他值,如下所示:

12 KG,200磅,45英里

让我们称之为MeasureUnit值,并且每个X值

都是deffirent 请帮助我

我试过了,但标签显示为0始终

    Chart1.Series(0).Points.DataBind(Data, XValue, YValue, "Label=" & YValue & ControlChars.Lf & LabelUnit)

这是Ans:

  Chart1.Series(0).Points.DataBind(Data, XValue, YValue, "Unit=" & LabelUnit)
    Chart1.Series("Series1").XValueMember = XValue
    Chart1.Series("Series1").YValueMembers = YValue

   For Each pnt As DataPoint In Chart1.Series(0).Points
        pnt.Label = "#VAL" & ControlChars.Lf & pnt.GetCustomProperty("Unit")

    Next
    Chart1.Series("Series1").IsValueShownAsLabel = True
    Chart1.Series("Series1").ToolTip = "#VAL"

1 个答案:

答案 0 :(得分:0)

您可以使用AxisLabel属性

chart1.Series[i].Points[i].AxisLabel = yourValue; // here yourValue is the value returned by database

如果您的系列已有数据,则可以

foreach (DataPoint dp in s.Points)
{
     dp.AxisLabel = dp.XValue + "yourUnit" ; // or write your own logic here
}