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


Java BarData类代码示例

本文整理汇总了Java中com.github.mikephil.charting.data.BarData的典型用法代码示例。如果您正苦于以下问题:Java BarData类的具体用法?Java BarData怎么用?Java BarData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BarData类属于com.github.mikephil.charting.data包,在下文中一共展示了BarData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateBarData

import com.github.mikephil.charting.data.BarData; //导入依赖的package包/类
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;
    }
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:24,代码来源:SimpleFragment.java

示例2: onCreate

import com.github.mikephil.charting.data.BarData; //导入依赖的package包/类
@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();


}
 
开发者ID:AswinVasudevan21,项目名称:MobileProjectManagement,代码行数:37,代码来源:TimeVisualization.java

示例3: getHighlight

import com.github.mikephil.charting.data.BarData; //导入依赖的package包/类
@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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:BarHighlighter.java

示例4: getHighlight

import com.github.mikephil.charting.data.BarData; //导入依赖的package包/类
@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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:HorizontalBarHighlighter.java

示例5: generateBarData

import com.github.mikephil.charting.data.BarData; //导入依赖的package包/类
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;
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:SimpleFragment.java

示例6: onCreate

import com.github.mikephil.charting.data.BarData; //导入依赖的package包/类
@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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:ListViewBarChartActivity.java

示例7: generateData

import com.github.mikephil.charting.data.BarData; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:ListViewBarChartActivity.java

示例8: setData

import com.github.mikephil.charting.data.BarData; //导入依赖的package包/类
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);
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:RealmDatabaseActivityHorizontalBar.java

示例9: setData

import com.github.mikephil.charting.data.BarData; //导入依赖的package包/类
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);
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:RealmDatabaseActivityBar.java

示例10: generateDataBar

import com.github.mikephil.charting.data.BarData; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:ListViewMultiChartActivity.java

示例11: setData

import com.github.mikephil.charting.data.BarData; //导入依赖的package包/类
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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:ScrollViewActivity.java

示例12: generateBarData

import com.github.mikephil.charting.data.BarData; //导入依赖的package包/类
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;
    }
 
开发者ID:Protino,项目名称:CodeWatch,代码行数:26,代码来源:ProjectDetailsFragment.java

示例13: generateBarData

import com.github.mikephil.charting.data.BarData; //导入依赖的package包/类
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;
    }
 
开发者ID:Protino,项目名称:CodeWatch,代码行数:25,代码来源:GoalsDetailFragment.java

示例14: buildAgeChartItem

import com.github.mikephil.charting.data.BarData; //导入依赖的package包/类
/**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;
    }
 
开发者ID:graviton57,项目名称:DOUSalaries,代码行数:24,代码来源:DataBaseHelper.java

示例15: generateBarData

import com.github.mikephil.charting.data.BarData; //导入依赖的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


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