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

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

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

Highlight.getAxis介绍

[英]Returns the axis the highlighted value belongs to.
[中]返回高亮显示的值所属的轴。

代码示例

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

/**
 * Returns the minimum distance from a touch value (in pixels) to the
 * closest value (in pixels) that is displayed in the chart.
 *
 * @param closestValues
 * @param pos
 * @param axis
 * @return
 */
protected float getMinimumDistance(List<Highlight> closestValues, float pos, YAxis.AxisDependency axis) {
  float distance = Float.MAX_VALUE;
  for (int i = 0; i < closestValues.size(); i++) {
    Highlight high = closestValues.get(i);
    if (high.getAxis() == axis) {
      float tempDistance = Math.abs(getHighlightPos(high) - pos);
      if (tempDistance < distance) {
        distance = tempDistance;
      }
    }
  }
  return distance;
}

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

/**
 * Returns the Highlight of the DataSet that contains the closest value on the
 * y-axis.
 *
 * @param closestValues        contains two Highlight objects per DataSet closest to the selected x-position (determined by
 *                             rounding up an down)
 * @param x
 * @param y
 * @param axis                 the closest axis
 * @param minSelectionDistance
 * @return
 */
public Highlight getClosestHighlightByPixel(List<Highlight> closestValues, float x, float y,
                      YAxis.AxisDependency axis, float minSelectionDistance) {
  Highlight closest = null;
  float distance = minSelectionDistance;
  for (int i = 0; i < closestValues.size(); i++) {
    Highlight high = closestValues.get(i);
    if (axis == null || high.getAxis() == axis) {
      float cDistance = getDistance(x, y, high.getXPx(), high.getYPx());
      if (cDistance < distance) {
        closest = high;
        distance = cDistance;
      }
    }
  }
  return closest;
}

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

/**
 * Returns the Highlight object (contains x-index and DataSet index) of the selected value at the given touch
 * point
 * inside the CombinedChart.
 *
 * @param x
 * @param y
 * @return
 */
@Override
public Highlight getHighlightByTouchPoint(float x, float y) {
  if (mData == null) {
    Log.e(LOG_TAG, "Can't select by touch. No data set.");
    return null;
  } else {
    Highlight h = getHighlighter().getHighlight(x, y);
    if (h == null || !isHighlightFullBarEnabled()) return h;
    // For isHighlightFullBarEnabled, remove stackIndex
    return new Highlight(h.getX(), h.getY(),
        h.getXPx(), h.getYPx(),
        h.getDataSetIndex(), -1, h.getAxis());
  }
}

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

/**
 * Returns the Highlight object (contains x-index and DataSet index) of the selected value at the given touch
 * point
 * inside the BarChart.
 *
 * @param x
 * @param y
 * @return
 */
@Override
public Highlight getHighlightByTouchPoint(float x, float y) {
  if (mData == null) {
    Log.e(LOG_TAG, "Can't select by touch. No data set.");
    return null;
  } else {
    Highlight h = getHighlighter().getHighlight(x, y);
    if (h == null || !isHighlightFullBarEnabled()) return h;
    // For isHighlightFullBarEnabled, remove stackIndex
    return new Highlight(h.getX(), h.getY(),
        h.getXPx(), h.getYPx(),
        h.getDataSetIndex(), -1, h.getAxis());
  }
}

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

high.getDataSetIndex(),
    stackIndex,
    high.getAxis()
);

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

/**
 * Returns the minimum distance from a touch value (in pixels) to the
 * closest value (in pixels) that is displayed in the chart.
 *
 * @param closestValues
 * @param pos
 * @param axis
 * @return
 */
protected float getMinimumDistance(List<Highlight> closestValues, float pos, YAxis.AxisDependency axis) {
  float distance = Float.MAX_VALUE;
  for (int i = 0; i < closestValues.size(); i++) {
    Highlight high = closestValues.get(i);
    if (high.getAxis() == axis) {
      float tempDistance = Math.abs(getHighlightPos(high) - pos);
      if (tempDistance < distance) {
        distance = tempDistance;
      }
    }
  }
  return distance;
}

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

/**
 * Returns the minimum distance from a touch value (in pixels) to the
 * closest value (in pixels) that is displayed in the chart.
 *
 * @param closestValues
 * @param pos
 * @param axis
 * @return
 */
protected float getMinimumDistance(List<Highlight> closestValues, float pos, YAxis.AxisDependency axis) {
  float distance = Float.MAX_VALUE;
  for (int i = 0; i < closestValues.size(); i++) {
    Highlight high = closestValues.get(i);
    if (high.getAxis() == axis) {
      float tempDistance = Math.abs(getHighlightPos(high) - pos);
      if (tempDistance < distance) {
        distance = tempDistance;
      }
    }
  }
  return distance;
}

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

/**
 * Returns the minimum distance from a touch value (in pixels) to the
 * closest value (in pixels) that is displayed in the chart.
 *
 * @param closestValues
 * @param pos
 * @param axis
 * @return
 */
