Jump to content
Software FX Community

Disabling date "bucketing" with AxisFormat.Date?


dtanabe
 Share

Recommended Posts

Is there any way to disable the custom formatting that goes on with date axes (collapsing into months, "Q1", "Q2", etc.)?

CustomFormat appears to be ignored once the bucketing starts to come into effect.

I tried handling Axis.GetLabel:
  • With AxisFormat.Date/DateTime/Time, I still get the undesired bucketing behavior, but worse, GetLabel gives me "June 30, 2009" for what should be the "June 2009" label (it's consistently the last day of the month), and there is no way to distinguish between these month-DateTime stand-ins and the real thing.
  • With AxisFormat.None, I can successfully format; however, the auto max/min/step values align the numbers as if they were doubles, which causes other issues (gaps before and after the max/min values, step values that don't align neatly on day boundaries).

--DKT

Link to comment
Share on other sites

You can control each buketing format separately using the following syntax

// <day format>;<month format>;<abbreviated year format>;<quarter format>;<year format>

A way to completely disable the bucketing would be for you to set up the AxisX step, note that this property is of type unit so you can pass a TimeSpan if your axis has dates, e.g.

chart1.AxisX.Labels.Format = ChartFX.WPF.AxisFormat.DateTime;chart1.AxisX.Labels.Angle = 90;chart1.AxisX.Step = new TimeSpan(365, 0, 0, 0);

We interpret some magic numbers, e.g. 365 days means a year, 30 days means a month. Note that using this approach might result in label overlap if the chart is resized to a size where the default format (or your own if you use CustomFormat) does not fit.

JuanC

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.

 Share

×
×
  • Create New...