Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
Evgeniy edited this page Nov 9, 2015 · 5 revisions

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

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)

Dataset

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[])

Customization

  • Color - Set color to the whole set or only to a specific bar.

    dataset.setColor(color)

    bar.setColor(color)

    dataset.setGradientColor(colors, positions)

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /