Skip to content

Danver97/MaterialHistogram

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 

Repository files navigation

MaterialHistogram

A great customizable histogram baseline for Android apps.

Installation

Download the zip, unzip it and import it in Android Studio. Then add the following lines to your app's grandle file:

compile project(':materialhistogram')

Usage

Define 'app' namespace on root view in your layout:

xmlns:app="http://schemas.android.com/apk/res-auto"

Include this material histogram library in your layout:

<com.danver.materialhistogram.MaterialHistogram
                            android:layout_width="dimension"
                            android:layout_height="dimension"
                            app:bars_color="color"
                            app:bars_padding="dimension"
                            app:bars_thickness="dimension"
                            app:bars_thickness_adaptive="boolean"
                            app:bars_corner="dimension"
                            app:target_value="float"
                            app:target_color="color"
                            app:axis_show="boolean"
                            app:chart_alignment="center|left|right"
                            app:chart_show_scale="boolean"
                            app:chart_show_average="boolean"
                            app:average_color="color"/>

materialhistogram

The app:bars_thickness_adaptive="boolean" attribute set on "true" make the app:bars_thickness="dimension" attribute to be ignored and the chart will automatically adapt the bars thickness in order to fit the specified android:layout_width="dimension" dimension.

materialhistogram-2

Actually, the related method is supposed to adjust both thickness and padding in order to have a thickness:padding ratio of 8:1 (because it looks better). In the examble above only thickness have been changed.

app:target_value="float" attribute represent, while showing some stats, a value compared to which the values displayed have to stay below or above. app:chart_show_average="boolean" allows to display a line representing the average of the values displayed on the histogram.

materialhistogram-3

Public fields and methods

  //Public fields
  
  public final static int CHART_ALIGNEMT_CENTER = 0;
  public final static int CHART_ALIGNEMT_LEFT = 1;
  public final static int CHART_ALIGNEMT_RIGHT = 2;
  
  //Setters
  
  public void setValues(int array[]);
  public void setValues(float array[]);
  public void setValues(ArrayList<? extends Number> arrayList);
  
  public void setBarColor(@ColorInt int color);
  
  public void setBarCorner(float dp);
  public void setBarThickness(float dp);
  public void setBarPadding(float dp);
  public void setBarAdaptiveThickness(boolean status);
  
  public void setShowAverage(boolean status);
  public void setAverageColor(@ColorInt int color);
  
  public void setTargetValue(float value);
  public void setTargetValueColor(@ColorInt int color);
  
  public void setChartAlignment(int alignment);
  
  public void setHeight(int dpHeight);
  public void setWidth(int dpWidth);
  
  //Getters
  
  public int getBarColor();
  
  public ArrayList getValues();
  public float getMaxValue();
  
  public int getBarNumber();
  
  public int getChartAlignment();
  
  public boolean getBarAdaptiveThicknessStatus();
  public int getBarThicknessDp();
  public int getBarPaddingDp();
  public int getBarCornerDp();
  
  public float getAverageValue();
  public boolean getShowAverageStatus();
  public int getAverageColor();
  
  public float getTargetValue();
  public int getTargetValueColor();

Next

  • Add orientation settings

About

A great customizable histogram for Android apps.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages