Java Code Examples for com.github.mikephil.charting.utils.ColorTemplate

The following examples show how to use com.github.mikephil.charting.utils.ColorTemplate. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: memorize   Source File: StatisticActivity.java    License: MIT License 6 votes vote down vote up
private BarData generateDataBar(int cnt) {

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

        for (int i = 0; i < 12; i++) {
            entries.add(new BarEntry(i, (int) (Math.random() * 70) + 30));
        }

        BarDataSet d = new BarDataSet(entries, "New DataSet " + cnt);
        d.setColors(ColorTemplate.VORDIPLOM_COLORS);
        d.setHighLightAlpha(255);

        BarData cd = new BarData(d);
        cd.setBarWidth(0.9f);
        return cd;
    }
 
Example 2
Source Project: Stayfit   Source File: ScrollViewActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void setData(int count) {
    
    ArrayList<BarEntry> yVals = new ArrayList<BarEntry>();
    ArrayList<String> xVals = new ArrayList<String>();

    for (int i = 0; i < count; i++) {
        float val = (float) (Math.random() * count) + 15;
        yVals.add(new BarEntry((int) val, i));
        xVals.add((int) val + "");
    }

    BarDataSet set = new BarDataSet(yVals, "Data Set");
    set.setColors(ColorTemplate.VORDIPLOM_COLORS);
    set.setDrawValues(false);

    BarData data = new BarData(xVals, set);

    mChart.setData(data);
    mChart.invalidate();
    mChart.animateY(800);
}
 
Example 3
Source Project: Stayfit   Source File: CombinedChartActivity.java    License: Apache License 2.0 6 votes vote down vote up
protected BubbleData generateBubbleData() {

        BubbleData bd = new BubbleData();

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

        for (int index = 0; index < itemcount; index++) {
            float rnd = getRandom(20, 30);
            entries.add(new BubbleEntry(index, rnd, rnd));
        }

        BubbleDataSet set = new BubbleDataSet(entries, "Bubble DataSet");
        set.setColors(ColorTemplate.VORDIPLOM_COLORS);
        set.setValueTextSize(10f);
        set.setValueTextColor(Color.WHITE);
        set.setHighlightCircleWidth(1.5f);
        set.setDrawValues(true);
        bd.addDataSet(set);

        return bd;
    }
 
Example 4
Source Project: Stayfit   Source File: RealtimeLineChartActivity.java    License: Apache License 2.0 6 votes vote down vote up
private LineDataSet createSet() {

        LineDataSet set = new LineDataSet(null, "Dynamic Data");
        set.setAxisDependency(AxisDependency.LEFT);
        set.setColor(ColorTemplate.getHoloBlue());
        set.setCircleColor(Color.WHITE);
        set.setLineWidth(2f);
        set.setCircleRadius(4f);
        set.setFillAlpha(65);
        set.setFillColor(ColorTemplate.getHoloBlue());
        set.setHighLightColor(Color.rgb(244, 117, 117));
        set.setValueTextColor(Color.WHITE);
        set.setValueTextSize(9f);
        set.setDrawValues(false);
        return set;
    }
 
Example 5
Source Project: StockChart-MPAndroidChart   Source File: Legend.java    License: MIT License 6 votes vote down vote up
/**
 * Entries that will be appended to the end of the auto calculated
 * entries after calculating the legend.
 * (if the legend has already been calculated, you will need to call notifyDataSetChanged()
 * to let the changes take effect)
 */
public void setExtra(int[] colors, String[] labels) {

    List<LegendEntry> entries = new ArrayList<>();

    for (int i = 0; i < Math.min(colors.length, labels.length); i++) {
        final LegendEntry entry = new LegendEntry();
        entry.formColor = colors[i];
        entry.label = labels[i];

        if (entry.formColor == ColorTemplate.COLOR_SKIP ||
                entry.formColor == 0) {
            entry.form = LegendForm.NONE;
        } else if (entry.formColor == ColorTemplate.COLOR_NONE) {
            entry.form = LegendForm.EMPTY;
        }

        entries.add(entry);
    }

    mExtraEntries = entries.toArray(new LegendEntry[entries.size()]);
}
 
