【问题标题】:asp.net chart series point label font formatsasp.net 图表系列点标签字体格式
【发布时间】:2012-05-24 22:24:58
【问题描述】:

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

'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

【问题讨论】:

    标签: asp.net mschart labels series


    【解决方案1】:

    你应该在这里看到它

    pt.Font
    

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

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

    【讨论】:

      【解决方案2】:

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

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

      然后将数据点的字体属性设置为它:

      pt.font = myFont;
      

      【讨论】:

        【解决方案3】:

        添加系列标签为 Font="Zurich BT, 11pt, style=Bold"

        【讨论】:

        • 能否附上代码示例,包括如何将其添加到系列中?这将有助于澄清建议,并有助于将其与现有的两个答案相提并论。
        • 喜欢这个 系列>
        猜你喜欢
        • 2012-11-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-11-21
        • 2012-09-04
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多