Jump to content
Software FX Community

How to apply multiple formats on point labels


ubaid.tariq

Recommended Posts

 Hi

 I have to show multiple values in a single point label say %v and %p and i want the format only to be applied on %v but when i apply it using

chart1.AxisY.DataFormat, the format is applied on both the values. How can i stop %p from adapting the DataFormat???

 

Regards,

Ubaid Tariq

Link to comment
Share on other sites

Hi .... I posted a wrong query. the actual query is how can i apply different data formats on different points in a single series. Say i have 2 points "P1" and "P2" in series "S". How can i set currency format to P1 and scientific format to P2 ? I am trying to do so using chart.AxisY.DataFormat but it applies to all points in all the series.

 

Regards,

Ubaid Tariq

Link to comment
Share on other sites

You can use chart.GetPointLabel event to return custom point labels on the fly. This event must be enabled first by setting chart.Axis(n).Notify to true.

It could degrade performance a bit if you have a large number of points, but if you need to show all the values all the time, it is the only way.

If you don't have to show actual values all the time, you can hide them and override chart.GetTip to change the text shown in the tooltip, which does not affect performance.

Link to comment
Share on other sites

It is working fine as far as label text is concerned. I have tried applying different back Color and Border Style on individual points but its not giving correct result in first try. i have to enable/disable labels multiple times to get the desired result, i believe there is some kind of refresh problem.

Also when i try to apply different font, it gives me unhandled exception "invalid parameter".

 

Link to comment
Share on other sites

Try the attached solution.

The back color change option seems to be one step behind. Also when you click on "change font" it will have no affect in first try and after that click on any of the buttons it will throw you an unhandled exception and chart area will have a big cross on it.

Link to comment
Share on other sites

You failed to mention a very important thing (that's why posting a sample program is so important): You are setting this from within a GetPointLabel event handler!

You can not do that. The GetPointLabel event is fired as the chart is being drawn. You cannot make any changes to the chart from within an event that occurs during painting.

You need to set this up outside of this event handler, for example in your FormLoad handler where you set your chart's data.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...