當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。