com.github.mikephil.charting.highlight.Highlight.getXPx()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(130)

本文整理了Java中com.github.mikephil.charting.highlight.Highlight.getXPx()方法的一些代码示例,展示了Highlight.getXPx()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Highlight.getXPx()方法的具体详情如下:
包路径:com.github.mikephil.charting.highlight.Highlight
类名称:Highlight
方法名:getXPx

Highlight.getXPx介绍

[英]returns the x-position of the highlight in pixels
[中]返回高亮显示的x位置(以像素为单位)

代码示例

代码示例来源:origin: PhilJay/MPAndroidChart

  1. /**
  2. * Returns the Highlight of the DataSet that contains the closest value on the
  3. * y-axis.
  4. *
  5. * @param closestValues contains two Highlight objects per DataSet closest to the selected x-position (determined by
  6. * rounding up an down)
  7. * @param x
  8. * @param y
  9. * @param axis the closest axis
  10. * @param minSelectionDistance
  11. * @return
  12. */
  13. public Highlight getClosestHighlightByPixel(List<Highlight> closestValues, float x, float y,
  14. YAxis.AxisDependency axis, float minSelectionDistance) {
  15. Highlight closest = null;
  16. float distance = minSelectionDistance;
  17. for (int i = 0; i < closestValues.size(); i++) {
  18. Highlight high = closestValues.get(i);
  19. if (axis == null || high.getAxis() == axis) {
  20. float cDistance = getDistance(x, y, high.getXPx(), high.getYPx());
  21. if (cDistance < distance) {
  22. closest = high;
  23. distance = cDistance;
  24. }
  25. }
  26. }
  27. return closest;
  28. }

代码示例来源:origin: PhilJay/MPAndroidChart

  1. /**
  2. * Returns the Highlight object (contains x-index and DataSet index) of the selected value at the given touch
  3. * point
  4. * inside the CombinedChart.
  5. *
  6. * @param x
  7. * @param y
  8. * @return
  9. */
  10. @Override
  11. public Highlight getHighlightByTouchPoint(float x, float y) {
  12. if (mData == null) {
  13. Log.e(LOG_TAG, "Can't select by touch. No data set.");
  14. return null;
  15. } else {
  16. Highlight h = getHighlighter().getHighlight(x, y);
  17. if (h == null || !isHighlightFullBarEnabled()) return h;
  18. // For isHighlightFullBarEnabled, remove stackIndex
  19. return new Highlight(h.getX(), h.getY(),
  20. h.getXPx(), h.getYPx(),
  21. h.getDataSetIndex(), -1, h.getAxis());
  22. }
  23. }

代码示例来源:origin: PhilJay/MPAndroidChart

  1. /**
  2. * Returns the Highlight object (contains x-index and DataSet index) of the selected value at the given touch
  3. * point
  4. * inside the BarChart.
  5. *
  6. * @param x
  7. * @param y
  8. * @return
  9. */
  10. @Override
  11. public Highlight getHighlightByTouchPoint(float x, float y) {
  12. if (mData == null) {
  13. Log.e(LOG_TAG, "Can't select by touch. No data set.");
  14. return null;
  15. } else {
  16. Highlight h = getHighlighter().getHighlight(x, y);
  17. if (h == null || !isHighlightFullBarEnabled()) return h;
  18. // For isHighlightFullBarEnabled, remove stackIndex
  19. return new Highlight(h.getX(), h.getY(),
  20. h.getXPx(), h.getYPx(),
  21. h.getDataSetIndex(), -1, h.getAxis());
  22. }
  23. }

