gpt4 book ai didi

android - 我可以在 MpAndroid 折线图中已经存在的圆孔上创建一个圆孔吗?

转载 作者:行者123 更新时间:2023-11-30 00:09:35 25 4
gpt4 key购买 nike

我能够使用 MPAndroid 图表库动态创建折线图,也能够创建折线图的阴影,但我无法在 MPAndroid 折线图中之前存在的圆孔上创建另一个圆孔?

代码

  void plotGraph(List<StatementListApi> statementListApis) {

HashMap<Integer, String> stringDoubleHashMap = new HashMap<>();
stringDoubleHashMap.put(0, "0");
stringDoubleHashMap.put(1, "0");
stringDoubleHashMap.put(2, "0");
stringDoubleHashMap.put(3, "0");
stringDoubleHashMap.put(4, "0");
stringDoubleHashMap.put(5, "0");
stringDoubleHashMap.put(6, "0");

for (int i = 0; i < statementListApis.size(); i++) {

Date date = new Date(Long.parseLong(statementListApis.get(i).getRecordedDate()));
System.out.println("date is" + date);

if (stringDoubleHashMap.containsKey(date.getDay())) {

Long aLong = statementListApis.get(i).getAmount() + Long.parseLong(stringDoubleHashMap.get(date.getDay()));

stringDoubleHashMap.put(date.getDay(), aLong + "");

} else {

stringDoubleHashMap.put(date.getDay(), statementListApis.get(i).getAmount() + "");
}
System.out.println("size of hashmap" + stringDoubleHashMap.size());
}


List<String> xVals = new ArrayList<String>(stringDoubleHashMap.values());

List<ILineDataSet> testDataSet1 = new ArrayList<>();

List<Entry> entries = new ArrayList<>();

ArrayList<String> Labels = new ArrayList<>();
Labels.add("SUN");
Labels.add("MON");
Labels.add("TUE");
Labels.add("WED");
Labels.add("THU");
Labels.add("FRI");
Labels.add("SAT");

for (int i = 0; i < xVals.size(); i++) {

entries.add(new Entry(i, Float.parseFloat(xVals.get(i))));
LineDataSet dataSet = new LineDataSet(entries, Labels.get(i));
testDataSet1.add(dataSet);
dataSet.setMode(LineDataSet.Mode.CUBIC_BEZIER);
dataSet.setColor(Color.RED);
dataSet.setCircleColor(Color.WHITE);
dataSet.setValueTextColor(Color.WHITE);

}


activityStatementBinding.lineChart.getXAxis().setTextColor(Color.WHITE);

// for shadow
activityStatementBinding.lineChart.setLayerType(View.LAYER_TYPE_HARDWARE, null);
activityStatementBinding.lineChart.getRenderer().getPaintRender().setShadowLayer(1, 10, 10, Color.BLACK);

IMarker marker = new CustomMarkerView(this, R.layout.activity_marker_view);
activityStatementBinding.lineChart.setMarker(marker);

MarkerImage markerImage = new MarkerImage(this, R.drawable.ic_back_24);
activityStatementBinding.lineChart.setMarker(markerImage);

//Animation
activityStatementBinding.lineChart.animateY(1700);

YAxis leftAxis = activityStatementBinding.lineChart.getAxisRight();
leftAxis.setEnabled(false);

//used to remove the horizontal x-axis lines in graph
YAxis rightAxis = activityStatementBinding.lineChart.getAxisLeft();
rightAxis.setEnabled(false);

activityStatementBinding.lineChart.getDescription().setEnabled(false);

activityStatementBinding.lineChart.getXAxis().setPosition(XAxis.XAxisPosition.BOTTOM);

// used for removing the labels with color
Legend legend = activityStatementBinding.lineChart.getLegend();
legend.setEnabled(false);

// activityStatementBinding.lineChart.moveViewTo(10, 0, RIGHT);

// activityStatementBinding.lineChart.setScrollContainer(true);
// activityStatementBinding.lineChart.setHorizontalScrollBarEnabled(true);


activityStatementBinding.lineChart.getXAxis().setValueFormatter(new IndexAxisValueFormatter(Labels));
activityStatementBinding.lineChart.setData(new LineData(testDataSet1));
activityStatementBinding.lineChart.notifyDataSetChanged();
activityStatementBinding.lineChart.invalidate();


}

获取图像 enter image description here

需要图片 enter image description here

How can i achieve the circle hole over the one that already exist?

最佳答案

您需要执行以下操作:

    lineDataSet.setCircleRadius(6);
float circleHoleRadius = circleRadius/2;
lineDataSet.setCircleHoleRadius(circleHoleRadius);
//lineDataSet.setCircleColor(Color.RED);
// Below line is to add transperancy to your color
lineDataSet.setCircleColor(Color.argb(12,284,55,32));
lineDataSet.setCircleColorHole(Color.WHITE);

您可以根据需要更改颜色和尺寸。快乐编码:)

关于android - 我可以在 MpAndroid 折线图中已经存在的圆孔上创建一个圆孔吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48364156/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com