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


Java BarDataSet.setStackLabels方法代码示例

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


在下文中一共展示了BarDataSet.setStackLabels方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dataSetConfig

import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
@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")));
    }
}
 
开发者ID:mskec,项目名称:react-native-mp-android-chart,代码行数:21,代码来源:BarChartManager.java

示例2: generateBarData

import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private BarData generateBarData() {

        ArrayList<BarEntry> entries1 = new ArrayList<BarEntry>();
        ArrayList<BarEntry> entries2 = new ArrayList<BarEntry>();

        for (int index = 0; index < itemcount; index++) {
            entries1.add(new BarEntry(0, getRandom(25, 25)));

            // stacked
            entries2.add(new BarEntry(0, new float[]{getRandom(13, 12), getRandom(13, 12)}));
        }

        BarDataSet set1 = new BarDataSet(entries1, "Bar 1");
        set1.setColor(Color.rgb(60, 220, 78));
        set1.setValueTextColor(Color.rgb(60, 220, 78));
        set1.setValueTextSize(10f);
        set1.setAxisDependency(YAxis.AxisDependency.LEFT);

        BarDataSet set2 = new BarDataSet(entries2, "");
        set2.setStackLabels(new String[]{"Stack 1", "Stack 2"});
        set2.setColors(new int[]{Color.rgb(61, 165, 255), Color.rgb(23, 197, 255)});
        set2.setValueTextColor(Color.rgb(61, 165, 255));
        set2.setValueTextSize(10f);
        set2.setAxisDependency(YAxis.AxisDependency.LEFT);

        float groupSpace = 0.06f;
        float barSpace = 0.02f; // x2 dataset
        float barWidth = 0.45f; // x2 dataset
        // (0.45 + 0.02) * 2 + 0.06 = 1.00 -> interval per "group"

        BarData d = new BarData(set1, set2);
        d.setBarWidth(barWidth);

        // make this BarData object grouped
        d.groupBars(0, groupSpace, barSpace); // start at x = 0

        return d;
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:39,代码来源:CombinedChartActivity.java

示例3: onProgressChanged

import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

	tvX.setText("" + (mSeekBarX.getProgress() + 1));
	tvY.setText("" + (mSeekBarY.getProgress()));

	ArrayList<String> xVals = new ArrayList<String>();
	for (int i = 0; i < mSeekBarX.getProgress() + 1; i++) {
		xVals.add(mMonths[i % mMonths.length]);
	}

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

	for (int i = 0; i < mSeekBarX.getProgress() + 1; i++) {
		float mult = (mSeekBarY.getProgress() + 1);
		float val1 = (float) (Math.random() * mult) + mult / 3;
		float val2 = (float) (Math.random() * mult) + mult / 3;
		float val3 = (float) (Math.random() * mult) + mult / 3;

		yVals1.add(new BarEntry(new float[] { val1, val2, val3 }, i));
	}

	BarDataSet set1 = new BarDataSet(yVals1, "Statistics Vienna 2014");
	set1.setColors(getColors());
	set1.setStackLabels(new String[] { "Births", "Divorces", "Marriages" });

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

	BarData data = new BarData(xVals, dataSets);
	data.setValueFormatter(new MyValueFormatter());

	mChart.setData(data);
	mChart.invalidate();
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:36,代码来源:StackedBarActivity.java

示例4: generateBarData

import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private BarData generateBarData(float index, float dis) {

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


        for (int i = 0; i < count; i++) {
            float a = new Random().nextInt(40) / 100f + 0.1f;
            float b = new Random().nextInt(40) / 100f + 0.1f;
            entries.add(new BarEntry(index, new float[]{a, b, 1 - a - b}));
            index += dis;
        }

        BarDataSet set = new BarDataSet(entries, "hello");
        set.setStackLabels(new String[]{"1", "2"});
        set.setColors(new int[]{Color.rgb(154, 209, 253), Color.rgb(254, 206, 121), Color.rgb(253, 136, 95)});
        set.setValueTextColor(Color.rgb(61, 165, 255));
        set.setValueTextSize(10f);
        set.setAxisDependency(YAxis.AxisDependency.LEFT);


        ArrayList<IBarDataSet> threebardata = new ArrayList<>();

        BarData d = new BarData(threebardata);
        d.setBarWidth(0.4f);
        d.setDrawValues(true);

        d.addDataSet(set);

        d.setValueFormatter(new IValueFormatter() {
            @Override
            public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
                return toPercentDecimalStr(value);
            }
        });
        return d;
    }
 
