当前位置: 首页>>代码示例>>Java>>正文


Java BarDataSet.setValueTextSize方法代码示例

本文整理汇总了Java中com.github.mikephil.charting.data.BarDataSet.setValueTextSize方法的典型用法代码示例。如果您正苦于以下问题:Java BarDataSet.setValueTextSize方法的具体用法?Java BarDataSet.setValueTextSize怎么用?Java BarDataSet.setValueTextSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.github.mikephil.charting.data.BarDataSet的用法示例。


在下文中一共展示了BarDataSet.setValueTextSize方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateBarData

import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
/**
 * 柱形图数据
 */
private BarData generateBarData() {
    BarData barData = new BarData();
    ArrayList<BarEntry> entries1 = new ArrayList<>();
    for (int index = 0; index < items.size(); index++) {
        entries1.add(new BarEntry(index + 1f, (float) items.get(index).main_data.getData()));
    }
    BarDataSet barDataSet = new BarDataSet(entries1, "当前数据");
    barDataSet.setValues(entries1);
    barDataSet.setDrawValues(false);//是否在线上显示值
    barDataSet.setColor(Color.rgb(230, 230, 230));
    barDataSet.setHighLightColor(Color.parseColor(items.get(dateSelected).state.getColor()));
    barDataSet.setValueTextColor(Color.rgb(60, 220, 78));
    barDataSet.setValueTextSize(10f);
    barDataSet.setAxisDependency(YAxis.AxisDependency.LEFT);
    float barWidth = 0.45f;
    barData.addDataSet(barDataSet);
    barData.setBarWidth(barWidth);
    return barData;
}
 
开发者ID:jay16,项目名称:shengyiplus-android,代码行数:23,代码来源:HomeTricsActivity.java

示例2: getBarData

import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private BarData getBarData(FinishedExercise finishedExercise) {
    List<FinishedSet> sets = finishedExercise.getSets();
    List<BarEntry> entries = new ArrayList<>();
    for (int i = 0; i < sets.size(); i++) {
        int reps = sets.get(i).getReps();
        int maxReps = sets.get(i).getMaxReps();
        int openReps = maxReps - reps;
        entries.add(new BarEntry(i, new float[]{reps, openReps}));
    }
    BarDataSet set = new BarDataSet(entries, "sets");
    int textColor = activity.getResources().getColor(R.color.primaryTextColor);
    set.setValueTextColor(textColor);
    set.setValueTextSize(12);
    set.setColors(getColors());
    BarData barData = new BarData(set);
    barData.setValueFormatter(new HideZeroValueFormatter());
    return barData;
}
 
开发者ID:avalax,项目名称:FitBuddy,代码行数:19,代码来源:FinishedExerciseAdapter.java

示例3: generateBarData

import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private BarData generateBarData() {

        ArrayList<BarEntry> entries1 = new ArrayList<BarEntry>();
        ArrayList<BarEntry> entries2 = new ArrayList<BarEntry>();

        for (int index = 0; index < itemcount; index++) {
            entries1.add(new BarEntry(0, getRandom(25, 25)));

            // stacked
            entries2.add(new BarEntry(0, new float[]{getRandom(13, 12), getRandom(13, 12)}));
        }

        BarDataSet set1 = new BarDataSet(entries1, "Bar 1");
        set1.setColor(Color.rgb(60, 220, 78));
        set1.setValueTextColor(Color.rgb(60, 220, 78));
        set1.setValueTextSize(10f);
        set1.setAxisDependency(YAxis.AxisDependency.LEFT);

        BarDataSet set2 = new BarDataSet(entries2, "");
        set2.setStackLabels(new String[]{"Stack 1", "Stack 2"});
        set2.setColors(new int[]{Color.rgb(61, 165, 255), Color.rgb(23, 197, 255)});
        set2.setValueTextColor(Color.rgb(61, 165, 255));
        set2.setValueTextSize(10f);
        set2.setAxisDependency(YAxis.AxisDependency.LEFT);

        float groupSpace = 0.06f;
        float barSpace = 0.02f; // x2 dataset
        float barWidth = 0.45f; // x2 dataset
        // (0.45 + 0.02) * 2 + 0.06 = 1.00 -> interval per "group"

        BarData d = new BarData(set1, set2);
        d.setBarWidth(barWidth);

        // make this BarData object grouped
        d.groupBars(0, groupSpace, barSpace); // start at x = 0

        return d;
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:39,代码来源:CombinedChartActivity.java

示例4: showBarChart

import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
/**
 * 展示柱状图(一条)
 *
 * @param xAxisValues
 * @param yAxisValues
 * @param labels      x轴下标
 */
public void showBarChart(List<Integer> xAxisValues, List<Integer> yAxisValues
        , List<String> labels) {
    initLineChart();
    ArrayList<BarEntry> entries = new ArrayList<>();
    for (int i = 0; i < xAxisValues.size(); i++) {
        entries.add(new BarEntry(xAxisValues.get(i), yAxisValues.get(i)));
    }
    // 每一个BarDataSet代表一类柱状图
    BarDataSet barDataSet = new BarDataSet(entries, "");

    MyXFormatter myXFormatter = new MyXFormatter(labels);
    xAxis.setValueFormatter(myXFormatter);

    barDataSet.setColors(ColorTemplate.MATERIAL_COLORS);
    barDataSet.setValueTextSize(9f);
    barDataSet.setFormLineWidth(1f);
    barDataSet.setFormSize(15.f);
    ArrayList<IBarDataSet> dataSets = new ArrayList<>();
    dataSets.add(barDataSet);
    BarData data = new BarData(dataSets);
    //设置X轴的刻度数
    xAxis.setLabelCount(xAxisValues.size() - 1, false);
    if (xAxisValues.size() - 1 > 7) {
        mBarChart.getXAxis().setLabelRotationAngle(90);//设置X轴文字顺时针旋转角度
    }
    mBarChart.setData(data);
}
 
开发者ID:liuyongfeng90,项目名称:JKCloud,代码行数:35,代码来源:BarChartManager.java

示例5: generateBarData

import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private BarData generateBarData(float index, float dis) {

        ArrayList<BarEntry> entries = new ArrayList<>();


        for (int i = 0; i < count; i++) {
            float a = new Random().nextInt(40) / 100f + 0.1f;
            float b = new Random().nextInt(40) / 100f + 0.1f;
            entries.add(new BarEntry(index, new float[]{a, b, 1 - a - b}));
            index += dis;
        }

        BarDataSet set = new BarDataSet(entries, "hello");
        set.setStackLabels(new String[]{"1", "2"});
        set.setColors(new int[]{Color.rgb(154, 209, 253), Color.rgb(254, 206, 121), Color.rgb(253, 136, 95)});
        set.setValueTextColor(Color.rgb(61, 165, 255));
        set.setValueTextSize(10f);
        set.setAxisDependency(YAxis.AxisDependency.LEFT);


        ArrayList<IBarDataSet> threebardata = new ArrayList<>();

        BarData d = new BarData(threebardata);
        d.setBarWidth(0.4f);
        d.setDrawValues(true);

        d.addDataSet(set);

        d.setValueFormatter(new IValueFormatter() {
            @Override
            public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
                return toPercentDecimalStr(value);
            }
        });
        return d;
    }
 
开发者ID:xsingHu,项目名称:xs-android-architecture,代码行数:37,代码来源:MainActivity.java

示例6: getBarData

import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private BarData getBarData(List<String> xVals, List<BarEntry> barEntries) {
    final BarDataSet dataSet = new BarDataSet(barEntries, getContext().getString(R.string.servings));

    dataSet.setColor(ContextCompat.getColor(getContext(), R.color.colorPrimary));
    dataSet.setValueTextColor(ContextCompat.getColor(getContext(), android.R.color.white));
    dataSet.setValueTextSize(14);

    // We just want the value as an integer
    dataSet.setValueFormatter(new BarChartValueFormatter());

    return new BarData(xVals, dataSet);
}
 
开发者ID:nutritionfactsorg,项目名称:daily-dozen-android,代码行数:13,代码来源:LoadServingsHistoryTask.java

示例7: initGradeDistributionChart

import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
/**
 * Initializes the grade distribution bar chart.
 *
 * @param gradeDistribution array with grade distributions
 */
private void initGradeDistributionChart(int[] gradeDistribution) {
    // y-values
    ArrayList<BarEntry> yValues = new ArrayList<>();
    for(int i = 0; i < gradeDistribution.length; i++) {
        yValues.add(new BarEntry(gradeDistribution[i], i));
    }

    // x-values
    ArrayList<String> xValues = new ArrayList<>();
    xValues.add("1,0 - 1,3");
    xValues.add("1,7 - 2,3");
    xValues.add("2,7 - 3,3");
    xValues.add("3,7 - 4,0");
    xValues.add("4,3 - 5,0");
    xValues.add("Andere");

    BarDataSet dataSet = new BarDataSet(yValues, "");
    dataSet.setValueTextSize(12);
    dataSet.setValueTextColor(ContextCompat.getColor(getContext(), R.color.text87));
    dataSet.setColor(ContextCompat.getColor(getContext(), R.color.colorAccent));
    dataSet.setDrawValues(true);
    dataSet.setBarSpacePercent(35);

    BarData barData = new BarData(xValues, dataSet);
    barData.setValueFormatter(new DecimalValueFormatter("#"));
    barData.setHighlightEnabled(false);
    chartGradeDistribution.setData(barData);

    setChartStyle(chartGradeDistribution);
    chartGradeDistribution.getXAxis().setLabelsToSkip(0);
    chartGradeDistribution.invalidate();
}
 
开发者ID:MyGrades,项目名称:mygrades-app,代码行数:38,代码来源:FragmentStatistics.java

示例8: populateUserStatsChart

import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
/**
 * Show user stats graph
 */
private void populateUserStatsChart() {
    final String[] userStatsChartXAxisLabel = getActivity().getResources().getStringArray(R.array.user_stats_x_axis_labels);
    final BarChart chart = getActivity().findViewById(R.id.user_stats_chart);
    chart.setTouchEnabled(false);
    XAxis xAxis = chart.getXAxis();
    xAxis.setGranularity(1);
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    xAxis.setValueFormatter(new IAxisValueFormatter() {
        /**
         * Format the value
         * @param value - value to fit to the axis
         * @param axis - the axis to fit to
         * @return Returns the formatted value
         */
        @Override
        public String getFormattedValue(float value, AxisBase axis) {
            int v = (int) value;
            return userStatsChartXAxisLabel[v];
        }
    });
    xAxis.setDrawGridLines(false);
    xAxis.setTextSize(11f);
    YAxis rightAxis = chart.getAxisRight();
    rightAxis.setEnabled(false);
    chart.getAxisLeft().setGranularity(1);
    chart.getDescription().setEnabled(false);

    if (mUser != null) {
        int[] colors = getActivity().getResources().getIntArray(R.array.user_stats_chart_colors);
        List<BarEntry> entries = new ArrayList<>();
        entries.add(new BarEntry(0f, mUser.getPlantsAdded()));
        entries.add(new BarEntry(1f, mUser.getPlantsDeleted()));
        entries.add(new BarEntry(2f, mUser.getWaterCount()));
        entries.add(new BarEntry(3f, mUser.getMeasureCount()));
        entries.add(new BarEntry(4f, mUser.getPhotoCount()));

        BarDataSet barDataSet = new BarDataSet(entries, "Plant Operations");
        barDataSet.setColors(ColorTemplate.createColors(colors));
        barDataSet.setValueTextSize(11f);

        BarData data = new BarData(barDataSet);
        data.setBarWidth(0.9f); // set custom bar width
        chart.setData(data);
        chart.invalidate(); // refresh
    }
}
 
