naamab Posted April 13, 2008 Report Share Posted April 13, 2008 Hi, I have graph with AxisY.LabelsFormat.Format = AxisFormat.Time. The values can be positive and negative, and I want to use "mm:ss" format for positive values, and "-mm:ss" for negative values. currently (with "mm:ss" as LabelsFormat.CustomFormat) - the graph ignores the fact that the values are negative... How can I do that? Quote Link to comment Share on other sites More sharing options...
PDyer Posted April 15, 2008 Report Share Posted April 15, 2008 Negative dates do not have too much sense. Although I tried Chart1.AxisX.LabelsFormat.CustomFormat = "h:mm:ss" but there is no way to apply a conditional based on the value seems you have to handle the data before pass it to Chart FX. Perhaps you could convert the - date values to the previous day. I suggest you to open the resource center and search for "custom format" perhaps that give you another ideas. Quote Link to comment Share on other sites More sharing options...
naamab Posted April 16, 2008 Author Report Share Posted April 16, 2008 I don't want to present dates, I want to present time. The meaning of negative time like -01:00 will be: 'a minute ago' or 'one minute less then...', so I think it does make sense.The values I Quote Link to comment Share on other sites More sharing options...
Frank Posted April 16, 2008 Report Share Posted April 16, 2008 The problem here is that Time values include a date as well, in other words, there is way to pass "1:00 pm" to the chart you need to pass a date too so that 1:00 pm of today is different than 1:00 pm of tomorrow. This is regardless of the labels format. Even thoug you are displaying only the time it doesn't mean that there is not date associated with it. So the datatype in the chart is DateTime regardless o your label format which is used just for displaying. As such, there is no concept of a negative datetime since there is no zero (there is but it doesn't mean anything). It looks that what you are looking for is a TimeSpan datatype. We do not support TimeSpans in this version althought this is something we will have in the next version. What you can do now is "trick" the chart. Here is how you can do it: 1) You will convert your timespan values to integers. You can use the TotalMilliseconds for this. These will end up being possitive and negative numbers, 2) You will leave the X-Axis as numeric. 3) Capture the GetAxisLabel event and convert the label about to be displayed (numeric value. eg. 1000,-1500,etc.) back to a TimeSpan and set the label to be this string. Quote Link to comment Share on other sites More sharing options...
naamab Posted April 17, 2008 Author Report Share Posted April 17, 2008 This is what I needed! Thank you very much. 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.