开发者ID:xsingHu,项目名称:xs-android-architecture,代码行数:37,代码来源:MainActivity.java

示例5: updateSpectrumGUI

import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private void updateSpectrumGUI() {


        ArrayList<String> xVals = new ArrayList<String>();
        ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
        double[] freqLabels = measurementService.getAudioProcess().getRealtimeCenterFrequency();
        float[] freqValues = measurementService.getAudioProcess().getThirdOctaveFrequencySPL();
        for(int idfreq =0; idfreq < freqLabels.length; idfreq++) {
            xVals.add(Spectrogram.formatFrequency((int)freqLabels[idfreq]));
            // Sum values
            // Compute frequency range covered by frequency
            yVals1.add(new BarEntry(new float[] {freqValues[idfreq]}, idfreq));
        }

        BarDataSet set1 = new BarDataSet(yVals1, "DataSet");
        set1.setColor(Color.rgb(102, 178, 255));
        set1.setStackLabels(new String[]{
                "SL"
        });

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

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

        BarChart sChart = getSpectrum();
        if(sChart != null){
            sChart.setData(data);
            sChart.setPadding(0, 0, 0, 0);
            sChart.setViewPortOffsets(0,0,0,0);
            sChart.invalidate(); // refresh
        }
    }
 
开发者ID:Ifsttar,项目名称:NoiseCapture,代码行数:35,代码来源:MeasurementActivity.java

示例6: onCreateView

import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.chart_frag, container, false);

    // Set up timeline chart
    chart = view.findViewById(R.id.timeline);
    entries = new ArrayList<>();

    // Set up the x-axis
    XAxis xAxis = chart.getXAxis();
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);

    formatter = DateTimeFormatter.ofPattern("MMM d");
    dates = new ArrayList<>();

    int numDays = 14;
    LocalDate today = LocalDate.now();
    minimumDate = today.minusDays(numDays);
    LocalDate currentDay = minimumDate;

    dateMap = new HashMap<>();

    for (int i = 0; i < numDays + 1; i++) {
        float index = (float) i;

        String dateString = currentDay.format(formatter);
        dates.add(dateString);
        dateMap.put(dateString, i);

        BarEntry barEntry = new BarEntry(index, new float[] { 0, 0, 0, 0 });
        entries.add(barEntry);

        currentDay = currentDay.plusDays(1);
    }

    xAxis.setValueFormatter(new MyXAxisValueFormatter(dates));
    xAxis.setLabelCount(numDays);
    xAxis.setGranularity(1f);
    xAxis.setLabelRotationAngle(45f);

    UserAccount currentUser = HabitUpApplication.getCurrentUser();

    // Get user events
    ArrayList<HabitEvent> eventList = currentUser.getEventList().getEvents();

    for (HabitEvent event : eventList) {
        if (withinDateRange(event.getCompletedate(), minimumDate)) {
            addChartEntry(event);
        }
    }

    set = new BarDataSet(entries, "");
    int red = Color.parseColor(Attributes.getColour("Physical"));
    int purple = Color.parseColor(Attributes.getColour("Mental"));
    int green = Color.parseColor(Attributes.getColour("Discipline"));
    int blue = Color.parseColor(Attributes.getColour("Social"));
    int[] colors = {red, purple, green, blue};
    set.setColors(colors);
    set.setStackLabels(new String[]{"Physical", "Mental", "Discipline", "Social"});
    set.setDrawValues(false);

    BarData data = new BarData(set);
    data.setBarWidth(0.6f);

    YAxis leftAxis = chart.getAxisLeft();
    leftAxis.setValueFormatter(new MyYAxisValueFormatter());
    leftAxis.setGranularity(1f);
    leftAxis.setAxisMinimum(0f);
    chart.getAxisRight().setEnabled(false);

    chart.setData(data);
    chart.setFitBars(true);
    chart.getXAxis().setDrawGridLines(false);
    chart.getAxisLeft().setDrawGridLines(false);
    chart.getDescription().setEnabled(false);
    animateChart();
    chart.invalidate();

    return view;
}
 