代码示例来源:origin: xiaolongonly/Ticket-Analysis

  1. /**
  2. * Returns the Highlight of the DataSet that contains the closest value on the
  3. * y-axis.
  4. *
  5. * @param closestValues contains two Highlight objects per DataSet closest to the selected x-position (determined by
  6. * rounding up an down)
  7. * @param x
  8. * @param y
  9. * @param axis the closest axis
  10. * @param minSelectionDistance
  11. * @return
  12. */
  13. public Highlight getClosestHighlightByPixel(List<Highlight> closestValues, float x, float y,
  14. YAxis.AxisDependency axis, float minSelectionDistance) {
  15. Highlight closest = null;
  16. float distance = minSelectionDistance;
  17. for (int i = 0; i < closestValues.size(); i++) {
  18. Highlight high = closestValues.get(i);
  19. if (axis == null || high.getAxis() == axis) {
  20. float cDistance = getDistance(x, y, high.getXPx(), high.getYPx());
  21. if (cDistance < distance) {
  22. closest = high;
  23. distance = cDistance;
  24. }
  25. }
  26. }
  27. return closest;
  28. }

代码示例来源:origin: WenWangAndroid/ChartManager

  1. /**
  2. * Returns the Highlight of the DataSet that contains the closest value on the
  3. * y-axis.
  4. *
  5. * @param closestValues contains two Highlight objects per DataSet closest to the selected x-position (determined by
  6. * rounding up an down)
  7. * @param x
  8. * @param y
  9. * @param axis the closest axis
  10. * @param minSelectionDistance
  11. * @return
  12. */
  13. public Highlight getClosestHighlightByPixel(List<Highlight> closestValues, float x, float y,
  14. YAxis.AxisDependency axis, float minSelectionDistance) {
  15. Highlight closest = null;
  16. float distance = minSelectionDistance;
  17. for (int i = 0; i < closestValues.size(); i++) {
  18. Highlight high = closestValues.get(i);
  19. if (axis == null || high.getAxis() == axis) {
  20. float cDistance = getDistance(x, y, high.getXPx(), high.getYPx());
  21. if (cDistance < distance) {
  22. closest = high;
  23. distance = cDistance;
  24. }
  25. }
  26. }
  27. return closest;
  28. }

代码示例来源:origin: com.github.PhilJay/MPAndroidChart

  1. /**
  2. * Returns the Highlight of the DataSet that contains the closest value on the
  3. * y-axis.
  4. *
  5. * @param closestValues contains two Highlight objects per DataSet closest to the selected x-position (determined by
  6. * rounding up an down)
  7. * @param x
  8. * @param y
  9. * @param axis the closest axis
  10. * @param minSelectionDistance
  11. * @return
  12. */
  13. public Highlight getClosestHighlightByPixel(List<Highlight> closestValues, float x, float y,
  14. YAxis.AxisDependency axis, float minSelectionDistance) {
  15. Highlight closest = null;
  16. float distance = minSelectionDistance;
  17. for (int i = 0; i < closestValues.size(); i++) {
  18. Highlight high = closestValues.get(i);
  19. if (axis == null || high.getAxis() == axis) {
  20. float cDistance = getDistance(x, y, high.getXPx(), high.getYPx());
  21. if (cDistance < distance) {
  22. closest = high;
  23. distance = cDistance;
  24. }
  25. }
  26. }
  27. return closest;
  28. }

代码示例来源:origin: WallaceXiao/StockChart-MPAndroidChart

  1. /**
  2. * Returns the Highlight of the DataSet that contains the closest value on the
  3. * y-axis.
  4. *
  5. * @param closestValues contains two Highlight objects per DataSet closest to the selected x-position (determined by
  6. * rounding up an down)
  7. * @param x
  8. * @param y
  9. * @param axis the closest axis
  10. * @param minSelectionDistance
  11. * @return
  12. */
  13. public Highlight getClosestHighlightByPixel(List<Highlight> closestValues, float x, float y,
  14. YAxis.AxisDependency axis, float minSelectionDistance) {
  15. Highlight closest = null;
  16. float distance = minSelectionDistance;
  17. for (int i = 0; i < closestValues.size(); i++) {
  18. Highlight high = closestValues.get(i);
  19. if (axis == null || high.getAxis() == axis) {
  20. float cDistance = getDistance(x, y, high.getXPx(), high.getYPx());
  21. if (cDistance < distance) {
  22. closest = high;
  23. distance = cDistance;
  24. }
  25. }
  26. }
  27. return closest;
  28. }

