Java 类com.github.mikephil.charting.data.BarData 实例源码

项目:GitHub    文件:BarHighlighter.java   
@Override
public Highlight getHighlight(float x, float y) {
    Highlight high = super.getHighlight(x, y);

    if(high == null) {
        return null;
    }

    MPPointD pos = getValsForTouch(x, y);

    BarData barData = mChart.getBarData();

    IBarDataSet set = barData.getDataSetByIndex(high.getDataSetIndex());
    if (set.isStacked()) {

        return getStackedHighlight(high,
                set,
                (float) pos.x,
                (float) pos.y);
    }

    MPPointD.recycleInstance(pos);

    return high;
}
项目:GitHub    文件:HorizontalBarHighlighter.java   
@Override
public Highlight getHighlight(float x, float y) {

    BarData barData = mChart.getBarData();

    MPPointD pos = getValsForTouch(y, x);

    Highlight high = getHighlightForX((float) pos.y, y, x);
    if (high == null)
        return null;

    IBarDataSet set = barData.getDataSetByIndex(high.getDataSetIndex());
    if (set.isStacked()) {

        return getStackedHighlight(high,
                set,
                (float) pos.y,
                (float) pos.x);
    }

    MPPointD.recycleInstance(pos);

    return high;
}
项目:GitHub    文件:SimpleFragment.java   
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(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;
    }
项目:GitHub    文件:ListViewBarChartActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_listview_chart);

    ListView lv = (ListView) findViewById(R.id.listView1);

    ArrayList<BarData> list = new ArrayList<BarData>();

    // 20 items
    for (int i = 0; i < 20; i++) {
        list.add(generateData(i + 1));
    }

    ChartDataAdapter cda = new ChartDataAdapter(getApplicationContext(), list);
    lv.setAdapter(cda);
}
项目:GitHub    文件:ListViewBarChartActivity.java   
/**
 * 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(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<IBarDataSet>();
    sets.add(d);

    BarData cd = new BarData(sets);
    cd.setBarWidth(0.9f);
    return cd;
}
项目:GitHub    文件:RealmDatabaseActivityHorizontalBar.java   
private void setData() {

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

        //RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "stackValues", "xIndex"); // normal entries
        RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "xValue", "stackValues", "floatValue"); // stacked entries
        set.setColors(new int[]{ColorTemplate.rgb("#8BC34A"), ColorTemplate.rgb("#FFC107"), ColorTemplate.rgb("#9E9E9E")});
        set.setLabel("Mobile OS distribution");
        set.setStackLabels(new String[]{"iOS", "Android", "Other"});

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

        // create a data object with the dataset list
        BarData data = new BarData(dataSets);
        styleData(data);
        data.setValueTextColor(Color.WHITE);

        // set data
        mChart.setData(data);
        mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
    }
项目:GitHub    文件:RealmDatabaseActivityBar.java   
private void setData() {

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

        //RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "stackValues", "xIndex"); // normal entries
        RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "xValue", "yValue"); // 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
        BarData data = new BarData(dataSets);
        styleData(data);

        // set data
        mChart.setData(data);
        mChart.setFitBars(true);
        mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
    }
项目:GitHub    文件:ListViewMultiChartActivity.java   
/**
 * 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(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;
}
项目:GitHub    文件:ScrollViewActivity.java   
private void setData(int count) {

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

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

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

    BarData data = new BarData(set);

    mChart.setData(data);
    mChart.invalidate();
    mChart.animateY(800);
}
项目:CodeWatch    文件:ProjectDetailsFragment.java   
private BarData generateBarData(List<Integer> progressSoFar) {

        ArrayList<BarEntry> barEntries = new ArrayList<>(progressSoFar.size());

        DateTime dateTime = new DateTime();
        referenceTime = dateTime.minusDays(7).getMillis();
        int totalSeconds = 0;
        for (int i = 0; i < progressSoFar.size(); i++) {
            int progress = progressSoFar.get(i);
            barEntries.add(new BarEntry(i, progress));
            totalSeconds += progress;
        }

        activityTotal.setText(context.getString(R.string.total_project_time,
                FormatUtils.getFormattedTime(context, totalSeconds)));

        BarDataSet barDataSet = new BarDataSet(barEntries, "");

        barDataSet.setColors(blue400);

        BarData barData = new BarData(barDataSet);
        barData.setBarWidth(0.85f);
        barData.setDrawValues(false);
        return barData;
    }
项目:CodeWatch    文件:GoalsDetailFragment.java   
private BarData generateBarData(int dailyGoal, List<Integer> progressSoFar) {


        ArrayList<BarEntry> barEntries = new ArrayList<>(progressSoFar.size());

        DateTime dateTime = new DateTime();
        referenceTime = dateTime.minusDays(7).getMillis();
        for (int i = 0; i < progressSoFar.size(); i++) {
            barEntries.add(new BarEntry(i, progressSoFar.get(i)));
        }

        BarDataSet barDataSet = new BarDataSet(barEntries, "");

        int colors[] = new int[progressSoFar.size()];
        for (int i = 0; i < progressSoFar.size(); i++) {
            colors[i] = (progressSoFar.get(i) >= dailyGoal * 60 * 60) ? green400 : red400;
        }
        barDataSet.setColors(colors);

        BarData barData = new BarData(barDataSet);
        barData.setBarWidth(0.85f);
        barData.setDrawValues(false);
        return barData;
    }
项目:DOUSalaries    文件:DataBaseHelper.java   
/**BarData chart items*/

    private ChartItem buildAgeChartItem(SQLiteDatabase db, long period) {
        ChartItem result = null;
        Cursor cursor = buildCursorForCharts(DemographicsType.AGE, db, period);
        if (cursor != null) {
            List<BarEntry> entries = new ArrayList<>();
            while (cursor.moveToNext()) {
                if (cursor.getInt(0) > 0){// age>0
                    float value = cursor.getFloat(0);
                    int count = cursor.getInt(1);
                    entries.add(new BarEntry(value, count, new EntryMarkerData(value, count)));
                }
            }
            if (!entries.isEmpty()){
                BarData barData = ChartHelper.populateBarData(entries, "", null);
                result = new VerticalBarChartItem(context, barData);
                ((VerticalBarChartItem) result).setTitle(context.getString(R.string.chart_item_age));
            }
            cursor.close();
        }
        return result;
    }