开发者ID:CMPUT301F17T29,项目名称:HabitUp,代码行数:82,代码来源:ChartFragment.java

示例7: onCreate

import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_age_distribution);

    setTitle("Age Distribution Austria");

    mChart = (HorizontalBarChart) findViewById(R.id.chart1);
    mChart.setOnChartValueSelectedListener(this);
    mChart.setDrawGridBackground(false);
    mChart.setDescription("");

    // scaling can now only be done on x- and y-axis separately
    mChart.setPinchZoom(false);

    mChart.setDrawBarShadow(false);
    mChart.setDrawValueAboveBar(true);
    
    mChart.getAxisLeft().setEnabled(false);
    mChart.getAxisRight().setAxisMaxValue(25f);
    mChart.getAxisRight().setAxisMinValue(-25f);
    mChart.getAxisRight().setDrawGridLines(false);
    mChart.getAxisRight().setDrawZeroLine(true);
    mChart.getAxisRight().setLabelCount(7, false);
    mChart.getAxisRight().setValueFormatter(new CustomFormatter());
    mChart.getAxisRight().setTextSize(9f);

    XAxis xAxis = mChart.getXAxis();
    xAxis.setPosition(XAxisPosition.BOTH_SIDED);
    xAxis.setDrawGridLines(false);
    xAxis.setDrawAxisLine(false);
    xAxis.setTextSize(9f);

    Legend l = mChart.getLegend();
    l.setPosition(LegendPosition.BELOW_CHART_RIGHT);
    l.setFormSize(8f);
    l.setFormToTextSpace(4f);
    l.setXEntrySpace(6f);

    // IMPORTANT: When using negative values in stacked bars, always make sure the negative values are in the array first
    ArrayList<BarEntry> yValues = new ArrayList<BarEntry>();
    yValues.add(new BarEntry(new float[]{ -10, 10 }, 0));
    yValues.add(new BarEntry(new float[]{ -12, 13 }, 1));
    yValues.add(new BarEntry(new float[]{ -15, 15 }, 2));
    yValues.add(new BarEntry(new float[]{ -17, 17 }, 3));
    yValues.add(new BarEntry(new float[]{ -19, 20 }, 4));
    yValues.add(new BarEntry(new float[]{ -19, 19 }, 5));
    yValues.add(new BarEntry(new float[]{ -16, 16 }, 6));
    yValues.add(new BarEntry(new float[]{ -13, 14 }, 7));
    yValues.add(new BarEntry(new float[]{ -10, 11 }, 8));
    yValues.add(new BarEntry(new float[]{ -5, 6 }, 9));
    yValues.add(new BarEntry(new float[]{ -1, 2 }, 10));

    BarDataSet set = new BarDataSet(yValues, "Age Distribution");
    set.setValueFormatter(new CustomFormatter());
    set.setValueTextSize(7f);
    set.setAxisDependency(YAxis.AxisDependency.RIGHT);
    set.setBarSpacePercent(40f);
    set.setColors(new int[] {Color.rgb(67,67,72), Color.rgb(124,181,236)});
    set.setStackLabels(new String[]{
            "Men", "Women"
    });

    String []xVals = new String[]{"0-10", "10-20", "20-30", "30-40", "40-50", "50-60", "60-70", "70-80", "80-90", "90-100", "100+"};

    BarData data = new BarData(xVals, set);
    mChart.setData(data);
    mChart.invalidate();
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:72,代码来源:StackedBarActivityNegative.java

示例8: createBarChartStacked

