An Android library that lets you create a BarChartView in a simple flexible and easy way .
dependencies {
implementation 'com.widget:barChart:2.1.2'
}
<dependency>
<groupId>com.widget</groupId>
<artifactId>barchart</artifactId>
<version>2+</version>
<type>pom</type>
</dependency>
<com.widget.chart.BarChartView
android:id="@+id/chartView"
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_margin="10dp"
<!--defines chart column background drawable-->
app:column_background="@drawable/bg_gradient_primary"
<!--or set chart column background color-->
app:column_color="@color/colorAccent"
<!--defines column label text color-->
app:column_label_color="@color/colorPrimaryDark"
<!--defines Space between columns-->
app:gap="5dp"
<!--shows x-coordinates-->
app:showLines="true"
<!--shows x-coordinates values-->
app:showPercentages="true"
<!--shows x-coordinates color (label and line)-->
app:x_line_color="@color/grey_300"/>
public BarChartModel(String label, int percent) {
this.label = label;
this.percent = percent;
}
public BarChartModel(int percent) {
this.percent = percent;
}
List<BarChartModel> columnsModelList = new ArrayList<>();
for (int i = 2; i <= 10; i++) {
columnsModelList.add(new BarChartModel("Label: "+i, i * 50));
rowsModelList.add(new BarChartModel("" + i * 50, i * 50));
}
chartView.drawChart(columnsModelList, 4);// 4 is the required x-coordinates number which will be drawn with equaled gap.
List<BarChartModel> rowsModelList = new ArrayList<>();
chartView.drawChart(columnsModelList, rowsModelList);// rowsModelList of type rowsModelList represents
chartView.drawChart(columnsModelList);// it's like with 0 x-coordinates number .
<!-- defines the width of label of horizontal rows -->
<dimen name="row_label_width">@dimen/_20sdp</dimen>
<!-- defines the width of label of columns -->
<dimen name="column_label_width">@dimen/_30sdp</dimen>
<!-- defines the height of label of horizontal rows -->
<dimen name="row_label_height">@dimen/_20sdp</dimen>
<!-- defines the height of of horizontal rows -->
<dimen name="row_line_height">2dp</dimen>
<!-- defines the text size of both column and row labels -->
<dimen name="barTitle">@dimen/_12ssp</dimen>
<!-- defines width of the column (chart) -->
<dimen name="column_width">@dimen/_15sdp</dimen>
This project is licensed under the MIT License - see the LICENSE.md file for details