Replacing numeric labels with text on linear axis

Oystein Bjorke 6 years ago 0
This discussion was imported from CodePlex

robjmberry wrote at 2014-02-05 13:16:


I would like to create a Bar chart that shows the progress of items through an established workflow.

For example: A made up order system has the following stages:

1) Credit check
2) Credit approved
3) Order dispatched
4) Order received
5) Order closed

What I’d like to do is have open orders listed vertically on a category axis and then bar the will show how far through the life-cycle the order is. Using a linear axis and the numerical value of the status this can be done easily. What I’d like is to replace the number on the axis with the stage, eg: 2 would be shown as Credit Approved

Is this possible ?


objo wrote at 2014-02-14 16:07:

try to create a custom Axis class and override the Axis.FormatValue method.
    public class MyLinearAxis : LinearAxis
        public override string FormatValue(double x)
            switch ((int)x)
                case 1:
                    return "Credit check";
                    // etc.
                    return string.Empty;
We could add a Func<double,string> property to the Axis class if this is a frequently needed feature. Something like this:
        public Func<double, string> LabelFormatter { get; set; }

        public virtual string FormatValue(double x)
            if (this.LabelFormatter != null)
                return this.LabelFormatter(x);

If you want this included in the library:
  1. create an issue
  2. create a fork
  3. add some unit tests
  4. implement
  5. submit including issue #
  6. make a pull request.