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


Java ColorTemplate.createColors方法代码示例

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


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

示例1: createBarChart

import com.github.mikephil.charting.utils.ColorTemplate; //导入方法依赖的package包/类
/**
 * Creates the bar chart showing counters visually.
 */
private void createBarChart(BarChart barChart) {
    if (game != null) {
        ArrayList<BarEntry> entries = new ArrayList<>();
        ArrayList<BarEntry> entries2 = new ArrayList<>();
        // create simple bar chart

        // fill single rolls, 1..6
        int[] counts = sr.getCounts();
        for (int i = 0; i < counts.length; i++) {
            entries.add(new BarEntry(counts[i], i));
        }
        // fill double roll sums, 2..12
        counts = dr.getSumCount();
        for (int i = 0; i < counts.length; i++) {
            entries2.add(new BarEntry(counts[i], i + 1));
        }

        BarDataSet dataset = new BarDataSet(entries, "# of single rolls: " + sr.getTotal());
        BarDataSet dataset2 = new BarDataSet(entries2, "# of double rolls: " + dr.getTotal());

        ArrayList<String> labels = new ArrayList<>();
        // fill label for dice roll sums, 1..12
        for (int i = 0; i < 12; i++) {
            labels.add(Integer.toString(i + 1));
        }

        // explicit color resolving with util, see AboutActivity#demoBarChart
        List<Integer> colors = ColorTemplate.createColors(getResources(), new int[]{R.color.colorSingleRoll, R.color.colorDoubleRoll});
        //dataset.setColors(ColorTemplate.COLORFUL_COLORS);
        dataset.setColor(colors.get(0));
        dataset2.setColor(colors.get(1));

        BarData data = new BarData(labels, dataset);
        data.addDataSet(dataset2);
        barChart.setData(data);
    }
}
 
开发者ID:thilo20,项目名称:MachiKoroPad,代码行数:41,代码来源:StatsActivity.java

示例2: createBarChartStacked

import com.github.mikephil.charting.utils.ColorTemplate; //导入方法依赖的package包/类
/**
         * Creates the stacked bar chart showing counters visually.
         */
        private void createBarChartStacked(BarChart barChart) {
            if (game != null) {
                ArrayList<BarEntry> entries = new ArrayList<>();
                // create stacked bar chart

                // fill single rolls, 1..6
                // and  double roll sums, 2..12  into list of bar entries
                int[] counts1 = sr.getCounts();
                int[] counts2 = dr.getSumCount();
                // loop dice roll sums 1..12
                for (int i = 0; i < counts2.length + 1; i++) {
                    float[] vals = {0f, 0f};
                    if (i < counts1.length) {
                        vals[0] = (float) counts1[i];
                    }
                    if (i > 0) {
                        vals[1] = (float) counts2[i - 1];
                    }
                    entries.add(new BarEntry(vals, i));
                }

                BarDataSet dataset = new BarDataSet(entries, getString(R.string.stats_chart_legend));
                dataset.setStackLabels(new String[]{
                        getString(R.string.stats_chart_legend_single, sr.getTotal()),
                        getString(R.string.stats_chart_legend_double, dr.getTotal())
                });

                ArrayList<String> labels = new ArrayList<>();
                // fill label for dice roll sums, 1..12
                for (int i = 0; i < counts2.length + 1; i++) {
                    labels.add(Integer.toString(i + 1));
                }

                // explicit color resolving with util, see AboutActivity#demoBarChart
                List<Integer> colors = ColorTemplate.createColors(getResources(), new int[]{R.color.colorSingleRoll, R.color.colorDoubleRoll});
                //dataset.setColors(ColorTemplate.COLORFUL_COLORS);
                dataset.setColors(colors);

                BarData data = new BarData(labels, dataset);
                barChart.setData(data);

                dataset.setDrawValues(false);
                // try drawing data labels larger but with integer number - strange visual effects!
//                data.setValueTextSize(14);
//                data.setValueFormatter(new ValueFormatter() {
//                    @Override
//                    public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
//                        return String.format(Locale.US, "%1.0f", value);
//                    }
//                });
            }
        }
 
开发者ID:thilo20,项目名称:MachiKoroPad,代码行数:56,代码来源:StatsActivity.java

示例3: setColors

import com.github.mikephil.charting.utils.ColorTemplate; //导入方法依赖的package包/类
/**
 * Sets the colors that should be used fore this DataSet. Colors are reused
 * as soon as the number of Entries the DataSet represents is higher than
 * the size of the colors array. If you are using colors from the resources,
 * make sure that the colors are already prepared (by calling
 * getResources().getColor(...)) before adding them to the DataSet.
 *
 * @param colors
 */
public void setColors(int... colors) {
    this.mColors = ColorTemplate.createColors(colors);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:BaseDataSet.java

示例4: setCircleColors

import com.github.mikephil.charting.utils.ColorTemplate; //导入方法依赖的package包/类
/**
 * Sets the colors that should be used for the circles of this DataSet.
 * Colors are reused as soon as the number of Entries the DataSet represents
 * is higher than the size of the colors array. Make sure that the colors
 * are already prepared (by calling getResources().getColor(...)) before
 * adding them to the DataSet.
 *
 * @param colors
 */
public void setCircleColors(int... colors) {
    this.mCircleColors = ColorTemplate.createColors(colors);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:LineDataSet.java

示例5: setColors

import com.github.mikephil.charting.utils.ColorTemplate; //导入方法依赖的package包/类
/**
 * Sets the colors that should be used fore this DataSet. Colors are reused
 * as soon as the number of Entries the DataSet represents is higher than
 * the size of the colors array. If you are using colors from the resources,
 * make sure that the colors are already prepared (by calling
 * getResources().getColor(...)) before adding them to the DataSet.
 *
 * @param colors
 */
public void setColors(int[] colors) {
    this.mColors = ColorTemplate.createColors(colors);
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:13,代码来源:BaseDataSet.java

示例6: setCircleColors

import com.github.mikephil.charting.utils.ColorTemplate; //导入方法依赖的package包/类
/**
 * Sets the colors that should be used for the circles of this DataSet.
 * Colors are reused as soon as the number of Entries the DataSet represents
 * is higher than the size of the colors array. Make sure that the colors
 * are already prepared (by calling getResources().getColor(...)) before
 * adding them to the DataSet.
 *
 * @param colors
 */
public void setCircleColors(int[] colors) {
    this.mCircleColors = ColorTemplate.createColors(colors);
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:13,代码来源:RealmLineDataSet.java

示例7: setCircleColors

import com.github.mikephil.charting.utils.ColorTemplate; //导入方法依赖的package包/类
/**
 * Sets the colors that should be used for the circles of this DataSet.
 * Colors are reused as soon as the number of Entries the DataSet represents
 * is higher than the size of the colors array. Make sure that the colors
 * are already prepared (by calling getResources().getColor(...)) before
 * adding them to the DataSet.
 * 
 * @param colors
 */
public void setCircleColors(int[] colors) {
    this.mCircleColors = ColorTemplate.createColors(colors);
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:13,代码来源:LineDataSet.java


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