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