PhilJay / MPAndroidChart

A powerful 🚀 Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, panning and animations.
Other
37.62k stars 9.02k forks source link

How to remove group separating line in bar chart multidataset #4634

Open blbhargav opened 5 years ago

blbhargav commented 5 years ago

Screenshot Hi. I want to remove those lines between groups. I tried every thing. But couldn't achieved it. Please give me a solution.

float barSpace = 0.03f;
float barWidth = 0.2f;
// (0.2 + 0.03) * 2 + 0.54 = 1.00 -> interval per "group"
ArrayList<BarEntry> credit = new ArrayList<>();
ArrayList<BarEntry> debit = new ArrayList<>();
//data added to credit and debit. Not pasted here.
//chart.setOnChartValueSelectedListener(activity);
chart.getDescription().setEnabled(false);
//        chart.setDrawBorders(true);
// scaling can now only be done on x- and y-axis separately
chart.setPinchZoom(false);
​
chart.setDrawBarShadow(false);
​
chart.setDrawGridBackground(false);
chart.setFitBars(false);
​
// create a custom MarkerView (extend MarkerView) and specify the layout
// to use for it
MyMarkerView mv = new MyMarkerView(activity, R.layout.custom_marker_view);
mv.setChartView(chart); // For bounds control
chart.setMarker(mv); // Set the marker to the chart
​
Legend l = chart.getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
l.setOrientation(Legend.LegendOrientation.VERTICAL);
l.setDrawInside(false);
//l.setTypeface(tfLight);
l.setYOffset(0f);
l.setXOffset(10f);
l.setYEntrySpace(0f);
l.setTextSize(8f);
​
XAxis xAxis = chart.getXAxis();
//xAxis.setTypeface(tfLight);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setGranularity(1f);
xAxis.setCenterAxisLabels(true);
xAxis.setValueFormatter(new IndexAxisValueFormatter(xAxisLabel));
xAxis.setDrawAxisLine(false);
​
chart.getAxisRight().setEnabled(false);
chart.getAxisLeft().setEnabled(false);
chart.getLegend().setEnabled(false);
chart.getAxisLeft().setDrawGridLines(false);
chart.getAxisRight().setDrawGridLines(false);
​
spentAmountTV.setText(todaySpent);
​
BarDataSet set1, set2;
if (chart.getData() != null && chart.getData().getDataSetCount() > 0) {
set1 = (BarDataSet) chart.getData().getDataSetByIndex(0);
set2 = (BarDataSet) chart.getData().getDataSetByIndex(1);
set1.setValues(credit);
set2.setValues(debit);
chart.getData().notifyDataChanged();
chart.notifyDataSetChanged();
}else {
set1 = new BarDataSet(credit, "Credit");
set1.setColor(ContextCompat.getColor(activity, R.color.lightGreen));
set2 = new BarDataSet(debit, "Debit");
set2.setColor(ContextCompat.getColor(activity, R.color.lightOrange));
​
BarData data = new BarData(set1, set2);
data.setValueFormatter(new LargeValueFormatter());
​data.setHighlightEnabled(false);
//data.setValueTypeface(tfLight);
chart.setData(data);
}
​
// specify the width each bar should have
chart.getBarData().setBarWidth(barWidth);
​
// restrict the x-axis range
//chart.getXAxis().setAxisMinimum(startYear);
​
// barData.getGroupWith(...) is a helper that calculates the width each group needs based on the provided parameters
chart.getXAxis().setAxisMaximum(0 + chart.getBarData().getGroupWidth(groupSpace, barSpace) * dailySummaryList.size());
chart.groupBars(0, groupSpace, barSpace);
chart.invalidate();
Bharatsingh-nickelfox commented 5 years ago

Same Issue. Please help.

Humayung commented 1 year ago

Honestly, I need your problem buddy, I need the separator line!

use this to remove the separator xAxis.setDrawGridLines(false)

chart