3

I have an <apex:chart> bar chart. It graphs Users (vertical axis) and assigned cases (horizontal). Therefore cases will only ever be an integer value.

However when rendered the auto-scaled axis for cases shows "0.3", "0.6", "0.9" etc. Clearly this is meaningless.

Is there a way to force the axis to use integer values?

Googling suggests that as the data get high enough the scale will eventually become integer. But I want to force it to integer regardless of the range in the data set.

2

You can set a steps attribute on an apex:axis as well as a minimum and maximum. So if in your controller you work out that the maximum value is say 3, you can set the maximum to that (and the minimum to zero) and set the number of steps to 2 so those 2 ticks appear at "1" and "2".

At some point (e.g. say 10 steps or more) the logic should revert back to the default algorithm so that algorithm can choose the right number of ticks to show.

1
  • Thanks. It's fudgey but I suppose it works. – powlo May 19 '14 at 10:38
1

If you want to force cases to tick by integer values, your first step is to get the maximum case count from your existing cases by user query. Store this in a public controller property called maxChartValue. Then, when defining the cases axis, include the following: minimum="0" maximum="{!maxChartValue}" steps="{!maxChartValue - 1}". That should make everything look good.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.