Example 6
Source Project: StockChart-MPAndroidChart   Source File: SimpleFragment.java    License: MIT License 6 votes vote down vote up
protected BarData generateBarData(int dataSets, float range, int count) {

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

        for(int i = 0; i < dataSets; i++) {

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

            for(int j = 0; j < count; j++) {
                entries.add(new BarEntry(j, (float) (Math.random() * range) + range / 4));
            }

            BarDataSet ds = new BarDataSet(entries, getLabel(i));
            ds.setColors(ColorTemplate.VORDIPLOM_COLORS);
            sets.add(ds);
        }

        BarData d = new BarData(sets);
        d.setValueTypeface(tf);
        return d;
    }
 
Example 7
Source Project: Stayfit   Source File: SimpleFragment.java    License: Apache License 2.0 6 votes vote down vote up
protected ScatterData generateScatterData(int dataSets, float range, int count) {
    
    ArrayList<IScatterDataSet> sets = new ArrayList<IScatterDataSet>();
    
    ScatterShape[] shapes = ScatterChart.getAllPossibleShapes();
    
    for(int i = 0; i < dataSets; i++) {
       
        ArrayList<Entry> entries = new ArrayList<Entry>();
        
        for(int j = 0; j < count; j++) {        
            entries.add(new Entry((float) (Math.random() * range) + range / 4, j));
        }
        
        ScatterDataSet ds = new ScatterDataSet(entries, getLabel(i));
        ds.setScatterShapeSize(12f);
        ds.setScatterShape(shapes[i % shapes.length]);
        ds.setColors(ColorTemplate.COLORFUL_COLORS);
        ds.setScatterShapeSize(9f);
        sets.add(ds);
    }
    
    ScatterData d = new ScatterData(ChartData.generateXVals(0, count), sets);
    d.setValueTypeface(tf);
    return d;
}
 
Example 8
Source Project: StockChart-MPAndroidChart   Source File: SimpleFragment.java    License: MIT License 6 votes vote down vote up
protected LineData generateLineData() {

        ArrayList<ILineDataSet> sets = new ArrayList<>();
        LineDataSet ds1 = new LineDataSet(FileUtils.loadEntriesFromAssets(context.getAssets(), "sine.txt"), "Sine function");
        LineDataSet ds2 = new LineDataSet(FileUtils.loadEntriesFromAssets(context.getAssets(), "cosine.txt"), "Cosine function");

        ds1.setLineWidth(2f);
        ds2.setLineWidth(2f);

        ds1.setDrawCircles(false);
        ds2.setDrawCircles(false);

        ds1.setColor(ColorTemplate.VORDIPLOM_COLORS[0]);
        ds2.setColor(ColorTemplate.VORDIPLOM_COLORS[1]);

        // load DataSets from files in assets folder
        sets.add(ds1);
        sets.add(ds2);

        LineData d = new LineData(sets);
        d.setValueTypeface(tf);
        return d;
    }
 
Example 9
Source Project: Stayfit   Source File: RealmDatabaseActivityPie.java    License: Apache License 2.0 6 votes vote down vote up
private void setData() {

        RealmResults<RealmDemoData> result = mRealm.allObjects(RealmDemoData.class);

        //RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "stackValues", "xIndex"); // normal entries
        RealmPieDataSet<RealmDemoData> set = new RealmPieDataSet<RealmDemoData>(result, "value", "xIndex"); // stacked entries
        set.setColors(ColorTemplate.VORDIPLOM_COLORS);
        set.setLabel("Example market share");
        set.setSliceSpace(2);

        // create a data object with the dataset list
        RealmPieData data = new RealmPieData(result, "xValue", set);
        styleData(data);
        data.setValueTextColor(Color.WHITE);
        data.setValueTextSize(12f);

        // set data
        mChart.setData(data);
        mChart.animateY(1400);
    }
 
Example 10
/**
 * generates a random ChartData object with just one DataSet
 *
 * @return Bar data
 */
private BarData generateData(int cnt) {

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

    for (int i = 0; i < 12; i++) {
        entries.add(new BarEntry(i, (float) (Math.random() * 70) + 30));
    }

    BarDataSet d = new BarDataSet(entries, "New DataSet " + cnt);
    d.setColors(ColorTemplate.VORDIPLOM_COLORS);
    d.setBarShadowColor(Color.rgb(203, 203, 203));

    ArrayList<IBarDataSet> sets = new ArrayList<>();
    sets.add(d);

    BarData cd = new BarData(sets);
    cd.setBarWidth(0.9f);
    return cd;
}
 
