gpt4 book ai didi

java - mChart android颜色没有改变

转载 作者:行者123 更新时间:2023-12-04 07:39:59 24 4
gpt4 key购买 nike

我正在使用 Mphil 图表库,我已为折线图添加了此代码。
但它没有改变颜色,它显示默认的紫色,我的代码中是否有遗漏或错误

  LineDataSet set1;
if (mChart.getData() != null &&
mChart.getData().getDataSetCount() > 0) {
set1 = (LineDataSet) mChart.getData().getDataSetByIndex(0);
set1.setValues(values);
mChart.getData().notifyDataChanged();
mChart.notifyDataSetChanged();



} else {
set1 = new LineDataSet(values, "");
set1.setDrawIcons(false);
set1.setLabel("");
set1.setDrawValues(false);
set1.setHighLightColor(R.color.extracyan);
mChart.getLegend().setEnabled(false);
// set1.enableDashedLine(10f, 5f, 0f);
//set1.enableDashedHighlightLine(10f, 5f, 0f);
set1.setColor(R.color.extracyan);
set1.setCircleColor(R.color.extracyan);
set1.setLineWidth(3.5f);
set1.setDrawCircles(false);
set1.setCircleRadius(3.5f);
set1.setDrawCircleHole(false);
set1.setValueTextSize(0f);
set1.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER);
set1.setDrawFilled(false);
set1.setFormLineWidth(2.5f);
set1.setFormLineDashEffect(new DashPathEffect(new float[]{10f, 5f}, 0f));
set1.setFormSize(15.f);

/*if (Utils.getSDKInt() >= 18) {
Drawable drawable = ContextCompat.getDrawable(this, R.drawable.fade_blue);
set1.setFillDrawable(drawable);
} else {
set1.setFillColor(R.color.cyan);
}*/
ArrayList<ILineDataSet> dataSets = new ArrayList<>();
dataSets.add(set1);
LineData data = new LineData(dataSets);
mChart.setData(data);
progresslayout.setVisibility(View.GONE);
txtProgress.setVisibility(View.GONE);

}

我尝试添加 diff 颜色、diff 方法,但仍然相同,我尝试添加 2 个带有 diff 颜色的集合,但更改了,它们的颜色相同

最佳答案

您可以添加多个 颜色为您 charts这样:

  ArrayList<Integer> colors = new ArrayList<>();
for (int c : ColorTemplate.JOYFUL_COLORS)
colors.add(c);
for (int c : ColorTemplate.LIBERTY_COLORS)
colors.add(c);
for (int c : ColorTemplate.COLORFUL_COLORS)
colors.add(c);
for (int c : ColorTemplate.VORDIPLOM_COLORS)
colors.add(c);
for (int c : ColorTemplate.PASTEL_COLORS)
colors.add(c);
set1.setColors(colors);
将此代码替换为 set1.setColor(R.color.extracyan);那。

关于java - mChart android颜色没有改变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67537526/

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