13 Replies - 7369 Views - Last Post: 14 January 2015 - 01:54 PM Rate Topic: -----

#1 csharp_user   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 12-January 15

How to use label properties by Serie.Points[1].Label ?

Posted 12 January 2015 - 08:58 AM

Dear C# programmers,

Can someone help me?
I use the Chart module to implement a diving profile.
It seems everything works fine except the use of labels.

Each point can have a label:
For example I attach a label name "Air" as following:

diving_profile.Points[1].Label = "Air";

This works fine. However I want to change the font size and use a connection line from the labeltext to its corresponding data point.
I can't find the correct c# syntax to do this.
1) How can I change the Font size of the label?
2) How can I use a connection line between the text and datapoint?

Thanks in advance,

John

Is This A Good Question/Topic? 0
  • +

Replies To: How to use label properties by Serie.Points[1].Label ?

#2 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6537
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: How to use label properties by Serie.Points[1].Label ?

Posted 12 January 2015 - 09:05 AM

Have you read the documentation on MSDN? It spells it out, so it seems odd you say "I can't find it". Are you just wanking with it on your PC until you stumble across it?

Let's see your code attempts to fix it so we can see where you are going wrong.

http://msdn.microsof...=vs.140%29.aspx

This MSDN page seems to be even more specific. Found by Googling the term "Chart label :msdn"
http://msdn.microsof...=vs.110%29.aspx
Was This Post Helpful? 0
  • +
  • -

#3 csharp_user   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 12-January 15

Re: How to use label properties by Serie.Points[1].Label ?

Posted 12 January 2015 - 09:10 AM

View PosttlhIn`toq, on 12 January 2015 - 09:05 AM, said:

Have you read the documentation on MSDN? It spells it out, so it seems odd you say "I can't find it". Are you just wanking with it on your PC until you stumble across it?

Let's see your code attempts to fix it so we can see where you are going wrong.

http://msdn.microsof...=vs.140%29.aspx

This MSDN page seems to be even more specific. Found by Googling the term "Chart label :msdn"
http://msdn.microsof...=vs.110%29.aspx


Thanks for your fast reply.
I am searching the net for a couple of hours and tried several things. If I had the answer I didn't use this forum!
It seems I have difficulty with the syntax.
Wat can I sent more to illustrate my problem?

John

View Postcsharp_user, on 12 January 2015 - 09:07 AM, said:

View PosttlhIn`toq, on 12 January 2015 - 09:05 AM, said:

Have you read the documentation on MSDN? It spells it out, so it seems odd you say "I can't find it". Are you just wanking with it on your PC until you stumble across it?

Let's see your code attempts to fix it so we can see where you are going wrong.

http://msdn.microsof...=vs.140%29.aspx

This MSDN page seems to be even more specific. Found by Googling the term "Chart label :msdn"
http://msdn.microsof...=vs.110%29.aspx


Thanks for your fast reply.
I am searching the net for a couple of hours and tried several things. If I had the answer I didn't use this forum!
It seems I have difficulty with the syntax.
Wat can I sent more to illustrate my problem?

John



I found also this page but how can I change the Fontsize of the label?
Does a Fontsize apply to all the datapoints for example or can I change a specific one?

John
Was This Post Helpful? 0
  • +
  • -

#4 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6537
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: How to use label properties by Serie.Points[1].Label ?

Posted 12 January 2015 - 09:29 AM

View Postcsharp_user, on 12 January 2015 - 10:10 AM, said:

It seems I have difficulty with the syntax.
Wat can I sent more to illustrate my problem?


As I already asked for:

