Heisenberg
Heisenberg

Reputation: 5668

Make line chart take full width of parent using mpchart?

I've customized a line chart which looks just about what I wanted. But I'm unable to remove the padding from it left after switching off the axis lables and lines. Setting

chart.setViewPortOffsets(0f, 0f, 0f, 0f);

has helped but it did not remove the padding completely. In short what I want is:

enter image description here

Upvotes: 2

Views: 1160

Answers (2)

Heisenberg
Heisenberg

Reputation: 5668

I was using Android Studio's generated activity which had padding in the outermost layout.

android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"

It worked perfectly after removing parent padding. It might be a silly question for experienced developers, but for a newbie like me it took a while to figure it out.

Upvotes: 1

Dhruv
Dhruv

Reputation: 1799

Try to add:

YAxis leftAxis = chart.getAxisLeft();    
leftAxis.setAxisMinValue(0f);
YAxis rightAxis = chart.getAxisRight();
rightAxis.setAxisMinValue(0f);

Hope, this answer will solve you problem.

Upvotes: 0

Related Questions