import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
/**
         * Creates the stacked bar chart showing counters visually.
         */
        private void createBarChartStacked(BarChart barChart) {
            if (game != null) {
                ArrayList<BarEntry> entries = new ArrayList<>();
                // create stacked bar chart

                // fill single rolls, 1..6
                // and  double roll sums, 2..12  into list of bar entries
                int[] counts1 = sr.getCounts();
                int[] counts2 = dr.getSumCount();
                // loop dice roll sums 1..12
                for (int i = 0; i < counts2.length + 1; i++) {
                    float[] vals = {0f, 0f};
                    if (i < counts1.length) {
                        vals[0] = (float) counts1[i];
                    }
                    if (i > 0) {
                        vals[1] = (float) counts2[i - 1];
                    }
                    entries.add(new BarEntry(vals, i));
                }

                BarDataSet dataset = new BarDataSet(entries, getString(R.string.stats_chart_legend));
                dataset.setStackLabels(new String[]{
                        getString(R.string.stats_chart_legend_single, sr.getTotal()),
                        getString(R.string.stats_chart_legend_double, dr.getTotal())
                });

                ArrayList<String> labels = new ArrayList<>();
                // fill label for dice roll sums, 1..12
                for (int i = 0; i < counts2.length + 1; i++) {
                    labels.add(Integer.toString(i + 1));
                }

                // explicit color resolving with util, see AboutActivity#demoBarChart
                List<Integer> colors = ColorTemplate.createColors(getResources(), new int[]{R.color.colorSingleRoll, R.color.colorDoubleRoll});
                //dataset.setColors(ColorTemplate.COLORFUL_COLORS);
                dataset.setColors(colors);

                BarData data = new BarData(labels, dataset);
                barChart.setData(data);

                dataset.setDrawValues(false);
                // try drawing data labels larger but with integer number - strange visual effects!
//                data.setValueTextSize(14);
//                data.setValueFormatter(new ValueFormatter() {
//                    @Override
//                    public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
//                        return String.format(Locale.US, "%1.0f", value);
//                    }
//                });
            }
        }
 
开发者ID:thilo20,项目名称:MachiKoroPad,代码行数:56,代码来源:StatsActivity.java

示例9: createBarChartStackedPlayers

import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
/**
         * Creates the stacked bar chart showing results player vs. player.
         */
        private void createBarChartStackedPlayers(BarChart barChart) {
            if (game != null) {
                ArrayList<BarEntry> entries = new ArrayList<>();
                // create stacked bar chart

                // fill roll results per player
                // loop dice roll sums 1..14
                int len = game.isHarbour() ? 14 : 12;
                for (int i = 0; i < len; i++) {
                    float[] vals = new float[game.getNumPlayers()];
                    for (int pl = 0; pl < game.getNumPlayers(); pl++) {
                        vals[pl] = (float) game.getPlayer(pl).getRollResult().getCount()[i];
                    }
                    entries.add(new BarEntry(vals, i));
                }

                BarDataSet dataset = new BarDataSet(entries, "");

                String[] names = new String[game.getNumPlayers()];
                for (int pl = 0; pl < game.getNumPlayers(); pl++) {
                    names[pl] = game.getPlayer(pl).getName();
                }
                dataset.setStackLabels(names);

                ArrayList<String> labels = new ArrayList<>();
                // fill label for dice roll sums, 1..12
                for (int i = 0; i < len; i++) {
                    labels.add(Integer.toString(i + 1));
                }

                // explicit color resolving with util, see AboutActivity#demoBarChart
                int[] playercolors = new int[game.getNumPlayers()];
                for (int pl = 0; pl < game.getNumPlayers(); pl++) {
                    playercolors[pl] = game.getPlayer(pl).getColor();
                }
//                List<Integer> colors = ColorTemplate.createColors(getResources(), playercolors);
//                dataset.setColors(colors);
                dataset.setColors(playercolors);

                BarData data = new BarData(labels, dataset);
                barChart.setData(data);

                dataset.setDrawValues(false);
            }
        }
 
开发者ID:thilo20,项目名称:MachiKoroPad,代码行数:49,代码来源:StatsActivity.java


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