项目:shengyiplus-android    文件:HomeTricsActivity.java   
/**
 * 柱形图数据
 */
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;
}
项目:Stayfit    文件:SimpleFragment.java   
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;
    }
项目:beaconradar    文件:DetailsActivity.java   
/**
 * Procedure to add last DetailsData sample to chart.
 * @param data
 * @param chart
 */
private void insertChartSample(DetailsData data, BarChart chart, @Nullable Beacon beacon) {
    data.insertAndUpdate(beacon);
    BarData barData = chart.getData();
    BarDataSet set = barData.getDataSetByIndex(0);
    if(set.getEntryCount() == mPresenter.getSamplesCount()) {
        barData.removeXValue(0);
        set.removeEntry(0);
        for (Entry entry : set.getYVals()) {
            entry.setXIndex(entry.getXIndex() - 1);
        }
    }
    barData.addXValue(" ");
    BarEntry newEntry = new BarEntry(
            data.getCurrentValue(mPresenter.getMode()),
            set.getEntryCount());
    barData.addEntry(newEntry, 0);
    setChartRange(chart, data, mPresenter.getAutoscale());
    setChartAverage(chart, data, mPresenter.getAverage());

    chart.notifyDataSetChanged();
    chart.invalidate();
}
项目:Stayfit    文件:ListViewBarChartActivity.java   
/**
 * 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;
}
项目:Stayfit    文件:BarChartActivitySinus.java   
private void setData(int count) {

        ArrayList<String> xVals = new ArrayList<String>();

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

        for (int i = 0; i < count; i++) {
            xVals.add(i+"");
            entries.add(mSinusData.get(i));
        }

        BarDataSet set = new BarDataSet(entries, "Sinus Function");
        set.setBarSpacePercent(40f);
        set.setColor(Color.rgb(240, 120, 124));

        BarData data = new BarData(xVals, set);
        data.setValueTextSize(10f);
        data.setValueTypeface(mTf);
        data.setDrawValues(false);

        mChart.setData(data);
    }
项目:LETO-Toggl_Android    文件:BarHighlighter.java   
@Override
public Highlight getHighlight(float x, float y) {
    Highlight high = super.getHighlight(x, y);

    if(high == null) {
        return null;
    }

    MPPointD pos = getValsForTouch(x, y);

    BarData barData = mChart.getBarData();

    IBarDataSet set = barData.getDataSetByIndex(high.getDataSetIndex());
    if (set.isStacked()) {

        return getStackedHighlight(high,
                set,
                (float) pos.x,
                (float) pos.y);
    }

    MPPointD.recycleInstance(pos);

    return high;
}
项目:Stayfit    文件:ListViewMultiChartActivity.java   
/**
 * 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;
}
项目:Stayfit    文件:ScrollViewActivity.java   
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);
}
项目:Stayfit    文件:HorizontalBarChartActivity.java   
private void setData(int count, float range) {

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

        for (int i = 0; i < count; i++) {
            xVals.add(mMonths[i % 12]);
            yVals1.add(new BarEntry((float) (Math.random() * range), i));
        }

        BarDataSet set1 = new BarDataSet(yVals1, "DataSet 1");

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

        BarData data = new BarData(xVals, dataSets);
        data.setValueTextSize(10f);
        data.setValueTypeface(tf);

        mChart.setData(data);
    }
项目:bounswe2016group2    文件:userHomeFragment.java   
/**
     * Generate bar data bar data.
     *
     * @param dataSets the data sets
     * @param range    the range
     * @param count    the count
     * @return the bar data
     */
    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(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;
    }