开发者ID:iskandergaba,项目名称:Botanist,代码行数:50,代码来源:AccountController.java

示例9: onCreate

import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_age_distribution);

    setTitle("Age Distribution Austria");

    mChart = (HorizontalBarChart) findViewById(R.id.chart1);
    mChart.setOnChartValueSelectedListener(this);
    mChart.setDrawGridBackground(false);
    mChart.setDescription("");

    // scaling can now only be done on x- and y-axis separately
    mChart.setPinchZoom(false);

    mChart.setDrawBarShadow(false);
    mChart.setDrawValueAboveBar(true);
    
    mChart.getAxisLeft().setEnabled(false);
    mChart.getAxisRight().setAxisMaxValue(25f);
    mChart.getAxisRight().setAxisMinValue(-25f);
    mChart.getAxisRight().setDrawGridLines(false);
    mChart.getAxisRight().setDrawZeroLine(true);
    mChart.getAxisRight().setLabelCount(7, false);
    mChart.getAxisRight().setValueFormatter(new CustomFormatter());
    mChart.getAxisRight().setTextSize(9f);

    XAxis xAxis = mChart.getXAxis();
    xAxis.setPosition(XAxisPosition.BOTH_SIDED);
    xAxis.setDrawGridLines(false);
    xAxis.setDrawAxisLine(false);
    xAxis.setTextSize(9f);

    Legend l = mChart.getLegend();
    l.setPosition(LegendPosition.BELOW_CHART_RIGHT);
    l.setFormSize(8f);
    l.setFormToTextSpace(4f);
    l.setXEntrySpace(6f);

    // IMPORTANT: When using negative values in stacked bars, always make sure the negative values are in the array first
    ArrayList<BarEntry> yValues = new ArrayList<BarEntry>();
    yValues.add(new BarEntry(new float[]{ -10, 10 }, 0));
    yValues.add(new BarEntry(new float[]{ -12, 13 }, 1));
    yValues.add(new BarEntry(new float[]{ -15, 15 }, 2));
    yValues.add(new BarEntry(new float[]{ -17, 17 }, 3));
    yValues.add(new BarEntry(new float[]{ -19, 20 }, 4));
    yValues.add(new BarEntry(new float[]{ -19, 19 }, 5));
    yValues.add(new BarEntry(new float[]{ -16, 16 }, 6));
    yValues.add(new BarEntry(new float[]{ -13, 14 }, 7));
    yValues.add(new BarEntry(new float[]{ -10, 11 }, 8));
    yValues.add(new BarEntry(new float[]{ -5, 6 }, 9));
    yValues.add(new BarEntry(new float[]{ -1, 2 }, 10));

    BarDataSet set = new BarDataSet(yValues, "Age Distribution");
    set.setValueFormatter(new CustomFormatter());
    set.setValueTextSize(7f);
    set.setAxisDependency(YAxis.AxisDependency.RIGHT);
    set.setBarSpacePercent(40f);
    set.setColors(new int[] {Color.rgb(67,67,72), Color.rgb(124,181,236)});
    set.setStackLabels(new String[]{
            "Men", "Women"
    });

    String []xVals = new String[]{"0-10", "10-20", "20-30", "30-40", "40-50", "50-60", "60-70", "70-80", "80-90", "90-100", "100+"};

    BarData data = new BarData(xVals, set);
    mChart.setData(data);
    mChart.invalidate();
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:72,代码来源:StackedBarActivityNegative.java

示例10: generateBarData

