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


Java BarEntry类代码示例

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


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

示例1: onCreate

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

示例2: getBarBounds

import com.github.mikephil.charting.data.BarEntry; //导入依赖的package包/类
/**
 * The passed outputRect will be assigned the values of the bounding box of the specified Entry in the specified DataSet.
 * The rect will be assigned Float.MIN_VALUE in all locations if the Entry could not be found in the charts data.
 *
 * @param e
 * @return
 */
public void getBarBounds(BarEntry e, RectF outputRect) {

    RectF bounds = outputRect;

    IBarDataSet set = mData.getDataSetForEntry(e);

    if (set == null) {
        bounds.set(Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE);
        return;
    }

    float y = e.getY();
    float x = e.getX();

    float barWidth = mData.getBarWidth();

    float left = x - barWidth / 2f;
    float right = x + barWidth / 2f;
    float top = y >= 0 ? y : 0;
    float bottom = y <= 0 ? y : 0;

    bounds.set(left, top, right, bottom);

    getTransformer(set.getAxisDependency()).rectValueToPixel(outputRect);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:33,代码来源:BarChart.java

示例3: getBarBounds

import com.github.mikephil.charting.data.BarEntry; //导入依赖的package包/类
@Override
public void getBarBounds(BarEntry e, RectF outputRect) {

    RectF bounds = outputRect;
    IBarDataSet set = mData.getDataSetForEntry(e);

    if (set == null) {
        outputRect.set(Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE);
        return;
    }

    float y = e.getY();
    float x = e.getX();

    float barWidth = mData.getBarWidth();

    float top = x - barWidth / 2f;
    float bottom = x + barWidth / 2f;
    float left = y >= 0 ? y : 0;
    float right = y <= 0 ? y : 0;

    bounds.set(left, top, right, bottom);

    getTransformer(set.getAxisDependency()).rectValueToPixel(bounds);

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:HorizontalBarChart.java

示例4: getFormattedValue

import com.github.mikephil.charting.data.BarEntry; //导入依赖的package包/类
@Override
public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {

    if (!mDrawWholeStack && entry instanceof BarEntry) {

        BarEntry barEntry = (BarEntry) entry;
        float[] vals = barEntry.getYVals();

        if (vals != null) {

            // find out if we are on top of the stack
            if (vals[vals.length - 1] == value) {

                // return the "sum" across all stack values
                return mFormat.format(barEntry.getY()) + mAppendix;
            } else {
                return ""; // return empty
            }
        }
    }

    // return the "proposed" value
    return mFormat.format(value) + mAppendix;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:StackedValueFormatter.java

示例5: onValueSelected

import com.github.mikephil.charting.data.BarEntry; //导入依赖的package包/类
@SuppressLint("NewApi")
@Override
public void onValueSelected(Entry e, Highlight h) {

    if (e == null)
        return;

    RectF bounds = mOnValueSelectedRectF;
    mChart.getBarBounds((BarEntry) e, bounds);
    MPPointF position = mChart.getPosition(e, AxisDependency.LEFT);

    Log.i("bounds", bounds.toString());
    Log.i("position", position.toString());

    Log.i("x-index",
            "low: " + mChart.getLowestVisibleX() + ", high: "
                    + mChart.getHighestVisibleX());

    MPPointF.recycleInstance(position);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:BarChartActivity.java

示例6: generateBarData

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

示例7: generateData

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

import com.github.mikephil.charting.data.BarEntry; //导入依赖的package包/类
@Override
public void refreshContent(Entry e, Highlight highlight) {

    if (e instanceof BarEntry) {

        BarEntry be = (BarEntry) e;

        if(be.getYVals() != null) {

            // draw the stack value
            tvContent.setText("" + Utils.formatNumber(be.getYVals()[highlight.getStackIndex()], 0, true));
        } else {
            tvContent.setText("" + Utils.formatNumber(be.getY(), 0, true));
        }
    } else {

        tvContent.setText("" + Utils.formatNumber(e.getY(), 0, true));
    }

    super.refreshContent(e, highlight);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:StackedBarsMarkerView.java

示例9: generateDataBar

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

示例10: setData

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

示例11: onValueSelected

import com.github.mikephil.charting.data.BarEntry; //导入依赖的package包/类
@SuppressLint("NewApi")
@Override
public void onValueSelected(Entry e, Highlight h) {

    if (e == null)
        return;

    RectF bounds = mOnValueSelectedRectF;
    mChart.getBarBounds((BarEntry) e, bounds);

    MPPointF position = mChart.getPosition(e, mChart.getData().getDataSetByIndex(h.getDataSetIndex())
            .getAxisDependency());

    Log.i("bounds", bounds.toString());
    Log.i("position", position.toString());

    MPPointF.recycleInstance(position);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:HorizontalBarChartActivity.java

示例12: generateBarData

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

import com.github.mikephil.charting.data.BarEntry; //导入依赖的package包/类
private void addChartEntry(HabitEvent event) {
    String date = event.getCompletedate().format(formatter);
    int index = dateMap.get(date);
    BarEntry entry = entries.get(index);

    float[] stacks = entry.getYVals();

    String attribute = event.getHabitAttribute();
    if (attribute.equals("Physical")) {
        stacks[0] += 1;
    } else if (attribute.equals("Mental")) {
        stacks[1] += 1;
    } else if (attribute.equals("Discipline")) {
        stacks[2] += 1;
    } else if (attribute.equals("Social")) {
        stacks[3] += 1;
    }
    entry.setVals(stacks);
}
 
开发者ID:CMPUT301F17T29,项目名称:HabitUp,代码行数:20,代码来源:ChartFragment.java

示例15: buildAgeChartItem

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


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