chart ui categoryAxis labels' background

Thread is closed for posting
2 posts, 0 answers
  1. Arsen
    Arsen avatar
    15 posts
    Member since:
    Sep 2014

    Posted 30 Sep 2014 Link to this post


    Could you provide me way to make axis labels' background with width.
    Please view the file attached

  2. Victor
    Victor avatar
    1358 posts

    Posted 03 Oct 2014 Link to this post

    Hello Arsen,

    Thanks for writing.
    Please consider this example:
    public class CustomCategoricalAxis extends CategoricalAxis {
        public CustomCategoricalAxis(Context context) {
        public void renderLabel(Canvas canvas, ChartNode dataPoint) {
            RadRect layoutSlot = this.getLayoutSlot(dataPoint, this.lastLayoutContext);
            Paint yellow = new Paint();
            canvas.drawRect((float)layoutSlot.x - 20.0f, (float)layoutSlot.y, (float)layoutSlot.getRight() + 20.0f, (float)layoutSlot.getBottom(), yellow);
            super.renderLabel(canvas, dataPoint);

    You can use this custom axis instead of the base CategoricalAxis class.
    You can tweak the width with those magic numbers added to left and right. Also, there is bug in the label layout that causes them to stick a little bit above their layout slot. This will be fixed in our next release.

    Please write again if you have more questions.


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top