locked
How to set size and font in data points label ? RRS feed

  • Question

  • Hi there.

    I'd appreciate your help so very much.

    I have question for you: how to set size and font in data points label ?

    Thansk in advance.

    Chart1.Series["Series1"].IsValueShownAsLabel = true;   // Set data points label style
    
    ....

    Friday, March 2, 2012 7:58 PM

Answers

  • thanks this i the solution for my case:

           Chart1.Series["Default2"].ChartType = SeriesChartType.Column;
           Chart1.Series["Default2"]["LabelStyle"] = "Center";
           Chart1.Series["Default2"]["PointWidth"] = "0.7";
           Chart1.Series["Default2"].IsValueShownAsLabel = true;
           Chart1.Series["Default2"].Font = new System.Drawing.Font("Arial", 12);
           Chart1.Series["Default2"]["LabelStyle"] = "Top";
           Chart1.Series["Default2"].LabelBackColor = Color.LightCyan;


    • Marked as answer by cms9651 Saturday, March 3, 2012 11:08 AM
    Friday, March 2, 2012 10:27 PM

All replies

  • hi cms

    iterate through each datapoint and set the Font

    For Each dp As DataPoint In Chart1.Series(0).Points
                dp.Font = New Font(dp.Font.Name, 18, FontStyle.Italic)
            Next


    P.S. in your other thread, please unmark your post as the answer and mark the post(s) provided by others as the answer. This allows others to see which information or code solves the problem
    Friday, March 2, 2012 8:03 PM
    Moderator
  • I'm sorry... I don'y understand... this not working...

           Chart1.Series["Default2"].ChartType = SeriesChartType.Column;
           Chart1.Series["Default2"]["PointWidth"] = "0.7";
           Chart1.Series["Default2"].IsValueShownAsLabel = true;
           
           For Each dp As DataPoint In Chart1.Series["Default2"].Points
                dp.Font = New Font(dp.Font.Name, 18, FontStyle.Italic)
           Next

    Friday, March 2, 2012 8:10 PM
  • P.S. in your other thread, please unmark your post as the answer and mark the post(s) provided by others as the answer (you can see the 2 posts that Sipla proposed as the answer - those would be the ones to mark). This allows others to see which information or code solves the problem

    the code I posted is in VB

    you'll need to convert it to the equivalent C# code, if needed

    otherwise what exactly do you mean "this not working"? Is it throwing an error? Won't compile? Runs but doesn't change anything?

    If you want a different Font replace the dp.Font.Name with the name of a Font you want like "Arial"

    you can also leave off the FontStyle if you want - I just added it to show what else you can do

    dp.Font = New Font("Arial", 18, FontStyle.Italic)


    Friday, March 2, 2012 9:50 PM
    Moderator
  • thanks this i the solution for my case:

           Chart1.Series["Default2"].ChartType = SeriesChartType.Column;
           Chart1.Series["Default2"]["LabelStyle"] = "Center";
           Chart1.Series["Default2"]["PointWidth"] = "0.7";
           Chart1.Series["Default2"].IsValueShownAsLabel = true;
           Chart1.Series["Default2"].Font = new System.Drawing.Font("Arial", 12);
           Chart1.Series["Default2"]["LabelStyle"] = "Top";
           Chart1.Series["Default2"].LabelBackColor = Color.LightCyan;


    • Marked as answer by cms9651 Saturday, March 3, 2012 11:08 AM
    Friday, March 2, 2012 10:27 PM