import com.github.mikephil.charting.data.LineDataSet; //导入方法依赖的package包/类
private LineDataSet generateLineDataSet(List yVals, int color) {
// create a dataset and give it a type
LineDataSet set1 = new LineDataSet(yVals, "");
List colors = new ArrayList<>();
if (color == getResources().getColor(R.color.glucosio_pink)) {
for (Entry yVal : yVals) {
if (yVal.getVal() == (0)) {
colors.add(Color.TRANSPARENT);
} else {
colors.add(color);
}
}
set1.setCircleColors(colors);
} else {
set1.setCircleColor(color);
}
set1.setColor(color);
set1.setLineWidth(2f);
set1.setCircleSize(4f);
set1.setDrawCircleHole(true);
set1.disableDashedLine();
set1.setFillAlpha(255);
set1.setDrawFilled(true);
set1.setValueTextSize(0);
set1.setValueTextColor(Color.parseColor("#FFFFFF"));
set1.setFillDrawable(getResources().getDrawable(R.drawable.graph_gradient));
set1.setHighLightColor(getResources().getColor(R.color.glucosio_gray_light));
set1.setCubicIntensity(0.2f);
// TODO: Change this to true when a fix is available
// https://github.com/PhilJay/MPAndroidChart/issues/1541
set1.setDrawCubic(false);
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN_MR2) {
set1.setDrawFilled(false);
set1.setLineWidth(2f);
set1.setCircleSize(4f);
set1.setDrawCircleHole(true);
}
return set1;
}