项目:MarketBot    文件:MarketHistoryTab.java   
private BarData generateOrderBarData(List<MarketHistory> historyEntries) {

        SimpleDateFormat format = new SimpleDateFormat("MMM dd", Locale.getDefault());

        int size = historyEntries.size();
        List<BarEntry> entries = new ArrayList<>(size);
        List<String> xAxis = new ArrayList<>(size);
        for (int i = 0; i < size; i++) {
            MarketHistory history = historyEntries.get(i);
            Date recordDate = new Date(history.getRecordDate());

            xAxis.add(format.format(recordDate));
            entries.add(new BarEntry((float) history.getOrderCount(), i));
        }

        BarDataSet set = new BarDataSet(entries, "Order Count");
        set.setColor(Color.parseColor("#99FF99"));
//        set.setValueTextSize(0f);

        set.setDrawValues(false);

        set.setAxisDependency(YAxis.AxisDependency.RIGHT);
        return new BarData(xAxis, set);
    }
项目:2016.2-CidadeDemocratica    文件:CharterGenerator.java   
private static void setData(Chart barChart, List<Pair<String, Integer>> chartData, String title, Context context) {

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

        int count = chartData.size() > 10 ? 10 : chartData.size();
        for (int i = 0; i < count; i++) { //10 top states
            yVals.add(new BarEntry(i,chartData.get(i).second));
        }

        BarDataSet barDataSet = new BarDataSet(yVals, title);

        int[] colors = new int[]{context.getResources().getColor(R.color.colorChart1),
                context.getResources().getColor(R.color.colorChart2),
                context.getResources().getColor(R.color.colorChart3),
                context.getResources().getColor(R.color.colorChart4),
                context.getResources().getColor(R.color.colorChart5)};

        barDataSet.setColors(colors);

        BarData data = new BarData(barDataSet);
        data.setValueTextSize(12f);

        barChart.setData(data);
    }