Example 11
Source Project: StockChart-MPAndroidChart   Source File: CombinedChartActivity.java    License: MIT License 6 votes vote down vote up
private BubbleData generateBubbleData() {

        BubbleData bd = new BubbleData();

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

        for (int index = 0; index < count; index++) {
            float y = getRandom(10, 105);
            float size = getRandom(100, 105);
            entries.add(new BubbleEntry(index + 0.5f, y, size));
        }

        BubbleDataSet set = new BubbleDataSet(entries, "Bubble DataSet");
        set.setColors(ColorTemplate.VORDIPLOM_COLORS);
        set.setValueTextSize(10f);
        set.setValueTextColor(Color.WHITE);
        set.setHighlightCircleWidth(1.5f);
        set.setDrawValues(true);
        bd.addDataSet(set);

        return bd;
    }
 
Example 12
Source Project: Stayfit   Source File: SimpleFragment.java    License: Apache License 2.0 6 votes vote down vote up
protected BarData generateBarData(int dataSets, float range, int count) {
        
        ArrayList<IBarDataSet> sets = new ArrayList<IBarDataSet>();
        
        for(int i = 0; i < dataSets; i++) {
           
            ArrayList<BarEntry> entries = new ArrayList<BarEntry>();
            
//            entries = FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "stacked_bars.txt");
            
            for(int j = 0; j < count; j++) {        
                entries.add(new BarEntry((float) (Math.random() * range) + range / 4, j));
            }
            
            BarDataSet ds = new BarDataSet(entries, getLabel(i));
            ds.setColors(ColorTemplate.VORDIPLOM_COLORS);
            sets.add(ds);
        }
        
        BarData d = new BarData(ChartData.generateXVals(0, count), sets);
        d.setValueTypeface(tf);
        return d;
    }
 
Example 13
/**
 * generates a random ChartData object with just one DataSet
 *
 * @return Pie data
 */
private PieData generateDataPie() {

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

    for (int i = 0; i < 4; i++) {
        entries.add(new PieEntry((float) ((Math.random() * 70) + 30), "Quarter " + (i+1)));
    }

    PieDataSet d = new PieDataSet(entries, "");

    // space between slices
    d.setSliceSpace(2f);
    d.setColors(ColorTemplate.VORDIPLOM_COLORS);

    return new PieData(d);
}
 
Example 14
Source Project: StockChart-MPAndroidChart   Source File: ScrollViewActivity.java    License: MIT License 6 votes vote down vote up
private void setData(int count) {

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

        for (int i = 0; i < count; i++) {
            float val = (float) (Math.random() * count) + 15;
            values.add(new BarEntry(i, (int) val));
        }

        BarDataSet set = new BarDataSet(values, "Data Set");
        set.setColors(ColorTemplate.VORDIPLOM_COLORS);
        set.setDrawValues(false);

        BarData data = new BarData(set);

        chart.setData(data);
        chart.invalidate();
        chart.animateY(800);
    }
 
Example 15
Source Project: NetKnight   Source File: LegendRenderer.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Draws the Legend-form at the given position with the color at the given
 * index.
 *
 * @param c     canvas to draw with
 * @param x     position
 * @param y     position
 * @param index the index of the color to use (in the colors array)
 */
protected void drawForm(Canvas c, float x, float y, int index, Legend legend) {

    if (legend.getColors()[index] == ColorTemplate.COLOR_SKIP)
        return;

    mLegendFormPaint.setColor(legend.getColors()[index]);

    float formsize = legend.getFormSize();
    float half = formsize / 2f;

    switch (legend.getForm()) {
        case CIRCLE:
            c.drawCircle(x + half, y, half, mLegendFormPaint);
            break;
        case SQUARE:
            c.drawRect(x, y - half, x + formsize, y + half, mLegendFormPaint);
            break;
        case LINE:
            c.drawLine(x, y, x + formsize, y, mLegendFormPaint);
            break;
    }
}
 
Example 16
Source Project: Ticket-Analysis   Source File: Legend.java    License: MIT License 6 votes vote down vote up
/**
 * Entries that will be appended to the end of the auto calculated
 *   entries after calculating the legend.
 * (if the legend has already been calculated, you will need to call notifyDataSetChanged()
 *   to let the changes take effect)
 */