protected float getMinimumDistance(List<Highlight> closestValues, float pos, YAxis.AxisDependency axis) {
  float distance = Float.MAX_VALUE;
  for (int i = 0; i < closestValues.size(); i++) {
    Highlight high = closestValues.get(i);
    if (high.getAxis() == axis) {
      float tempDistance = Math.abs(getHighlightPos(high) - pos);
      if (tempDistance < distance) {
        distance = tempDistance;
      }
    }
  }
  return distance;
}

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

/**
 * Returns the minimum distance from a touch value (in pixels) to the
 * closest value (in pixels) that is displayed in the chart.
 *
 * @param closestValues
 * @param pos
 * @param axis
 * @return
 */
protected float getMinimumDistance(List<Highlight> closestValues, float pos, YAxis.AxisDependency axis) {
  float distance = Float.MAX_VALUE;
  for (int i = 0; i < closestValues.size(); i++) {
    Highlight high = closestValues.get(i);
    if (high.getAxis() == axis) {
      float tempDistance = Math.abs(getHighlightPos(high) - pos);
      if (tempDistance < distance) {
        distance = tempDistance;
      }
    }
  }
  return distance;
}

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

/**
 * Returns the Highlight of the DataSet that contains the closest value on the
 * y-axis.
 *
 * @param closestValues        contains two Highlight objects per DataSet closest to the selected x-position (determined by
 *                             rounding up an down)
 * @param x
 * @param y
 * @param axis                 the closest axis
 * @param minSelectionDistance
 * @return
 */
public Highlight getClosestHighlightByPixel(List<Highlight> closestValues, float x, float y,
                      YAxis.AxisDependency axis, float minSelectionDistance) {
  Highlight closest = null;
  float distance = minSelectionDistance;
  for (int i = 0; i < closestValues.size(); i++) {
    Highlight high = closestValues.get(i);
    if (axis == null || high.getAxis() == axis) {
      float cDistance = getDistance(x, y, high.getXPx(), high.getYPx());
      if (cDistance < distance) {
        closest = high;
        distance = cDistance;
      }
    }
  }
  return closest;
}

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

/**
 * Returns the Highlight of the DataSet that contains the closest value on the
 * y-axis.
 *
 * @param closestValues        contains two Highlight objects per DataSet closest to the selected x-position (determined by
 *                             rounding up an down)
 * @param x
 * @param y
 * @param axis                 the closest axis
 * @param minSelectionDistance
 * @return
 */
public Highlight getClosestHighlightByPixel(List<Highlight> closestValues, float x, float y,
                      YAxis.AxisDependency axis, float minSelectionDistance) {
  Highlight closest = null;
  float distance = minSelectionDistance;
  for (int i = 0; i < closestValues.size(); i++) {
    Highlight high = closestValues.get(i);
    if (axis == null || high.getAxis() == axis) {
      float cDistance = getDistance(x, y, high.getXPx(), high.getYPx());
      if (cDistance < distance) {
        closest = high;
        distance = cDistance;
      }
    }
  }
  return closest;
}

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

/**
 * Returns the Highlight of the DataSet that contains the closest value on the
 * y-axis.
 *
 * @param closestValues        contains two Highlight objects per DataSet closest to the selected x-position (determined by
 *                             rounding up an down)
 * @param x
 * @param y
 * @param axis                 the closest axis
 * @param minSelectionDistance
 * @return
 */
public Highlight getClosestHighlightByPixel(List<Highlight> closestValues, float x, float y,
                      YAxis.AxisDependency axis, float minSelectionDistance) {
  Highlight closest = null;
  float distance = minSelectionDistance;
  for (int i = 0; i < closestValues.size(); i++) {
    Highlight high = closestValues.get(i);
    if (axis == null || high.getAxis() == axis) {
      float cDistance = getDistance(x, y, high.getXPx(), high.getYPx());
      if (cDistance < distance) {
        closest = high;
        distance = cDistance;
      }
    }
  }
  return closest;
}

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

/**
 * Returns the Highlight of the DataSet that contains the closest value on the
 * y-axis.
 *
 * @param closestValues        contains two Highlight objects per DataSet closest to the selected x-position (determined by
 *                             rounding up an down)
 * @param x
 * @param y
 * @param axis                 the closest axis
 * @param minSelectionDistance
 * @return
 */
public Highlight getClosestHighlightByPixel(List<Highlight> closestValues, float x, float y,
                      YAxis.AxisDependency axis, float minSelectionDistance) {
  Highlight closest = null;
  float distance = minSelectionDistance;
  for (int i = 0; i < closestValues.size(); i++) {
    Highlight high = closestValues.get(i);
    if (axis == null || high.getAxis() == axis) {
      float cDistance = getDistance(x, y, high.getXPx(), high.getYPx());
      if (cDistance < distance) {
        closest = high;
        distance = cDistance;
      }
    }
  }
  return closest;
}

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

/**
 * Returns the Highlight object (contains x-index and DataSet index) of the selected value at the given touch
 * point
 * inside the BarChart.
 *
 * @param x
 * @param y
 * @return
 */
