Open UzBestDeveloper opened 4 years ago
`
//Here my code
yVals1 = new ArrayList<>();
yVals2 = new ArrayList<>();
yVals3 = new ArrayList<>();
for (int i = 0; i < amountByDateList.size(); i++) {
yVals1.add(new Entry(i, amountByDateList.get(i).getPurchases()));
}
for (int i = 0; i < amountByDateList.size(); i++) {
yVals2.add(new Entry(i, amountByDateList.get(i).getBonuses()));
}
for (int i = 0; i < amountByDateList.size(); i++) {
yVals3.add(new Entry(i, amountByDateList.get(i).getWriteOff()));
}
List<String> xValList = new LinkedList<>();
for (int i = 0; i < amountByDateList.size(); i++) {
xValList.add(amountByDateList.get(i).getChequeDate());
}
mLineChart.setOnChartValueSelectedListener(this);
mLineChart.setTouchEnabled(true);
mLineChart.setDragDecelerationFrictionCoef(0.9f);
mLineChart.setDragEnabled(true);
mLineChart.getDescription().setEnabled(false);
mLineChart.setScaleEnabled(true);
mLineChart.setDrawGridBackground(false);
mLineChart.setHighlightPerDragEnabled(false);
mLineChart.setPinchZoom(true);
mLineChart.setAutoScaleMinMaxEnabled(true);
mLineChart.setBackgroundColor(getResources().getColor(R.color.white));
mLineChart.animateY(1000);
mLineChart.setVisibleXRangeMinimum(1);
mLineChart.setLayerType(View.LAYER_TYPE_NONE, null);
mLineChart.getRenderer().getPaintRender().setShadowLayer(10, 0, 20, getColorWithAlpha(Color.GRAY, 0.1f));
mLineChart.notifyDataSetChanged();
mLineChart.invalidate();
XAxis xAxis = mLineChart.getXAxis();
xAxis.setTextSize(11f);
xAxis.setTextColor(getResources().getColor(R.color.line_chart_color));
xAxis.setDrawGridLines(false);
xAxis.setDrawAxisLine(false);
xAxis.setGranularity(1);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setValueFormatter(new ClaimsXAxisValueFormatter(xValList));
xAxis.setLabelRotationAngle(-70);
YAxis leftAxis = mLineChart.getAxisLeft();
leftAxis.setTextColor(ColorTemplate.getHoloBlue());
leftAxis.setAxisMinimum(0f);
leftAxis.setDrawGridLines(false);
leftAxis.setGranularityEnabled(true);
leftAxis.setEnabled(false);
YAxis rightAxis = mLineChart.getAxisRight();
rightAxis.setTextColor(Color.RED);
rightAxis.setAxisMinimum(0);
rightAxis.setDrawGridLines(false);
rightAxis.setEnabled(false);
rightAxis.setDrawZeroLine(false);
rightAxis.setGranularityEnabled(false);
mLineChart.getLegend().setEnabled(false);
LineDataSet set1, set2, set3;
set1 = new LineDataSet(yVals1, "");
set1.setAxisDependency(YAxis.AxisDependency.LEFT);
set1.setColor(getResources().getColor(R.color.shopping_amount_color));
set1.setCircleColor(getResources().getColor(R.color.shopping_amount_color));
set1.setLineWidth(4f);
set1.setCircleRadius(1f);
set1.setFillAlpha(60);
set1.setFillColor(getResources().getColor(R.color.shopping_amount_color));
set1.setHighLightColor(getResources().getColor(R.color.shopping_amount_color));
set1.setDrawCircleHole(false);
set2 = new LineDataSet(yVals2, "");
set2.setAxisDependency(YAxis.AxisDependency.RIGHT);
set2.setColor(getResources().getColor(R.color.filled_up_rewards_color));
set2.setLineWidth(4f);
set2.setCircleRadius(1f);
set2.setFillAlpha(60);
set2.setFillColor(getResources().getColor(R.color.filled_up_rewards_color));
set2.setDrawCircleHole(false);
set2.setCircleColor(getColorWithAlpha(getResources().getColor(R.color.filled_up_rewards_color), 0.4f));
set2.setHighLightColor(getResources().getColor(R.color.filled_up_rewards_color));
set3 = new LineDataSet(yVals3, "");
set3.setAxisDependency(YAxis.AxisDependency.RIGHT);
set3.setColor(getResources().getColor(R.color.write_off_rewards_color));
set3.setLineWidth(4f);
set3.setCircleRadius(1f);
set3.setFillAlpha(60);
set3.setFillColor(getResources().getColor(R.color.write_off_rewards_color));
set3.setDrawCircleHole(false);
set3.setCircleColor(getColorWithAlpha(getResources().getColor(R.color.write_off_rewards_color), 0.4f));
set3.setHighLightColor(getResources().getColor(R.color.write_off_rewards_color));
set1.setMode(LineDataSet.Mode.CUBIC_BEZIER);
set2.setMode(LineDataSet.Mode.CUBIC_BEZIER);
set3.setMode(LineDataSet.Mode.CUBIC_BEZIER);
LineData data = new LineData(set3, set2, set1);
data.setValueTextColor(getResources().getColor(R.color.transparent));
mLineChart.clear();
if (null != mLineChart.getLineData())
mLineChart.getLineData().clearValues();
mLineChart.setData(data);
mLineChart.getData().notifyDataChanged();
mLineChart.notifyDataSetChanged();
`
I have 3 lines in line chart.But in first dataset has values : 20 000 000 big numbers.and second and third values has :300 000 , 70 000 such kind of numbers.When it is drawn other 2 lines are not nice visible.How to show three lines nicely.For ex: 3 lines should be drawn in the center of screen despite of values