matdev
matdev

Reputation: 4283

How to center domain label below bar in a bar chart?

Currently, each bar's domain label appears below the left hand side of each bar, as pictured here:

enter image description here

Is there a way to position labels below each bar's center ?

Upvotes: 1

Views: 194

Answers (2)

Nick
Nick

Reputation: 8317

This should do the trick:

XYGraphWidget.LineLabelStyle style = plot.getGraph().getLineLabelStyle(XYGraphWidget.Edge.BOTTOM);
style.getPaint().setTextAlign(Paint.Align.CENTER);

Upvotes: 1

Sivakumar S
Sivakumar S

Reputation: 681

I believe you are doing that on canvas.

  1. You already know the width of the bar.
  2. Measure the text size (width) to be displayed using Measuring text height to be drawn on Canvas ( Android )
  3. (barWidth/2 - textWidth/2) + barLeft should do, i think.

Upvotes: 0

Related Questions