This is a migrated thread and some comments may be shown as answers.

chart ui categoryAxis labels' background

1 Answer 50 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Arsen
Top achievements
Rank 1
Arsen asked on 30 Sep 2014, 07:30 AM
Hello,

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

thanks

1 Answer, 1 is accepted

Sort by
0
Victor
Telerik team
answered on 03 Oct 2014, 08:48 AM
Hello Arsen,

Thanks for writing.
Please consider this example:
public class CustomCategoricalAxis extends CategoricalAxis {
    public CustomCategoricalAxis(Context context) {
        super(context);
    }
    @Override
    public void renderLabel(Canvas canvas, ChartNode dataPoint) {
        RadRect layoutSlot = this.getLayoutSlot(dataPoint, this.lastLayoutContext);
        Paint yellow = new Paint();
        yellow.setColor(Color.YELLOW);
        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.

Regards,
Victor
Telerik
 

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.

 
Tags
Chart
Asked by
Arsen
Top achievements
Rank 1
Answers by
Victor
Telerik team
Share this question
or