代码示例来源:origin: WenWangAndroid/ChartManager

  1. /**
  2. * Returns the Highlight object (contains x-index and DataSet index) of the selected value at the given touch
  3. * point
  4. * inside the BarChart.
  5. *
  6. * @param x
  7. * @param y
  8. * @return
  9. */
  10. @Override
  11. public Highlight getHighlightByTouchPoint(float x, float y) {
  12. if (mData == null) {
  13. Log.e(LOG_TAG, "Can't select by touch. No data set.");
  14. return null;
  15. } else {
  16. Highlight h = getHighlighter().getHighlight(x, y);
  17. if (h == null || !isHighlightFullBarEnabled()) return h;
  18. // For isHighlightFullBarEnabled, remove stackIndex
  19. return new Highlight(h.getX(), h.getY(),
  20. h.getXPx(), h.getYPx(),
  21. h.getDataSetIndex(), -1, h.getAxis());
  22. }
  23. }

代码示例来源:origin: xiaolongonly/Ticket-Analysis

  1. /**
  2. * Returns the Highlight object (contains x-index and DataSet index) of the selected value at the given touch
  3. * point
  4. * inside the BarChart.
  5. *
  6. * @param x
  7. * @param y
  8. * @return
  9. */
  10. @Override
  11. public Highlight getHighlightByTouchPoint(float x, float y) {
  12. if (mData == null) {
  13. Log.e(LOG_TAG, "Can't select by touch. No data set.");
  14. return null;
  15. } else {
  16. Highlight h = getHighlighter().getHighlight(x, y);
  17. if (h == null || !isHighlightFullBarEnabled()) return h;
  18. // For isHighlightFullBarEnabled, remove stackIndex
  19. return new Highlight(h.getX(), h.getY(),
  20. h.getXPx(), h.getYPx(),
  21. h.getDataSetIndex(), -1, h.getAxis());
  22. }
  23. }

代码示例来源:origin: WallaceXiao/StockChart-MPAndroidChart

  1. /**
  2. * Returns the Highlight object (contains x-index and DataSet index) of the selected value at the given touch
  3. * point
  4. * inside the BarChart.
  5. *
  6. * @param x
  7. * @param y
  8. * @return
  9. */
  10. @Override
  11. public Highlight getHighlightByTouchPoint(float x, float y) {
  12. if (mData == null) {
  13. Log.e(LOG_TAG, "Can't select by touch. No data set.");
  14. return null;
  15. } else {
  16. Highlight h = getHighlighter().getHighlight(x, y);
  17. if (h == null || !isHighlightFullBarEnabled()) {
  18. return h;
  19. }
  20. // For isHighlightFullBarEnabled, remove stackIndex
  21. return new Highlight(h.getX(), h.getY(),
  22. h.getXPx(), h.getYPx(),
  23. h.getDataSetIndex(), -1, h.getAxis());
  24. }
  25. }

代码示例来源:origin: com.github.PhilJay/MPAndroidChart

  1. /**
  2. * Returns the Highlight object (contains x-index and DataSet index) of the selected value at the given touch
  3. * point
  4. * inside the BarChart.
  5. *
  6. * @param x
  7. * @param y
  8. * @return
  9. */
  10. @Override
  11. public Highlight getHighlightByTouchPoint(float x, float y) {
  12. if (mData == null) {
  13. Log.e(LOG_TAG, "Can't select by touch. No data set.");
  14. return null;
  15. } else {
  16. Highlight h = getHighlighter().getHighlight(x, y);
  17. if (h == null || !isHighlightFullBarEnabled()) return h;
  18. // For isHighlightFullBarEnabled, remove stackIndex
  19. return new Highlight(h.getX(), h.getY(),
  20. h.getXPx(), h.getYPx(),
  21. h.getDataSetIndex(), -1, h.getAxis());
  22. }
  23. }

