我正在使用 MPAndroidChart图书馆。我正在使用 MPAndroidChart 设置包含数据的多折线图。它工作得很好,但背景变白了。这就是我在做的
nhChart = new LineChart(getActivity());
nhChart.setDescription("Number of Hits View");
nhChart = (LineChart) hitsView.findViewById(R.id.line_chart_number_of_hits);
//int color = Color.parseColor("#80101010");
nhChart.setBackgroundColor(Color.parseColor("#80101010"));
//nhChart.setBackgroundResource(R.drawable.background_portrate);
//nhChart.setBackground(getResources().getDrawable(R.drawable.background_portrate));
nhChart.setStartAtZero(true);
nhChart.setDrawBorder(true);
nhChart.setNoDataTextDescription("No Data available for Charts");
nhChart.setDrawYValues(false);
nhChart.setDrawBorder(true);
nhChart.setScaleEnabled(true);
nhChart.setHighlightEnabled(false);
nhChart.setTouchEnabled(true);
//nhChart.setGridColor(Color.WHITE & 0x70FFFFFF);
//nhChart.setDragScaleEnabled(true);
nhChart.setPinchZoom(true);
setData(valueDate.size(),10000);
nhChart.animateX(2500);
Legend l = nhChart.getLegend();
l.setForm(LegendForm.CIRCLE);
l.setFormSize(6f);
l.setTextColor(Color.WHITE);
YLabels y = nhChart.getYLabels();
y.setTextColor(Color.WHITE);
y.setLabelCount(6);
XLabels x1 = nhChart.getXLabels();
x1.setCenterXLabelText(true);
x1.setPosition(XLabelPosition.BOTTOM);
x1.setTextColor(Color.WHITE);
我正在 fragment viewpager 中的 AsyncTask 的执行后方法中绘制折线图。显示图表的其他 fragment 显示相同的白色背景。我尝试为背景设置颜色,但没有任何效果。我也把它留空了,但它仍然显示白色背景。我还更新了最新的 Jar,但它不起作用。请帮忙。 这是图片的外观
最佳答案
你想要透明的:
chart.setDrawGridBackground(false);
这是透明条:
chart.setDrawBarShadow(false);
关于android - MPAndroidChart 白色背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27016811/