Skip to content

Commit 280cb5c

Browse files
committed
Improve example
1 parent 70e2c38 commit 280cb5c

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

MPChartExample/src/com/xxmassdeveloper/mpchartexample/CubicLineChartActivity.java

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import com.github.mikephil.charting.data.LineDataSet;
2222
import com.github.mikephil.charting.data.filter.Approximator;
2323
import com.github.mikephil.charting.data.filter.Approximator.ApproximatorType;
24+
import com.github.mikephil.charting.formatter.FillFormatter;
25+
import com.github.mikephil.charting.interfaces.LineDataProvider;
2426
import com.github.mikephil.charting.utils.ColorTemplate;
2527
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
2628

@@ -54,7 +56,8 @@ protected void onCreate(Bundle savedInstanceState) {
5456
mSeekBarX.setOnSeekBarChangeListener(this);
5557

5658
mChart = (LineChart) findViewById(R.id.chart1);
57-
// if enabled, the chart will always start at zero on the y-axis
59+
mChart.setViewPortOffsets(0, 20, 0, 0);
60+
mChart.setBackgroundColor(Color.rgb(104, 241, 175));
5861

5962
// no description text
6063
mChart.setDescription("");
@@ -77,13 +80,16 @@ protected void onCreate(Bundle savedInstanceState) {
7780
tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
7881

7982
XAxis x = mChart.getXAxis();
80-
x.setTypeface(tf);
8183
x.setEnabled(false);
8284

8385
YAxis y = mChart.getAxisLeft();
8486
y.setTypeface(tf);
85-
y.setLabelCount(5, false);
86-
y.setEnabled(false);
87+
y.setLabelCount(6, false);
88+
y.setStartAtZero(false);
89+
y.setTextColor(Color.WHITE);
90+
y.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
91+
y.setDrawGridLines(false);
92+
y.setAxisLineColor(Color.WHITE);
8793

8894
mChart.getAxisRight().setEnabled(false);
8995

@@ -270,12 +276,20 @@ private void setData(int count, float range) {
270276
set1.setCubicIntensity(0.2f);
271277
//set1.setDrawFilled(true);
272278
set1.setDrawCircles(false);
273-
set1.setLineWidth(2f);
274-
set1.setCircleSize(5f);
279+
set1.setLineWidth(1.8f);
280+
set1.setCircleSize(4f);
281+
set1.setCircleColor(Color.WHITE);
275282
set1.setHighLightColor(Color.rgb(244, 117, 117));
276-
set1.setColor(Color.rgb(104, 241, 175));
277-
set1.setFillColor(ColorTemplate.getHoloBlue());
283+
set1.setColor(Color.WHITE);
284+
set1.setFillColor(Color.WHITE);
285+
set1.setFillAlpha(100);
278286
set1.setDrawHorizontalHighlightIndicator(false);
287+
set1.setFillFormatter(new FillFormatter() {
288+
@Override
289+
public float getFillLinePosition(LineDataSet dataSet, LineDataProvider dataProvider) {
290+
return -10;
291+
}
292+
});
279293

280294
// create a data object with the datasets
281295
LineData data = new LineData(xVals, set1);

0 commit comments

Comments
 (0)