Jump to content
Software FX Community

Default value for AxisLabelAttributes.Format hides strings


Recommended Posts

I ran into this one today and thought it was worth mentioning:

 I have a chart whose X-Axis labels are string values.  "0 - 2", "2 - 4", "4 - 6".  Ignore the fact that they have numerics in them, the same issue would probably occur if I had "Strawberry", "Chocolate", and "Vanilla" as my values.

 Elsewhere in my code, I was doing a clone of the chart, and blindly copying values, such as 

  clone.AxisX.Labels.Format = AxisX.Labels.Format;

And I was doing this not even knowing or caring that I hadn't set format on my AxisX labels.

The unset default value was AxisFormat.None, which "Displays a Number without formatting." per API reference.  Prior to the set, the labels were displaying, after the set, the categorical labels were not displayed, probably because of the API note.

This seems like an inconsistency in terms of behavior.  If the labels were displaying before I set the format, why should they disappear after I set the format to the exact same value?  It looks like this would only apply to categorical string data.  Perhaps an AxisFormat.String could be added or the default behavior of AxisFormat.None could be changed?

Link to comment
Share on other sites

We will research this issue to try find a fix or workwaround. Both suggestions (AxisFormat.String or changing the AxisFormat.None default behavior sound feasible)

Most properties in ChartFX are Dependency Properties (to support Binding, Animation, etc.) this means that internally we know whether the property is set or not.

About cloning, we are working on export/import scenarios so hopefully you will be able to use that functionality in the future, for now you might want to explore using GetLocalValueEnumerator to loop through the "locally set" DPs ignoring readonly properties, you could then assign only the properties that have been truly set. Unfortunately there is a small percentage of properties that are not DPs, for those you might still have to assign the old fashion way.




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.

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