import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private BarData generateBarData() {

        BarData d = new BarData();

        ArrayList<BarEntry> entries = new ArrayList<BarEntry>();

        for (int index = 0; index < itemcount; index++)
            entries.add(new BarEntry(getRandom(15, 30), index));

        BarDataSet set = new BarDataSet(entries, "Bar DataSet");
        set.setColor(Color.rgb(60, 220, 78));
        set.setValueTextColor(Color.rgb(60, 220, 78));
        set.setValueTextSize(10f);
        d.addDataSet(set);

        set.setAxisDependency(YAxis.AxisDependency.LEFT);

        return d;
    }
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:20,代码来源:CombinedChartActivity.java

示例11: showBarChart

import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
/**
 * Shows the bar chart with data taken from an OverviewEvent.
 *
 * @param overviewEvent - overview event
 */
private void showBarChart(OverviewEvent overviewEvent) {
    // general layout settings
    barChart.setPinchZoom(false);
    barChart.setDoubleTapToZoomEnabled(false);
    barChart.setScaleEnabled(false);
    barChart.setDescription("");
    barChart.setDrawBorders(false);
    barChart.setDrawBarShadow(false);
    barChart.setDrawGridBackground(false);
    barChart.getLegend().setEnabled(false);

    // set x-axis
    XAxis xAxis = barChart.getXAxis();
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    xAxis.setSpaceBetweenLabels(0);
    xAxis.setDrawAxisLine(false);
    xAxis.setDrawGridLines(false);
    xAxis.setTextColor(ContextCompat.getColor(this, R.color.text87));
    xAxis.setLabelsToSkip(0);

    // hide left y-axis
    barChart.getAxisLeft().setDrawGridLines(true);
    barChart.getAxisLeft().setDrawAxisLine(false);
    barChart.getAxisLeft().setDrawLabels(false);
    barChart.getAxisLeft().setGridColor(ContextCompat.getColor(this, R.color.divider));
    barChart.getAxisLeft().setLabelCount(6, true);

    // hide right y-axis
    barChart.getAxisRight().setDrawGridLines(false);
    barChart.getAxisRight().setDrawAxisLine(false);
    barChart.getAxisRight().setDrawLabels(false);

    Overview overview = overviewEvent.getOverview();

    // y-values
    ArrayList<BarEntry> yValues = new ArrayList<>();
    yValues.add(new BarEntry(overview.getSection1(), 0));
    yValues.add(new BarEntry(overview.getSection2(), 1));
    yValues.add(new BarEntry(overview.getSection3(), 2));
    yValues.add(new BarEntry(overview.getSection4(), 3));
    yValues.add(new BarEntry(overview.getSection5(), 4));

    // x-values
    ArrayList<String> xValues = new ArrayList<>();
    xValues.add("1,0 - 1,3");
    xValues.add("1,7 - 2,3");
    xValues.add("2,7 - 3,3");
    xValues.add("3,7 - 4,0");
    xValues.add("4,3 - 5,0");

    // set colors
    int[] BAR_CHART_COLORS = {COLOR_GRAY, COLOR_GRAY, COLOR_GRAY, COLOR_GRAY, COLOR_GRAY};
    if (overview.getUserSection() != null && overview.getUserSection() > 0) {
        BAR_CHART_COLORS[overview.getUserSection() - 1] = COLOR_HIGHLIGHT;
    }

    BarDataSet dataSet = new BarDataSet(yValues, "");
    dataSet.setValueTextSize(12);
    dataSet.setValueTextColor(ContextCompat.getColor(this, R.color.text87));
    dataSet.setColors(BAR_CHART_COLORS);
    dataSet.setDrawValues(true);
    dataSet.setBarSpacePercent(35);

    BarData barData = new BarData(xValues, dataSet);
    barData.setValueFormatter(new MyValueFormatter());
    barData.setHighlightEnabled(false);
    barChart.setData(barData);

    // add a nice and smooth animation
    barChart.animateY(1500);
    barChart.invalidate();
}
 
开发者ID:MyGrades,项目名称:mygrades-app,代码行数:78,代码来源:GradeDetailedActivity.java


注:本文中的com.github.mikephil.charting.data.BarDataSet.setValueTextSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。