public void setExtra(int[] colors, String[] labels) {

    List<LegendEntry> entries = new ArrayList<>();

    for (int i = 0; i < Math.min(colors.length, labels.length); i++) {
        final LegendEntry entry = new LegendEntry();
        entry.formColor = colors[i];
        entry.label = labels[i];

        if (entry.formColor == ColorTemplate.COLOR_SKIP ||
                entry.formColor == 0)
            entry.form = LegendForm.NONE;
        else if (entry.formColor == ColorTemplate.COLOR_NONE)
            entry.form = LegendForm.EMPTY;

        entries.add(entry);
    }

    mExtraEntries = entries.toArray(new LegendEntry[entries.size()]);
}
 
Example 17
Source Project: Stayfit   Source File: RealmDatabaseActivityBar.java    License: Apache License 2.0 6 votes vote down vote up
private void setData() {

        RealmResults<RealmDemoData> result = mRealm.allObjects(RealmDemoData.class);

        //RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "stackValues", "xIndex"); // normal entries
        RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "value", "xIndex"); // stacked entries
        set.setColors(new int[] {ColorTemplate.rgb("#FF5722"), ColorTemplate.rgb("#03A9F4")});
        set.setLabel("Realm BarDataSet");

        ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
        dataSets.add(set); // add the dataset

        // create a data object with the dataset list
        RealmBarData data = new RealmBarData(result, "xValue", dataSets);
        styleData(data);

        // set data
        mChart.setData(data);
        mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
    }
 
Example 18
Source Project: Stayfit   Source File: ListViewMultiChartActivity.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * generates a random ChartData object with just one DataSet
 * 
 * @return
 */
private BarData generateDataBar(int cnt) {

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

    for (int i = 0; i < 12; i++) {
        entries.add(new BarEntry((int) (Math.random() * 70) + 30, i));
    }

    BarDataSet d = new BarDataSet(entries, "New DataSet " + cnt);
    d.setBarSpacePercent(20f);
    d.setColors(ColorTemplate.VORDIPLOM_COLORS);
    d.setHighLightAlpha(255);
    
    BarData cd = new BarData(getMonths(), d);
    return cd;
}
 
Example 19
Source Project: Stayfit   Source File: RealmDatabaseActivityRadar.java    License: Apache License 2.0 6 votes vote down vote up
private void setData() {

        RealmResults<RealmDemoData> result = mRealm.allObjects(RealmDemoData.class);

        //RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "stackValues", "xIndex"); // normal entries
        RealmRadarDataSet<RealmDemoData> set = new RealmRadarDataSet<RealmDemoData>(result, "value", "xIndex"); // stacked entries
        set.setLabel("Realm RadarDataSet");
        set.setDrawFilled(true);
        set.setColor(ColorTemplate.rgb("#009688"));
        set.setFillColor(ColorTemplate.rgb("#009688"));
        set.setFillAlpha(130);
        set.setLineWidth(2f);

        ArrayList<IRadarDataSet> dataSets = new ArrayList<IRadarDataSet>();
        dataSets.add(set); // add the dataset

        // create a data object with the dataset list
        RadarData data = new RadarData(new String[] {"2013", "2014", "2015", "2016", "2017", "2018", "2019"}, dataSets);
        styleData(data);

        // set data
        mChart.setData(data);
        mChart.animateY(1400);
    }
 
Example 20
Source Project: Stayfit   Source File: ListViewBarChartActivity.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * generates a random ChartData object with just one DataSet
 * 
 * @return
 */
private BarData generateData(int cnt) {

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

    for (int i = 0; i < 12; i++) {
        entries.add(new BarEntry((int) (Math.random() * 70) + 30, i));
    }

    BarDataSet d = new BarDataSet(entries, "New DataSet " + cnt);    
    d.setBarSpacePercent(20f);
    d.setColors(ColorTemplate.VORDIPLOM_COLORS);
    d.setBarShadowColor(Color.rgb(203, 203, 203));
    
    ArrayList<IBarDataSet> sets = new ArrayList<IBarDataSet>();
    sets.add(d);
    
    BarData cd = new BarData(getMonths(), sets);
    return cd;
}
 
Example 21
Source Project: android-kline   Source File: Legend.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Entries that will be appended to the end of the auto calculated
 *   entries after calculating the legend.
 * (if the legend has already been calculated, you will need to call notifyDataSetChanged()
 *   to let the changes take effect)
 */
