Hi,
I'm having trouble in dealing with long label names in XAxis for Column Chart. Is there any way we could set 'maxWidth' of css for those labels and ellipse(...) if it overflows.
Any help would be appreciated.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
One way to do this without using CSS would be to implement a custom formatter for your X-Axis Labels. Note that this specific code will simply truncate the label and not add any ellipsis to the end.
chart.getXAxis()
.setLabels(new XAxisLabels()
.setFormatter(new AxisLabelsFormatter() {
public String format(AxisLabelsData axisLabelsData) {
// If the length of the label is greater than three, only show the first three characters.
return axisLabelsData.getValueAsString().length() > 3 ? axisLabelsData.getValueAsString().substring(0, 3) : axisLabelsData.getValueAsString();
}
})
)
;
If you want to add the ellipsis to show that the label has been shortened, you can change the return statement to something like:
Hi,
I'm having trouble in dealing with long label names in XAxis for Column Chart. Is there any way we could set 'maxWidth' of css for those labels and ellipse(...) if it overflows.
Any help would be appreciated.
One way to do this without using CSS would be to implement a custom formatter for your X-Axis Labels. Note that this specific code will simply truncate the label and not add any ellipsis to the end.
If you want to add the ellipsis to show that the label has been shortened, you can change the return statement to something like:
Last edit: Cory Skowronek 2013-08-13
Thanks alot for your response. that fix worked :)