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

项目: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   
/**
 * 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    文件: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;
    }
项目:Custom-Vison-Service    文件:NutritionActivity.java   
public void prepareChartData(Hit hit){
        entries = new ArrayList<BarEntry>();
        DecimalFormat df = new DecimalFormat();
        df.setMaximumFractionDigits(2);

        entries.add(new BarEntry(0, (float) (hit.getFields().getNfCalories()/2000)*100));
        entries.add(new BarEntry(1, (float) (hit.getFields().getNfTotalFat()/65)*100));
        entries.add(new BarEntry(2, (float) (hit.getFields().getNfCholesterol()/300)*100));
        entries.add(new BarEntry(3, (float)(hit.getFields().getNfSodium()/2400)*100));
        entries.add(new BarEntry(4, (float)(hit.getFields().getNfTotalCarbohydrate()/300)*100));
        entries.add(new BarEntry(5, (float) hit.getFields().getNfSodium()));
        entries.add(new BarEntry(6, (float) (hit.getFields().getNfProtein()/50)*100));
//        entries.add(new BarEntry(7, (float) hit.getFields().getNfVitaminADv(), "(mg)"));
//        entries.add(new BarEntry(8, (float) hit.getFields().getNfVitaminCDv(), "(mg)"));
//        entries.add(new BarEntry(9, (float) hit.getFields().getNfCalciumDv(), "(mg)"));

        BarDataSet dataSet = new BarDataSet(entries, String.format("%s Nutrition", food_item).toUpperCase());

        setChartData(dataSet);
    }
项目: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;
    }
项目: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);
    }
项目: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);
    }
项目: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);
    }
项目:P2P    文件:BarChart.java   
/**
 * Returns the bounding box of the specified Entry in the specified DataSet. Returns null if the Entry could not be
 * found in the charts data.
 * 
 * @param e
 * @return
 */
public RectF getBarBounds(BarEntry e) {

    BarDataSet set = mData.getDataSetForEntry(e);

    if (set == null)
        return null;

    float barspace = set.getBarSpace();
    float y = e.getVal();
    float x = e.getXIndex();

    float barWidth = 0.5f;

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

    RectF bounds = new RectF(left, top, right, bottom);

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

    return bounds;
}
项目:P2P    文件:BarHighlighter.java   
@Override
public Highlight getHighlight(float x, float y) {

    Highlight h = super.getHighlight(x, y);

    if (h == null)
        return h;
    else {

        BarDataSet set = mChart.getBarData().getDataSetByIndex(h.getDataSetIndex());

        if (set.isStacked()) {

            // create an array of the touch-point
            float[] pts = new float[2];
            pts[1] = y;

            // take any transformer to determine the x-axis value
            mChart.getTransformer(set.getAxisDependency()).pixelsToValue(pts);

            return getStackedHighlight(h, set, h.getXIndex(), h.getDataSetIndex(), pts[1]);
        } else
            return h;
    }
}
项目:P2P    文件:HorizontalBarHighlighter.java   
@Override
public Highlight getHighlight(float x, float y) {

    Highlight h = super.getHighlight(x, y);

    if (h == null)
        return h;
    else {

        BarDataSet set = mChart.getBarData().getDataSetByIndex(h.getDataSetIndex());

        if (set.isStacked()) {

            // create an array of the touch-point
            float[] pts = new float[2];
            pts[0] = y;

            // take any transformer to determine the x-axis value
            mChart.getTransformer(set.getAxisDependency()).pixelsToValue(pts);

            return getStackedHighlight(h, set, h.getXIndex(), h.getDataSetIndex(), pts[0]);
        } else
            return h;
    }
}
项目: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;
}
项目:react-native-mp-android-chart    文件:BarChartManager.java   
@Override
void dataSetConfig(IDataSet<BarEntry> dataSet, ReadableMap config) {
    BarDataSet barDataSet = (BarDataSet) dataSet;

    ChartDataSetConfigUtils.commonConfig(barDataSet, config);
    ChartDataSetConfigUtils.commonBarLineScatterCandleBubbleConfig(barDataSet, config);

    if (BridgeUtils.validate(config, ReadableType.Number, "barSpacePercent")) {
        barDataSet.setBarSpacePercent((float) config.getDouble("barSpacePercent"));
    }
    if (BridgeUtils.validate(config, ReadableType.String, "barShadowColor")) {
        barDataSet.setBarShadowColor(Color.parseColor(config.getString("barShadowColor")));
    }
    if (BridgeUtils.validate(config, ReadableType.Number, "highlightAlpha")) {
        barDataSet.setHighLightAlpha(config.getInt("highlightAlpha"));
    }
    if (BridgeUtils.validate(config, ReadableType.Array, "stackLabels")) {
        barDataSet.setStackLabels(BridgeUtils.convertToStringArray(config.getArray("stackLabels")));
    }
}
项目: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    文件: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   
/**
 * 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    文件: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);
}
项目:GoldenQuranAndroid    文件:StatisticsFragment.java   
private ArrayList<BarDataSet> getDataSet() {

        ArrayList<BarDataSet> dataSets = null;

        ArrayList<BarEntry> valueSet1 = new ArrayList<>();
        BarEntry v1e1 = new BarEntry(110.000f, 0); // Jan
        valueSet1.add(v1e1);
        BarEntry v1e2 = new BarEntry(40.000f, 1); // Feb
        valueSet1.add(v1e2);
        BarEntry v1e3 = new BarEntry(60.000f, 2); // Mar
        valueSet1.add(v1e3);
        BarEntry v1e4 = new BarEntry(30.000f, 3); // Apr
        valueSet1.add(v1e4);
        BarEntry v1e5 = new BarEntry(90.000f, 4); // May
        valueSet1.add(v1e5);
        BarEntry v1e6 = new BarEntry(100.000f, 5); // Jun
        valueSet1.add(v1e6);

        BarDataSet barDataSet1 = new BarDataSet(valueSet1, "Reading Status");
        barDataSet1.setColor(Color.rgb(255, 127, 80));

        dataSets = new ArrayList<>();
        dataSets.add(barDataSet1);
        return dataSets;
    }
项目: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;
    }
项目: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);
    }
项目:gadgetbridge_artikcloud    文件:AbstractChartFragment.java   
protected BarDataSet createActivitySet(List<BarEntry> values, List<Integer> colors, String label) {
        BarDataSet set1 = new BarDataSet(values, label);
        set1.setColors(colors);
//        set1.setDrawCubic(true);
//        set1.setCubicIntensity(0.2f);
//        //set1.setDrawFilled(true);
//        set1.setDrawCircles(false);
//        set1.setLineWidth(2f);
//        set1.setCircleSize(5f);
//        set1.setFillColor(ColorTemplate.getHoloBlue());
        set1.setDrawValues(false);
//        set1.setHighLightColor(Color.rgb(128, 0, 255));
//        set1.setColor(Color.rgb(89, 178, 44));
        set1.setValueTextColor(CHART_TEXT_COLOR);
        set1.setAxisDependency(YAxis.AxisDependency.LEFT);
        return set1;
    }
项目:gadgetbridge_artikcloud    文件:AbstractChartFragment.java   
protected BarDataSet createLightSleepSet(List<BarEntry> values, String label) {
        BarDataSet set1 = new BarDataSet(values, label);

//        set1.setDrawCubic(true);
//        set1.setCubicIntensity(0.2f);
//        //set1.setDrawFilled(true);
//        set1.setDrawCircles(false);
//        set1.setLineWidth(2f);
//        set1.setCircleSize(5f);
//        set1.setFillColor(ColorTemplate.getHoloBlue());
        set1.setDrawValues(false);
//        set1.setHighLightColor(Color.rgb(244, 117, 117));
//        set1.setColor(Color.rgb(182, 191, 255));
        set1.setValueTextColor(CHART_TEXT_COLOR);
//        set1.setColor(Color.CYAN);
        return set1;
    }
项目: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;
    }
项目: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();
}
项目:AndroidDatabaseLibraryComparison    文件:MainActivity.java   
private void initChart() {
    ArrayList<BarDataSet> dataSets = new ArrayList<>();
    // note that we show save first because that's how we initialize the DB
    for (String frameworkName : chartEntrySets.keySet()) {
        ArrayList<BarEntry> entrySet = chartEntrySets.get(frameworkName);
        BarDataSet dataSet = new BarDataSet(entrySet, frameworkName);
        dataSet.setColor(getFrameworkColor(frameworkName));
        dataSets.add(dataSet);
    }
    // load data and animate it
    ArrayList<String> xAxisLabels = new ArrayList<>();
    xAxisLabels.add("Save (msec)");
    xAxisLabels.add("Load (msec)");
    BarData data = new BarData(xAxisLabels, dataSets);
    chartView.setData(data);
    chartView.setDescription(null); // this takes up too much space, so clear it
    chartView.animateXY(2000, 2000);
    chartView.invalidate();
}
项目:mobile-manager-for-cloudflare    文件:BarChart.java   
/**
 * Returns the bounding box of the specified Entry in the specified DataSet.
 * Returns null if the Entry could not be found in the charts data.
 * 
 * @param e
 * @param dataSetIndex
 * @return
 */