View PosttlhIn`toq, on 12 January 2015 - 10:05 AM, said:

Let's see your code attempts to fix it so we can see where you are going wrong.



View Postcsharp_user, on 12 January 2015 - 10:10 AM, said:

I found also this page but how can I change the Fontsize of the label?
Does a Fontsize apply to all the datapoints for example or can I change a specific one?


MSDN Documentation said:

Axis Label Styles and Formats

You can set the axis label styles using the Axis object's LabelStyle property. Label style properties you set in this property, such as LabelStyle.Font, apply to an axis' labels. If the axis labels are too close to each other, you can set the LabelStyle.LabelsAutoFit or LabelStyle.Offset property to True.


John I'm not mad but will say this as one grown-up to another: You responded to my last post WAY TOO FAST to have even read over the documentation, let alone tried to experiment with anything the page was trying to tell you. As a developer its your responsibility to read through the documentation, try to make sense of it, and work with it, learning through some trial and error. You can't just throw your hands in the air after reading the first 3 paragraphs saying "I don't get it, I'll ask someone else to spoon-feed me an explanation."

So... lets see some effort on your part to read the docs and try to implement what they are explaining. When you reply next with issues I expect to see your code where you've tried to do this.
Was This Post Helpful? 0
  • +
  • -

#5 csharp_user   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 12-January 15

Re: How to use label properties by Serie.Points[1].Label ?

Posted 12 January 2015 - 10:21 AM

Ok, last try.....
I recently moved from VB to C# to implement a new diving program. In general I have no problems with the Chart module and as you can see a nice layout currently.
See the attached foto to understand the problem.
I really tried to find in the documentation how to implement my problem.
I tried to look for a Font class which can given a specific Font size. I see all kinds of label members but no member to change the label size.
diving_profile.Points[1].Label = "Air";
Something Like: diving_profile.Points[1].Label.FontSize = 24; ??
I also read that there is a way to draw a connection line from this labeltext to a specific data point.
In my example (see the attached picture) I use the text "Air".

I am not an experienced c# programmer so it takes some time to find all the members and properties and find a way to assign the right values.

John

Attached image(s)

  • Attached Image

This post has been edited by tlhIn`toq: 12 January 2015 - 10:27 AM
Reason for edit:: No need to quote the entire previous message: We all see it.

Was This Post Helpful? 0
  • +
  • -

#6 andrewsw   User is offline

  • palpable absurdity
  • member icon

Reputation: 6905
  • View blog
  • Posts: 28,567
  • Joined: 12-December 12

Re: How to use label properties by Serie.Points[1].Label ?

Posted 12 January 2015 - 10:28 AM

What is diving_profile? If it is a Series then you can do:
diving_profile.Font = New Font(Me.Font.Name, 5, FontStyle.Regular)


Note that there is no need to quote the previous post every time, there is a Reply button further down the page.
Was This Post Helpful? 0
  • +
  • -

#7 csharp_user   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 12-January 15

Re: How to use label properties by Serie.Points[1].Label ?

Posted 12 January 2015 - 10:40 AM

I created a new Serie like:
System.Windows.Forms.DataVisualization.Charting.Series diving_profile = new System.Windows.Forms.DataVisualization.Charting.Series();

When I use your code: diving_profile.Font = New Font(Me.Font.Name, 5, FontStyle.Regular);
I got an error: The name 'New' does not excist in the current context

But what Font do you change with this code? Is this the size of Points[1] for example?

John
Was This Post Helpful? 0
  • +
  • -

#8 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6537
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: How to use label properties by Serie.Points[1].Label ?

Posted 12 January 2015 - 10:56 AM

Quote

Ok, last try.....


Ok... My last try. The documentation tells you how to do this and I have asked twice for your code that shows where you are trying to do what they are saying and you've not provided anything that looks like you're trying.

I've never used this control and I haven't done WinForms in a couple years, but I can tell you this much: VB.NET and C# are both .NET languages and by now you should be able to read the documenation and understand what they mean when they say "Set the xyz property" or "provide a collection of abc objects"

MSDN Docz said:

Use custom labels to provide custom text for axes. Custom labels are implemented using the CustomLabels collection property. If you use custom labels, the chart area does not display axis labels from data points.


The labels at the bottom are from an attempt to make a CustomLabels collection. It seems to work.

Attached Image

If I sound frustrated its because I am. I've asked a couple times for your code where you've made an attempt to follow the documents and you've never provided it. I personally think you just aren't trying. Here's the code that produced the example you see. I'm bowing out of the conversation now because I'm simply not investing more time into your problem then you clearly are.

Spoiler

