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


Java IBarDataSet.getEntryForIndex方法代码示例

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


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

示例1: generateTransformedValuesBarChart

import com.github.mikephil.charting.interfaces.datasets.IBarDataSet; //导入方法依赖的package包/类
/**
 * Transforms an List of Entry into a float array containing the x and
 * y values transformed with all matrices for the BARCHART.
 *
 * @param data
 * @param dataSetIndex the dataset index
 * @param bd
 * @param phaseY
 * @return
 */
public float[] generateTransformedValuesBarChart(IBarDataSet data,
                                                 int dataSetIndex, BarData bd, float phaseY) {

    float[] valuePoints = new float[data.getEntryCount() * 2];

    int setCount = bd.getDataSetCount();
    float space = bd.getGroupSpace();

    for (int j = 0; j < valuePoints.length; j += 2) {

        Entry e = data.getEntryForIndex(j / 2);
        int i = e.getXIndex();

        // calculate the x-position, depending on datasetcount
        float x = e.getXIndex() + i * (setCount - 1) + dataSetIndex + space * i
                + space / 2f;
        float y = e.getVal();

        valuePoints[j] = x;
        valuePoints[j + 1] = y * phaseY;
    }

    getValueToPixelMatrix().mapPoints(valuePoints);

    return valuePoints;
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:37,代码来源:Transformer.java

示例2: generateTransformedValuesHorizontalBarChart

import com.github.mikephil.charting.interfaces.datasets.IBarDataSet; //导入方法依赖的package包/类
/**
 * Transforms an List of Entry into a float array containing the x and
 * y values transformed with all matrices for the BARCHART.
 *
 * @param data
 * @param dataSet the dataset index
 * @return
 */
public float[] generateTransformedValuesHorizontalBarChart(IBarDataSet data,
                                                           int dataSet, BarData bd, float phaseY) {

    float[] valuePoints = new float[data.getEntryCount() * 2];

    int setCount = bd.getDataSetCount();
    float space = bd.getGroupSpace();

    for (int j = 0; j < valuePoints.length; j += 2) {

        Entry e = data.getEntryForIndex(j / 2);
        int i = e.getXIndex();

        // calculate the x-position, depending on datasetcount
        float x = i + i * (setCount - 1) + dataSet + space * i
                + space / 2f;
        float y = e.getVal();

        valuePoints[j] = y * phaseY;
        valuePoints[j + 1] = x;
    }

    getValueToPixelMatrix().mapPoints(valuePoints);

    return valuePoints;
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:35,代码来源:Transformer.java

示例3: groupBars

import com.github.mikephil.charting.interfaces.datasets.IBarDataSet; //导入方法依赖的package包/类
/**
 * Re-implementation of BarData.groupBars(), but allows grouping with only 1 BarDataSet
 * This adjusts the x-coordinates of entries, which centers the bars between axis labels
 */
static void groupBars(final BarData barData) {
    IBarDataSet max = barData.getMaxEntryCountSet();
    int maxEntryCount = max.getEntryCount();
    float groupSpaceWidthHalf = GROUP_SPACE / 2f;
    float barWidthHalf = barData.getBarWidth() / 2f;
    float interval = barData.getGroupWidth(GROUP_SPACE, 0);
    float fromX = 0;

    for (int i = 0; i < maxEntryCount; i++) {
        float start = fromX;
        fromX += groupSpaceWidthHalf;

        for (IBarDataSet set : barData.getDataSets()) {
            fromX += barWidthHalf;
            if (i < set.getEntryCount()) {
                BarEntry entry = set.getEntryForIndex(i);
                if (entry != null) {
                    entry.setX(fromX);
                }
            }
            fromX += barWidthHalf;
        }

        fromX += groupSpaceWidthHalf;
        float end = fromX;
        float innerInterval = end - start;
        float diff = interval - innerInterval;

        // correct rounding errors
        if (diff > 0 || diff < 0) {
            fromX += diff;
        }
    }
    barData.notifyDataChanged();
}
 
开发者ID:google,项目名称:walt,代码行数:40,代码来源:HistogramChart.java

示例4: groupBars

import com.github.mikephil.charting.interfaces.datasets.IBarDataSet; //导入方法依赖的package包/类
/**
 * Groups all BarDataSet objects this data object holds together by modifying the x-value of their entries.
 * Previously set x-values of entries will be overwritten. Leaves space between bars and groups as specified
 * by the parameters.
 * Do not forget to call notifyDataSetChanged() on your BarChart object after calling this method.
 *
 * @param fromX      the starting point on the x-axis where the grouping should begin
 * @param groupSpace the space between groups of bars in values (not pixels) e.g. 0.8f for bar width 1f
 * @param barSpace   the space between individual bars in values (not pixels) e.g. 0.1f for bar width 1f
 */
public void groupBars(float fromX, float groupSpace, float barSpace) {

    int setCount = mDataSets.size();
    if (setCount <= 1) {
        throw new RuntimeException("BarData needs to hold at least 2 BarDataSets to allow grouping.");
    }

    IBarDataSet max = getMaxEntryCountSet();
    int maxEntryCount = max.getEntryCount();

    float groupSpaceWidthHalf = groupSpace / 2f;
    float barSpaceHalf = barSpace / 2f;
    float barWidthHalf = mBarWidth / 2f;

    float interval = getGroupWidth(groupSpace, barSpace);

    for (int i = 0; i < maxEntryCount; i++) {

        float start = fromX;
        fromX += groupSpaceWidthHalf;

        for (IBarDataSet set : mDataSets) {

            fromX += barSpaceHalf;
            fromX += barWidthHalf;

            if (i < set.getEntryCount()) {

                BarEntry entry = set.getEntryForIndex(i);

                if (entry != null) {
                    entry.setX(fromX);
                }
            }

            fromX += barWidthHalf;
            fromX += barSpaceHalf;
        }

        fromX += groupSpaceWidthHalf;
        float end = fromX;
        float innerInterval = end - start;
        float diff = interval - innerInterval;

        // correct rounding errors
        if (diff > 0 || diff < 0) {
            fromX += diff;
        }
    }

    notifyDataChanged();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:63,代码来源:BarData.java

示例5: groupBars

import com.github.mikephil.charting.interfaces.datasets.IBarDataSet; //导入方法依赖的package包/类
/**
 * Groups all BarDataSet objects this data object holds together by modifying the x-position of their entries.
 * Previously set x-positions of entries will be overwritten. Leaves space between bars and groups as specified
 * by the parameters.
 * Do not forget to call notifyDataSetChanged() on your BarChart object after calling this method.
 *
 * @param fromX      the starting point on the x-axis where the grouping should begin
 * @param groupSpace the space between groups of bars in values (not pixels) e.g. 0.8f for bar width 1f
 * @param barSpace   the space between individual bars in values (not pixels) e.g. 0.1f for bar width 1f
 */
public void groupBars(float fromX, float groupSpace, float barSpace) {

    int setCount = mDataSets.size();
    if (setCount <= 1) {
        throw new RuntimeException("BarData needs to hold at least 2 BarDataSets to allow grouping.");
    }

    IBarDataSet max = getMaxEntryCountSet();
    int maxEntryCount = max.getEntryCount();

    float groupSpaceWidthHalf = groupSpace / 2f;
    float barSpaceHalf = barSpace / 2f;
    float barWidthHalf = mBarWidth / 2f;

    float interval = getGroupWidth(groupSpace, barSpace);

    for (int i = 0; i < maxEntryCount; i++) {

        float start = fromX;
        fromX += groupSpaceWidthHalf;

        IBarDataSet set;
        final int setCountJ = mDataSets.size();
        for(int j = 0 ; j < setCountJ ; j++){
            set = mDataSets.get(j);

            fromX += barSpaceHalf;
            fromX += barWidthHalf;

            if (i < set.getEntryCount()) {

                BarEntry entry = set.getEntryForIndex(i);

                if (entry != null) {
                    entry.setX(fromX);
                }
            }

            fromX += barWidthHalf;
            fromX += barSpaceHalf;
        }

        fromX += groupSpaceWidthHalf;
        float end = fromX;
        float innerInterval = end - start;
        float diff = interval - innerInterval;

        // correct rounding errors
        if (diff > 0 || diff < 0) {
            fromX += diff;
        }
    }

    notifyDataChanged();
}
 
开发者ID:letolab,项目名称:LETO-Toggl_Android,代码行数:66,代码来源:BarData.java


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