2012-05-24 14 views
0

我目前正在使用下面显示的代码格式化我的图表系列点系列,但我没有看到任何方法来更改点标签文本的字体。 有谁知道在哪里访问点标签的字体属性?asp.net图表系列点标签字体格式

'set the series point color dependent on value and retrieve the best & worst values 
    Dim bestval As Double = 0.0 
    Dim worstval As Double = 0.0 
    For Each pt As DataPoint In cht.Series("MonthPL").Points 
     'pt.IsValueShownAsLabel = True 
     pt.Label = "#VALY{C0}" 
     pt.LabelToolTip = "#AXISLABEL 's P/L is #VALY{C0}" 
     If pt.YValues(0) < 0 Then 
      If pt.YValues(0) < worstval Then worstval = pt.YValues(0) 
      pt.Color = Color.Red 
      pt.LabelForeColor = Color.Black 
     Else 
      If pt.YValues(0) > bestval Then bestval = pt.YValues(0) 
      pt.Color = Color.DarkGreen 
      pt.LabelForeColor = Color.GhostWhite 
     End If 
    Next 

回答

1

你应该看到它在这里

pt.Font 

我在C#中使用的实际代码是

Chart1.Series[0].Points[0].Font 
0

声明一个新的字体,并使用:

Font myFont = new Font(FontFamily.Generic.SansSerif, 14, FontStyle.Bold); 

然后设置你的数据点的字体属性:

pt.font = myFont;