This post has been edited by tlhIn`toq: 12 January 2015 - 10:56 AM

Was This Post Helpful? 0
  • +
  • -

#9 csharp_user   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 12-January 15

Re: How to use label properties by Serie.Points[1].Label ?

Posted 12 January 2015 - 11:10 AM

I'm simply not investing more time into your problem then you clearly are. ??????

Sorry, I'm really don't understand.
I have been trying for hours at the moment to figure out how to resize my data point label.

There is no other code !!!!!
I controlled my chart olmost 95% with the standard properties within VS.

Sorry that I asked you something!

PS In your code I cannot find any Font sizing....

John
Was This Post Helpful? 0
  • +
  • -

#10 rgfirefly24   User is offline

  • D.I.C Lover
  • member icon


Reputation: 473
  • View blog
  • Posts: 2,221
  • Joined: 07-April 08

Re: How to use label properties by Serie.Points[1].Label ?

Posted 12 January 2015 - 11:41 AM

Here is the deal. You have been GIVEN resources to look over and read. Have you even tried anything to fix this issue? It looks like to us that you haven't, because you have not 1. Described what you have tried and 2. Shown us the code you have attempted. We are not going to do your work for you in any way, shape, or form. What we will do for you is ASSIST you by guiding you in your own attempts to fix the problem. Until you show us what you've done (with code) we can not help you any further.


As an aside, I found exactly what you were looking for after 2 seconds of googling. I typed this in google and found the answer: "Chart control change DataPoint Label font". Take that phrase, throw it in google, try to figure out how to do it on your own using the links. If you are still hitting roadblocks come back here with code and a clear description of what you tried; current output; and expected output and we will be able to help you further. Remember you get out what you put in, so unless you're willing to show us that you actually put some effort into it you will be hard pressed to get any real help.
Was This Post Helpful? 1
  • +
  • -

#11 andrewsw   User is offline

  • palpable absurdity
  • member icon

Reputation: 6905
  • View blog
  • Posts: 28,567
  • Joined: 12-December 12

Re: How to use label properties by Serie.Points[1].Label ?

Posted 12 January 2015 - 12:24 PM

Quote

The name 'New' does not excist in the current context

In C# it is new not New, but I assume that you've worked this out by now.
Was This Post Helpful? 0
  • +
  • -

#12 csharp_user   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 12-January 15

Re: How to use label properties by Serie.Points[1].Label ?

Posted 12 January 2015 - 12:32 PM

Deal!

At this moment The Font size is implemented and works!

diving_profile.Points[1].Font = new Font("Arial", 12, FontStyle.Regular);

I try to figure out how I can connect a line between the label and datapoint........

I'll be back....

John

View Postandrewsw, on 12 January 2015 - 12:24 PM, said:

Quote

The name 'New' does not excist in the current context

In C# it is new not New, but I assume that you've worked this out by now.


Correct, a few minutes ago I figured this out.

John
Was This Post Helpful? 0
  • +
  • -

#13 csharp_user   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 12-January 15

Re: How to use label properties by Serie.Points[1].Label ?

Posted 14 January 2015 - 01:52 PM

I have been busy for hours to implement the line (or callout line) from the datapoint to a label.
At the moment it seems no problem to show the data point label including size and angle. see the code below:
To test the code I use sometimes the comment brackets to exclude some parts.

werkelijk_duikprofiel.SmartLabelStyle.Enabled = false;
                werkelijk_duikprofiel.IsValueShownAsLabel = false;

                werkelijk_duikprofiel.Points[1].Label = "Air";
                werkelijk_duikprofiel.Points[1].LabelAngle = 10;
                werkelijk_duikprofiel.Points[1].LabelForeColor = Color.Yellow;
                werkelijk_duikprofiel.Points[1].Font = new Font("Arial", 12, FontStyle.Regular);

                werkelijk_duikprofiel.Points[2].Label = "EANX32";
                werkelijk_duikprofiel.Points[2].LabelForeColor = Color.Yellow;
                werkelijk_duikprofiel.Points[2].LabelAngle = 10;

However to include a callout line with labeltext including a surrounding box I try the code:

werkelijk_duikprofiel.SmartLabelStyle.Enabled = true;
                // Set the callout style.
                formduik1.Series[1].SmartLabelStyle.CalloutStyle = LabelCalloutStyle.Box;

                // Set the callout line color.
                formduik1.Series[1].SmartLabelStyle.CalloutLineColor = Color.Goldenrod;

                // Set the callout line style.
                formduik1.Series[1].SmartLabelStyle.CalloutLineDashStyle = ChartDashStyle.Dash;

                // Set the callout line width.
                formduik1.Series[1].SmartLabelStyle.CalloutLineWidth = 3;


Nothing happens :(

I try to implement the combination of a data point and label connected with a visible line. See my picture which I included. The middle label downunder is drawn in Paint to illustrate what I try to make......

Maybe someone can help me a bit.

John

Forgot the picture....
John

Attached image(s)

  • Attached Image

This post has been edited by andrewsw: 14 January 2015 - 01:56 PM
Reason for edit:: Removed quote and added code tags

Was This Post Helpful? 0
  • +
  • -

#14 andrewsw   User is offline

  • palpable absurdity
  • member icon

Reputation: 6905
  • View blog
  • Posts: 28,567
  • Joined: 12-December 12

Re: How to use label properties by Serie.Points[1].Label ?

Posted 14 January 2015 - 01:54 PM

@OP There is no need to quote a previous post, especially when your reply is not related to the post; there is a Reply button further down the page.

Also learn to use code tags, it demonstrates how to use them directly in the area where you are typing your post.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1