Search in sources :

Example 1 with CustomLabelFormatter

use of com.jjoe64.graphview.CustomLabelFormatter in project WordPress-Android by wordpress-mobile.

the class StatsBarGraph method setProperties.

private void setProperties() {
    GraphViewStyle gStyle = getGraphViewStyle();
    gStyle.setHorizontalLabelsIndexDependentColor(new HorizontalLabelsColor());
    gStyle.setHorizontalLabelsColor(getResources().getColor(R.color.grey_darken_30));
    gStyle.setVerticalLabelsColor(getResources().getColor(R.color.grey_darken_10));
    gStyle.setTextSize(getResources().getDimensionPixelSize(R.dimen.text_sz_extra_small));
    gStyle.setGridXColor(Color.TRANSPARENT);
    gStyle.setGridYColor(getResources().getColor(R.color.grey_lighten_30));
    gStyle.setNumVerticalLabels(3);
    setCustomLabelFormatter(new CustomLabelFormatter() {

        private NumberFormat numberFormatter;

        @Override
        public String formatLabel(double value, boolean isValueX) {
            if (isValueX) {
                return null;
            }
            if (numberFormatter == null) {
                numberFormatter = NumberFormat.getNumberInstance();
                numberFormatter.setMaximumFractionDigits(0);
            }
            return numberFormatter.format(value);
        }
    });
}
Also used : GraphViewStyle(com.jjoe64.graphview.GraphViewStyle) CustomLabelFormatter(com.jjoe64.graphview.CustomLabelFormatter) NumberFormat(java.text.NumberFormat)

Aggregations

CustomLabelFormatter (com.jjoe64.graphview.CustomLabelFormatter)1 GraphViewStyle (com.jjoe64.graphview.GraphViewStyle)1 NumberFormat (java.text.NumberFormat)1