public void setExtra(int[] colors, String[] labels) {

    List<LegendEntry> entries = new ArrayList<>();

    for (int i = 0; i < Math.min(colors.length, labels.length); i++) {
        final LegendEntry entry = new LegendEntry();
        entry.formColor = colors[i];
        entry.label = labels[i];

        if (entry.formColor == ColorTemplate.COLOR_SKIP ||
                entry.formColor == 0)
            entry.form = LegendForm.NONE;
        else if (entry.formColor == ColorTemplate.COLOR_NONE)
            entry.form = LegendForm.EMPTY;

        entries.add(entry);
    }

    mExtraEntries = entries.toArray(new LegendEntry[entries.size()]);
}
 
Example 22
Source Project: iMoney   Source File: LegendRenderer.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Draws the Legend-form at the given position with the color at the given
 * index.
 *
 * @param c     canvas to draw with
 * @param x     position
 * @param y     position
 * @param index the index of the color to use (in the colors array)
 */
protected void drawForm(Canvas c, float x, float y, int index, Legend legend) {

    if (legend.getColors()[index] == ColorTemplate.COLOR_SKIP)
        return;

    mLegendFormPaint.setColor(legend.getColors()[index]);

    float formsize = legend.getFormSize();
    float half = formsize / 2f;

    switch (legend.getForm()) {
        case CIRCLE:
            c.drawCircle(x + half, y, half, mLegendFormPaint);
            break;
        case SQUARE:
            c.drawRect(x, y - half, x + formsize, y + half, mLegendFormPaint);
            break;
        case LINE:
            c.drawLine(x, y, x + formsize, y, mLegendFormPaint);
            break;
    }
}
 
Example 23
Source Project: iMoney   Source File: BarChartActivity.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 生成柱状图的数据
 */
private BarData generateDataBar() {

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

    for (int i = 0; i < 12; i++) {
        entries.add(new BarEntry((int) (Math.random() * 70) + 30, i));
    }

    BarDataSet d = new BarDataSet(entries, "New DataSet ");
    // 设置柱状图之间的间距
    d.setBarSpacePercent(20f);
    // 设置显示的柱状图的颜色
    d.setColors(ColorTemplate.VORDIPLOM_COLORS);
    // 设置高亮的透明度:当点击柱状图时显示的透明度
    d.setHighLightAlpha(255);

    BarData cd = new BarData(getMonths(), d);
    return cd;
}
 
Example 24
Source Project: Stayfit   Source File: SimpleFragment.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * generates less data (1 DataSet, 4 values)
 * @return
 */
protected PieData generatePieData() {
    
    int count = 4;
    
    ArrayList<Entry> entries1 = new ArrayList<Entry>();
    ArrayList<String> xVals = new ArrayList<String>();
    
    xVals.add("Quarter 1");
    xVals.add("Quarter 2");
    xVals.add("Quarter 3");
    xVals.add("Quarter 4");
    
    for(int i = 0; i < count; i++) {
        xVals.add("entry" + (i+1));

        entries1.add(new Entry((float) (Math.random() * 60) + 40, i));
    }
    
    PieDataSet ds1 = new PieDataSet(entries1, "Quarterly Revenues 2015");
    ds1.setColors(ColorTemplate.VORDIPLOM_COLORS);
    ds1.setSliceSpace(2f);
    ds1.setValueTextColor(Color.WHITE);
    ds1.setValueTextSize(12f);
    
    PieData d = new PieData(xVals, ds1);
    d.setValueTypeface(tf);

    return d;
}
 
Example 25
Source Project: memorize   Source File: StatisticActivity.java    License: MIT License 5 votes vote down vote up
private LineData generateDataLine(int cnt) {

        ArrayList<Entry> values1 = new ArrayList<>();

        for (int i = 0; i < 12; i++) {
            values1.add(new Entry(i, (int) (Math.random() * 65) + 40));
        }

        LineDataSet d1 = new LineDataSet(values1, "New DataSet " + cnt + ", (1)");
        d1.setLineWidth(2.5f);
        d1.setCircleRadius(4.5f);
        d1.setHighLightColor(Color.rgb(244, 117, 117));
        d1.setDrawValues(false);

        ArrayList<Entry> values2 = new ArrayList<>();

        for (int i = 0; i < 12; i++) {
            values2.add(new Entry(i, values1.get(i).getY() - 30));
        }

        LineDataSet d2 = new LineDataSet(values2, "New DataSet " + cnt + ", (2)");
        d2.setLineWidth(2.5f);
        d2.setCircleRadius(4.5f);
        d2.setHighLightColor(Color.rgb(244, 117, 117));
        d2.setColor(ColorTemplate.VORDIPLOM_COLORS[0]);
        d2.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[0]);
        d2.setDrawValues(false);

        ArrayList<ILineDataSet> sets = new ArrayList<>();
        sets.add(d1);
        sets.add(d2);

        return new LineData(sets);
    }
 