项目:P2P    文件:BarChartActivity.java   
/**
 * 生成柱状图的数据
 */
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;
}
项目:Sxumiro_AndroidClient    文件:ListViewMultiChartFragment.java   
/**
 * 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;
}
项目:xs-android-architecture    文件:HorizontalBarHighlighter.java   
@Override
public Highlight getHighlight(float x, float y) {

    BarData barData = mChart.getBarData();

    MPPointD pos = getValsForTouch(y, x);

    Highlight high = getHighlightForX((float) pos.y, y, x);
    if (high == null)
        return null;

    IBarDataSet set = barData.getDataSetByIndex(high.getDataSetIndex());
    if (set.isStacked()) {

        return getStackedHighlight(high,
                set,
                (float) pos.y,
                (float) pos.x);
    }

    MPPointD.recycleInstance(pos);

    return high;
}
项目:xs-android-architecture    文件:SimpleFragment.java   
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(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;
    }
项目:xs-android-architecture    文件:ListViewBarChartActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_listview_chart);

    ListView lv = (ListView) findViewById(R.id.listView1);

    ArrayList<BarData> list = new ArrayList<BarData>();

    // 20 items
    for (int i = 0; i < 20; i++) {
        list.add(generateData(i + 1));
    }

    ChartDataAdapter cda = new ChartDataAdapter(getApplicationContext(), list);
    lv.setAdapter(cda);
}
项目:xs-android-architecture    文件:ListViewBarChartActivity.java   
/**
 * 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(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<IBarDataSet>();
    sets.add(d);

    BarData cd = new BarData(sets);
    cd.setBarWidth(0.9f);
    return cd;
}
项目:xs-android-architecture    文件:RealmDatabaseActivityHorizontalBar.java   
private void setData() {

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

        //RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "stackValues", "xIndex"); // normal entries
        RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "xValue", "stackValues", "floatValue"); // stacked entries
        set.setColors(new int[]{ColorTemplate.rgb("#8BC34A"), ColorTemplate.rgb("#FFC107"), ColorTemplate.rgb("#9E9E9E")});
        set.setLabel("Mobile OS distribution");
        set.setStackLabels(new String[]{"iOS", "Android", "Other"});

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

        // create a data object with the dataset list
        BarData data = new BarData(dataSets);
        styleData(data);
        data.setValueTextColor(Color.WHITE);

        // set data
        mChart.setData(data);
        mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
    }
项目:xs-android-architecture    文件:RealmDatabaseActivityBar.java   
private void setData() {

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

        //RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "stackValues", "xIndex"); // normal entries
        RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "xValue", "yValue"); // 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
        BarData data = new BarData(dataSets);
        styleData(data);

        // set data
        mChart.setData(data);
        mChart.setFitBars(true);
        mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
    }
项目:xs-android-architecture    文件:ListViewMultiChartActivity.java   
/**
 * 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(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;
}
项目:xs-android-architecture    文件:ScrollViewActivity.java   
private void setData(int count) {

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

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

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

    BarData data = new BarData(set);

    mChart.setData(data);
    mChart.invalidate();
    mChart.animateY(800);
}
项目:LETO-Toggl_Android    文件:HorizontalBarHighlighter.java   
@Override
public Highlight getHighlight(float x, float y) {

    BarData barData = mChart.getBarData();

    MPPointD pos = getValsForTouch(y, x);

    Highlight high = getHighlightForX((float) pos.y, y, x);
    if (high == null)
        return null;

    IBarDataSet set = barData.getDataSetByIndex(high.getDataSetIndex());
    if (set.isStacked()) {

        return getStackedHighlight(high,
                set,
                (float) pos.y,
                (float) pos.x);
    }

    MPPointD.recycleInstance(pos);

    return high;
}
项目:FaceT    文件:ProductDetailActivity.java   
public BarData getBarData() {

        ArrayList<BarEntry> entries = new ArrayList<>();
        float overall_people = 100f;

        Log.d(TAG + "barData", barRatingCount[3] + "");
        entries.add(new BarEntry(4, barRatingCount[4]));
        entries.add(new BarEntry(3, barRatingCount[3]));
        entries.add(new BarEntry(2, barRatingCount[2]));
        entries.add(new BarEntry(1, barRatingCount[1]));
        entries.add(new BarEntry(0, barRatingCount[0]));

        BarDataSet dataset = new BarDataSet(entries, "");
        dataset.setColors(CUSTOM_COLOR);
        dataset.setDrawValues(false);

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

        BarData data = new BarData(dataSets);
//        data.setValueTextSize(10f);
//        data.setValueTypeface(fontType);
        data.setBarWidth(1f);

        return data;
    }
项目:walt    文件:HistogramChart.java   
void recalculateDataSet(final BarData barData) {
    minBin = Math.floor(min / binWidth) * binWidth;
    maxBin = Math.floor(max / binWidth) * binWidth;

    int[][] bins = new int[rawData.size()][getNumBins()];

    for (int setNum = 0; setNum < rawData.size(); setNum++) {
        for (Double d : rawData.get(setNum)) {
            ++bins[setNum][(int) (Math.floor((d - minBin) / binWidth))];
        }
    }

    for (int setNum = 0; setNum < barData.getDataSetCount(); setNum++) {
        final IBarDataSet dataSet = barData.getDataSetByIndex(setNum);
        dataSet.clear();
        for (int i = 0; i < bins[setNum].length; i++) {
            dataSet.addEntry(new BarEntry(i, bins[setNum][i]));
        }
    }
    groupBars(barData);
    barData.notifyDataChanged();
}
项目:MobileProjectManagement    文件:TimeVisualization.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.timevis_layout);

    barchart = (BarChart) findViewById(R.id.barchart);

    Intent intent = getIntent();
    String ot = intent.getExtras().getString("ot");
    String pt = intent.getExtras().getString("pt");
    String lt = intent.getExtras().getString("lt");
    String pert = intent.getExtras().getString("pert");


    Float otf = Float.valueOf(ot);
    Float ptf = Float.valueOf(pt);
    Float ltf = Float.valueOf(lt);
    Float pertf = Float.valueOf(pert);


    List<BarEntry> entries = new ArrayList<>();
    entries.add(new BarEntry(0f, otf.floatValue()));
    entries.add(new BarEntry(1f, ptf.floatValue()));
    entries.add(new BarEntry(2f, ltf.floatValue()));
    entries.add(new BarEntry(3f, pertf.floatValue()));


    BarDataSet set = new BarDataSet(entries, "Time Visualization");
    BarData data = new BarData(set);
    data.setBarWidth(0.9f); // set custom bar width
    barchart.setData(data);
    barchart.setFitBars(true); // make the x-axis fit exactly all bars
    barchart.invalidate();


}
项目:GitHub    文件:BarChartRenderer.java   
@Override
public void initBuffers() {

    BarData barData = mChart.getBarData();
    mBarBuffers = new BarBuffer[barData.getDataSetCount()];

    for (int i = 0; i < mBarBuffers.length; i++) {
        IBarDataSet set = barData.getDataSetByIndex(i);
        mBarBuffers[i] = new BarBuffer(set.getEntryCount() * 4 * (set.isStacked() ? set.getStackSize() : 1),
                barData.getDataSetCount(), set.isStacked());
    }
}
项目:GitHub    文件:BarChartRenderer.java   
@Override
public void drawData(Canvas c) {

    BarData barData = mChart.getBarData();

    for (int i = 0; i < barData.getDataSetCount(); i++) {

        IBarDataSet set = barData.getDataSetByIndex(i);

        if (set.isVisible()) {
            drawDataSet(c, set, i);
        }
    }
}