ubaid.tariq Posted July 7, 2008 Report Share Posted July 7, 2008 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 Quote Link to comment Share on other sites More sharing options...
ubaid.tariq Posted July 7, 2008 Author Report Share Posted July 7, 2008 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 Quote Link to comment Share on other sites More sharing options...
VekiPeki Posted July 7, 2008 Report Share Posted July 7, 2008 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. Quote Link to comment Share on other sites More sharing options...
ubaid.tariq Posted July 12, 2008 Author Report Share Posted July 12, 2008 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". Quote Link to comment Share on other sites More sharing options...
Frank Posted July 12, 2008 Report Share Posted July 12, 2008 Please post a sample program that reproduces the produces the problem. I tried the following code and worked perfectly: chart1.Points[1,5].PointLabels.BackColor = Color.Red; Quote Link to comment Share on other sites More sharing options...
ubaid.tariq Posted July 14, 2008 Author Report Share Posted July 14, 2008 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. Quote Link to comment Share on other sites More sharing options...
Frank Posted July 15, 2008 Report Share Posted July 15, 2008 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.