當前位置: 首頁>>代碼示例>>Java>>正文


Java BarEntry.getX方法代碼示例

本文整理匯總了Java中com.github.mikephil.charting.data.BarEntry.getX方法的典型用法代碼示例。如果您正苦於以下問題:Java BarEntry.getX方法的具體用法?Java BarEntry.getX怎麽用?Java BarEntry.getX使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.github.mikephil.charting.data.BarEntry的用法示例。


在下文中一共展示了BarEntry.getX方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: 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

示例3: getStackedHighlight

import com.github.mikephil.charting.data.BarEntry; //導入方法依賴的package包/類
/**
 * This method creates the Highlight object that also indicates which value of a stacked BarEntry has been
 * selected.
 *
 * @param high the Highlight to work with looking for stacked values
 * @param set
 * @param xVal
 * @param yVal
 * @return
 */
public Highlight getStackedHighlight(Highlight high, IBarDataSet set, float xVal, float yVal) {

    BarEntry entry = set.getEntryForXValue(xVal, yVal);

    if (entry == null)
        return null;

    // not stacked
    if (entry.getYVals() == null) {
        return high;
    } else {
        Range[] ranges = entry.getRanges();

        if (ranges.length > 0) {
            int stackIndex = getClosestStackIndex(ranges, yVal);

            MPPointD pixels = mChart.getTransformer(set.getAxisDependency()).getPixelForValues(high.getX(), ranges[stackIndex].to);

            Highlight stackedHigh = new Highlight(
                    entry.getX(),
                    entry.getY(),
                    (float) pixels.x,
                    (float) pixels.y,
                    high.getDataSetIndex(),
                    stackIndex,
                    high.getAxis()
            );

            MPPointD.recycleInstance(pixels);

            return stackedHigh;
        }
    }

    return null;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:47,代碼來源:BarHighlighter.java

示例4: getStackedHighlight

import com.github.mikephil.charting.data.BarEntry; //導入方法依賴的package包/類
/**
 * This method creates the Highlight object that also indicates which value of a stacked BarEntry has been
 * selected.
 *
 * @param high the Highlight to work with looking for stacked values
 * @param set
 * @param xVal
 * @param yVal
 * @return
 */
public Highlight getStackedHighlight(Highlight high, IBarDataSet set, float xVal, float yVal) {

    BarEntry entry = set.getEntryForXPos(xVal);

    if (entry == null)
        return null;

    // not stacked
    if (entry.getYVals() == null) {
        return high;
    } else {
        Range[] ranges = entry.getRanges();

        if (ranges.length > 0) {
            int stackIndex = getClosestStackIndex(ranges, yVal);

            MPPointD pixels = mChart.getTransformer(set.getAxisDependency()).getPixelsForValues(high.getX(), ranges[stackIndex].to);

            Highlight stackedHigh = new Highlight(
                    entry.getX(),
                    entry.getY(),
                    (float) pixels.x,
                    (float) pixels.y,
                    high.getDataSetIndex(),
                    stackIndex,
                    high.getAxis()
            );

            MPPointD.recycleInstance(pixels);

            return stackedHigh;
        }
    }

    return null;
}
 
開發者ID:letolab,項目名稱:LETO-Toggl_Android,代碼行數:47,代碼來源:BarHighlighter.java


注:本文中的com.github.mikephil.charting.data.BarEntry.getX方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。