Jump to content
Software FX Community

Negative time value


naamab

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

 

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...