public RectF getBarBounds(BarEntry e) {

    BarDataSet set = mData.getDataSetForEntry(e);

    if (set == null)
        return null;

    float barspace = set.getBarSpace();
    float y = e.getVal();
    float x = e.getXIndex();

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

    RectF bounds = new RectF(left, top, right, bottom);

    mTrans.rectValueToPixel(bounds);

    return bounds;
}
项目:mobile-manager-for-cloudflare    文件:BarLineChartBase.java   
/**
 * Returns the position (in pixels) the provided Entry has inside the chart
 * view or null, if the provided Entry is null.
 * 
 * @param e
 * @return
 */
public PointF getPosition(Entry e) {

    if (e == null)
        return null;

    float[] vals = new float[] {
            e.getXIndex(), e.getVal()
    };

    if (this instanceof BarChart) {

        BarDataSet set = (BarDataSet) mData.getDataSetForEntry(e);
        if (set != null)
            vals[0] += set.getBarSpace() / 2f;
    }

    mTrans.pointValuesToPixel(vals);

    return new PointF(vals[0], vals[1]);
}
项目:eCarNet    文件:BarChartCustom.java   
public BarChartCustom(BarChart graphical, ArrayList<BarEntry> entries, String entriesLegend, ArrayList<String> labels, String chartDecription)
{
    this.entries = entries;
    this.chart = graphical;
    this.dataset = new BarDataSet(entries, entriesLegend);
    this.data = new BarData(labels, this.dataset);
    this.colors = new ArrayList<>();
    this.yLeftAxis = chart.getAxisLeft();
    this.yRightAxis = chart.getAxisRight();
    this.xAxis = chart.getXAxis();
    chart.setTouchEnabled(false);
    this.average = new LimitLine(getAverage(), String.format("%1$s : %2$.2f", "Moyenne", getAverage()));
    this.average.setTextSize(10);
    this.average.setLineColor(Color.RED);
    this.average.setLineWidth(1.5f);
    this.yLeftAxis.addLimitLine(average);
    this.average.setEnabled(false);
    this.legend = chart.getLegend();
    if(chartDecription!= null)
        chart.setDescription(chartDecription);
    else chart.setDescription("");
    setDefaultChart();
    setDefaultLegend();
    setDefaultAxes();
}
项目:NoiseCapture    文件:MeasurementActivity.java   
private void setData(double val) {

        ArrayList<String> xVals = new ArrayList<String>();
        xVals.add("");

        ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
        yVals1.add(new BarEntry((float)val, 0));

        BarDataSet set1 = new BarDataSet(yVals1, "DataSet");
        //set1.setBarSpacePercent(35f);
        //set1.setColor(Color.rgb(0, 153, 204));
        int nc=getNEcatColors(val);    // Choose the color category in function of the sound level
        set1.setColor(NE_COLORS[nc]);

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

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

        mChart.setData(data);
        mChart.invalidate(); // refresh
    }
项目:Expense-Tracker-App    文件:StatisticsFragment.java   
private void setCategoriesBarChart() {
    List<String> categoriesNames = new ArrayList<>();
    List<BarEntry> entryPerCategory = new ArrayList<>();

    for (int i=0; i < mCategoryList.size(); i++) {
        float value = Expense.getCategoryTotalByDate(DateManager.getInstance().getDateFrom(), DateManager.getInstance().getDateTo(), mCategoryList.get(i));
        if (value > 0) {
            categoriesNames.add(mCategoryList.get(i).getName());
            entryPerCategory.add(new BarEntry(value, categoriesNames.size()-1));
        }
    }
    if (categoriesNames.isEmpty()) {
        tvBcCategoriesEmpty.setVisibility(View.VISIBLE);
        bcCategories.setVisibility(View.GONE);
    } else {
        tvBcCategoriesEmpty.setVisibility(View.GONE);
        bcCategories.setVisibility(View.VISIBLE);
    }
    BarDataSet dataSet = new BarDataSet(entryPerCategory, getString(R.string.categories));
    dataSet.setColors(Util.getListColors());
    BarData barData = new BarData(categoriesNames, dataSet);
    bcCategories.setData(barData);
    bcCategories.invalidate();
}
项目:MPAndroidChart    文件: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;
    }
项目:MPAndroidChart    文件: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;
}