-
Notifications
You must be signed in to change notification settings - Fork 0
(4) Bar Chart
Bar Chart is represented by BarChartView class and extends ChartView. Before you go through it I would recommend you to take a look at the Chart section where the generic chart implementation is described. Everything which is stated in this page applies to HorizontalBarChartView as well, even when not explicitly mentioned.
Implement this chart by defining it in your XML layout:
<com.db.chart.view.BarChartView xmlns:chart="http://schemas.android.com/apk/res-auto" android:id="@+id/barchart" android:layout_width="match_parent" android:layout_height="100dp"/>
Customization described here refers to BarChartView and HorizontalBarChartView specific configuration. General chart customization can be found in Chart.
-
Data spacing
chart:chart_barSpacing="dp"chart.setBarSpacing(dimen)chart:chart_setSpacing="dp"chart.setSetSpacing(dimen) -
Bars background (Not Fill)
chart.setBarBackgroundColor(color)chart.setRoundCorners(dimen)
BarChartView makes use of BarSet, which extends ChartSet, to manage the data to be displayed. BarSet keeps a list of objects of type Bar. Customization can be done at both, BarSet or Bar, levels.
-
Add entries
dataset.addBar(new Bar(string, float))dataset.addBar(string, float)dataset.addBars(string[], float[])
-
Color - Set color to the whole set or only to a specific bar.
dataset.setColor(color)bar.setColor(color)dataset.setGradientColor(colors, positions)