代码示例来源:origin: com.github.PhilJay/MPAndroidChart

  1. /**
  2. * Returns the Highlight object (contains x-index and DataSet index) of the selected value at the given touch
  3. * point
  4. * inside the CombinedChart.
  5. *
  6. * @param x
  7. * @param y
  8. * @return
  9. */
  10. @Override
  11. public Highlight getHighlightByTouchPoint(float x, float y) {
  12. if (mData == null) {
  13. Log.e(LOG_TAG, "Can't select by touch. No data set.");
  14. return null;
  15. } else {
  16. Highlight h = getHighlighter().getHighlight(x, y);
  17. if (h == null || !isHighlightFullBarEnabled()) return h;
  18. // For isHighlightFullBarEnabled, remove stackIndex
  19. return new Highlight(h.getX(), h.getY(),
  20. h.getXPx(), h.getYPx(),
  21. h.getDataSetIndex(), -1, h.getAxis());
  22. }
  23. }

代码示例来源:origin: xiaolongonly/Ticket-Analysis

  1. /**
  2. * Returns the Highlight object (contains x-index and DataSet index) of the selected value at the given touch
  3. * point
  4. * inside the CombinedChart.
  5. *
  6. * @param x
  7. * @param y
  8. * @return
  9. */
  10. @Override
  11. public Highlight getHighlightByTouchPoint(float x, float y) {
  12. if (mData == null) {
  13. Log.e(LOG_TAG, "Can't select by touch. No data set.");
  14. return null;
  15. } else {
  16. Highlight h = getHighlighter().getHighlight(x, y);
  17. if (h == null || !isHighlightFullBarEnabled()) return h;
  18. // For isHighlightFullBarEnabled, remove stackIndex
  19. return new Highlight(h.getX(), h.getY(),
  20. h.getXPx(), h.getYPx(),
  21. h.getDataSetIndex(), -1, h.getAxis());
  22. }
  23. }

代码示例来源:origin: WenWangAndroid/ChartManager

  1. /**
  2. * Returns the Highlight object (contains x-index and DataSet index) of the selected value at the given touch
  3. * point
  4. * inside the CombinedChart.
  5. *
  6. * @param x
  7. * @param y
  8. * @return
  9. */
  10. @Override
  11. public Highlight getHighlightByTouchPoint(float x, float y) {
  12. if (mData == null) {
  13. Log.e(LOG_TAG, "Can't select by touch. No data set.");
  14. return null;
  15. } else {
  16. Highlight h = getHighlighter().getHighlight(x, y);
  17. if (h == null || !isHighlightFullBarEnabled()) return h;
  18. // For isHighlightFullBarEnabled, remove stackIndex
  19. return new Highlight(h.getX(), h.getY(),
  20. h.getXPx(), h.getYPx(),
  21. h.getDataSetIndex(), -1, h.getAxis());
  22. }
  23. }

代码示例来源:origin: WallaceXiao/StockChart-MPAndroidChart

  1. /**
  2. * Returns the Highlight object (contains x-index and DataSet index) of the selected value at the given touch
  3. * point
  4. * inside the CombinedChart.
  5. *
  6. * @param x
  7. * @param y
  8. * @return
  9. */
  10. @Override
  11. public Highlight getHighlightByTouchPoint(float x, float y) {
  12. if (mData == null) {
  13. Log.e(LOG_TAG, "Can't select by touch. No data set.");
  14. return null;
  15. } else {
  16. Highlight h = getHighlighter().getHighlight(x, y);
  17. if (h == null || !isHighlightFullBarEnabled()) {
  18. return h;
  19. }
  20. // For isHighlightFullBarEnabled, remove stackIndex
  21. return new Highlight(h.getX(), h.getY(),
  22. h.getXPx(), h.getYPx(),
  23. h.getDataSetIndex(), -1, h.getAxis());
  24. }
  25. }

相关文章