Example 26
Source Project: memorize   Source File: PieChartItem.java    License: MIT License 5 votes vote down vote up
private SpannableString generateCenterText() {
    SpannableString s = new SpannableString("Memorize\ncreated by\nTurtuvshin");
    s.setSpan(new RelativeSizeSpan(1.6f), 0, 14, 0);
    s.setSpan(new ForegroundColorSpan(ColorTemplate.VORDIPLOM_COLORS[0]), 0, 14, 0);
    s.setSpan(new RelativeSizeSpan(.9f), 14, 25, 0);
    s.setSpan(new ForegroundColorSpan(Color.GRAY), 14, 25, 0);
    s.setSpan(new RelativeSizeSpan(1.4f), 25, s.length(), 0);
    s.setSpan(new ForegroundColorSpan(ColorTemplate.getHoloBlue()), 25, s.length(), 0);
    return s;
}
 
Example 27
Source Project: dbclf   Source File: CameraActivity.java    License: Apache License 2.0 5 votes vote down vote up
private SpannableString generateCenterSpannableText() {
    final SpannableString s = new SpannableString("Center dog here\nkeep camera stable");
    s.setSpan(new RelativeSizeSpan(1.5f), 0, 15, 0);
    s.setSpan(new StyleSpan(Typeface.NORMAL), 15, s.length() - 15, 0);
    s.setSpan(new ForegroundColorSpan(ColorTemplate.getHoloBlue()), 0, 15, 0);

    s.setSpan(new StyleSpan(Typeface.ITALIC), s.length() - 18, s.length(), 0);
    s.setSpan(new ForegroundColorSpan(ColorTemplate.getHoloBlue()), s.length() - 18, s.length(), 0);
    return s;
}
 
Example 28
public BarData updateBarEntry() {
    ArrayList<BarEntry> mBarEntry = new ArrayList<>();
    for (int j = 0; j < 10; ++j) {
        mBarEntry.add(new BarEntry(j, mClassifier.getProbability(j)));
    }
    BarDataSet mBarDataSet = new BarDataSet(mBarEntry, "Projects");
    mBarDataSet.setColors(ColorTemplate.COLORFUL_COLORS);
    BarData mBardData = new BarData(mBarDataSet);
    return mBardData;
}
 
Example 29
Source Project: NetKnight   Source File: Legend.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * calculates the full width the fully drawn legend will use in pixels
 * 
 * @return
 */
public float getFullWidth(Paint labelpaint) {

    float width = 0f;

    for (int i = 0; i < mLabels.length; i++) {

        // grouped forms have null labels
        if (mLabels[i] != null) {

            // make a step to the left
            if (mColors[i] != ColorTemplate.COLOR_SKIP)
                width += mFormSize + mFormToTextSpace;

            width += Utils.calcTextWidth(labelpaint, mLabels[i]);

            if (i < mLabels.length - 1)
                width += mXEntrySpace;
        } else {
            width += mFormSize;
            if (i < mLabels.length - 1)
                width += mStackSpace;
        }
    }

    return width;
}
 
Example 30
Source Project: Stayfit   Source File: AnotherBarActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

    tvX.setText("" + (mSeekBarX.getProgress() + 1));
    tvY.setText("" + (mSeekBarY.getProgress()));

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

    for (int i = 0; i < mSeekBarX.getProgress() + 1; i++) {
        float mult = (mSeekBarY.getProgress() + 1);
        float val1 = (float) (Math.random() * mult) + mult / 3;
        yVals1.add(new BarEntry((int) val1, i));
    }

    ArrayList<String> xVals = new ArrayList<String>();
    for (int i = 0; i < mSeekBarX.getProgress() + 1; i++) {
        xVals.add((int) yVals1.get(i).getVal() + "");
    }

    BarDataSet set1 = new BarDataSet(yVals1, "Data Set");
    set1.setColors(ColorTemplate.VORDIPLOM_COLORS);
    set1.setDrawValues(false);

    ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
    dataSets.add(set1);

    BarData data = new BarData(xVals, dataSets);

    mChart.setData(data);
    mChart.invalidate();
}