@Override
public Highlight getHighlightByTouchPoint(float x, float y) {
  if (mData == null) {
    Log.e(LOG_TAG, "Can't select by touch. No data set.");
    return null;
  } else {
    Highlight h = getHighlighter().getHighlight(x, y);
    if (h == null || !isHighlightFullBarEnabled()) return h;
    // For isHighlightFullBarEnabled, remove stackIndex
    return new Highlight(h.getX(), h.getY(),
        h.getXPx(), h.getYPx(),
        h.getDataSetIndex(), -1, h.getAxis());
  }
}

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

/**
 * Returns the Highlight object (contains x-index and DataSet index) of the selected value at the given touch
 * point
 * inside the BarChart.
 *
 * @param x
 * @param y
 * @return
 */
@Override
public Highlight getHighlightByTouchPoint(float x, float y) {
  if (mData == null) {
    Log.e(LOG_TAG, "Can't select by touch. No data set.");
    return null;
  } else {
    Highlight h = getHighlighter().getHighlight(x, y);
    if (h == null || !isHighlightFullBarEnabled()) return h;
    // For isHighlightFullBarEnabled, remove stackIndex
    return new Highlight(h.getX(), h.getY(),
        h.getXPx(), h.getYPx(),
        h.getDataSetIndex(), -1, h.getAxis());
  }
}

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

/**
 * Returns the Highlight object (contains x-index and DataSet index) of the selected value at the given touch
 * point
 * inside the BarChart.
 *
 * @param x
 * @param y
 * @return
 */
@Override
public Highlight getHighlightByTouchPoint(float x, float y) {
  if (mData == null) {
    Log.e(LOG_TAG, "Can't select by touch. No data set.");
    return null;
  } else {
    Highlight h = getHighlighter().getHighlight(x, y);
    if (h == null || !isHighlightFullBarEnabled()) {
      return h;
    }
    // For isHighlightFullBarEnabled, remove stackIndex
    return new Highlight(h.getX(), h.getY(),
        h.getXPx(), h.getYPx(),
        h.getDataSetIndex(), -1, h.getAxis());
  }
}

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

/**
 * Returns the Highlight object (contains x-index and DataSet index) of the selected value at the given touch
 * point
 * inside the BarChart.
 *
 * @param x
 * @param y
 * @return
 */
@Override
public Highlight getHighlightByTouchPoint(float x, float y) {
  if (mData == null) {
    Log.e(LOG_TAG, "Can't select by touch. No data set.");
    return null;
  } else {
    Highlight h = getHighlighter().getHighlight(x, y);
    if (h == null || !isHighlightFullBarEnabled()) return h;
    // For isHighlightFullBarEnabled, remove stackIndex
    return new Highlight(h.getX(), h.getY(),
        h.getXPx(), h.getYPx(),
        h.getDataSetIndex(), -1, h.getAxis());
  }
}

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

/**
 * Returns the Highlight object (contains x-index and DataSet index) of the selected value at the given touch
 * point
 * inside the CombinedChart.
 *
 * @param x
 * @param y
 * @return
 */
@Override
public Highlight getHighlightByTouchPoint(float x, float y) {
  if (mData == null) {
    Log.e(LOG_TAG, "Can't select by touch. No data set.");
    return null;
  } else {
    Highlight h = getHighlighter().getHighlight(x, y);
    if (h == null || !isHighlightFullBarEnabled()) return h;
    // For isHighlightFullBarEnabled, remove stackIndex
    return new Highlight(h.getX(), h.getY(),
        h.getXPx(), h.getYPx(),
        h.getDataSetIndex(), -1, h.getAxis());
  }
}

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

/**
 * Returns the Highlight object (contains x-index and DataSet index) of the selected value at the given touch
 * point
 * inside the CombinedChart.
 *
 * @param x
 * @param y
 * @return
 */
@Override
public Highlight getHighlightByTouchPoint(float x, float y) {
  if (mData == null) {
    Log.e(LOG_TAG, "Can't select by touch. No data set.");
    return null;
  } else {
    Highlight h = getHighlighter().getHighlight(x, y);
    if (h == null || !isHighlightFullBarEnabled()) return h;
    // For isHighlightFullBarEnabled, remove stackIndex
    return new Highlight(h.getX(), h.getY(),
        h.getXPx(), h.getYPx(),
        h.getDataSetIndex(), -1, h.getAxis());
  }
}

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

/**
 * Returns the Highlight object (contains x-index and DataSet index) of the selected value at the given touch
 * point
 * inside the CombinedChart.
 *
 * @param x
 * @param y
 * @return
 */
@Override
public Highlight getHighlightByTouchPoint(float x, float y) {
  if (mData == null) {
    Log.e(LOG_TAG, "Can't select by touch. No data set.");
    return null;
  } else {
    Highlight h = getHighlighter().getHighlight(x, y);
    if (h == null || !isHighlightFullBarEnabled()) return h;
    // For isHighlightFullBarEnabled, remove stackIndex
    return new Highlight(h.getX(), h.getY(),
        h.getXPx(), h.getYPx(),
        h.getDataSetIndex(), -1, h.getAxis());
  }
}

相关文章