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

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

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

Highlight.setDataIndex介绍

暂无

代码示例

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

@Override
protected List<Highlight> getHighlightsAtXValue(float xVal, float x, float y) {
  mHighlightBuffer.clear();
  List<BarLineScatterCandleBubbleData> dataObjects = mChart.getCombinedData().getAllData();
  for (int i = 0; i < dataObjects.size(); i++) {
    ChartData dataObject = dataObjects.get(i);
    // in case of BarData, let the BarHighlighter take over
    if (barHighlighter != null && dataObject instanceof BarData) {
      Highlight high = barHighlighter.getHighlight(x, y);
      if (high != null) {
        high.setDataIndex(i);
        mHighlightBuffer.add(high);
      }
    } else {
      for (int j = 0, dataSetCount = dataObject.getDataSetCount(); j < dataSetCount; j++) {
        IDataSet dataSet = dataObjects.get(i).getDataSetByIndex(j);
        // don't include datasets that cannot be highlighted
        if (!dataSet.isHighlightEnabled())
          continue;
        List<Highlight> highs = buildHighlights(dataSet, j, xVal, DataSet.Rounding.CLOSEST);
        for (Highlight high : highs)
        {
          high.setDataIndex(i);
          mHighlightBuffer.add(high);
        }
      }
    }
  }
  return mHighlightBuffer;
}

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

@Override
protected List<Highlight> getHighlightsAtXValue(float xVal, float x, float y) {
  mHighlightBuffer.clear();
  List<BarLineScatterCandleBubbleData> dataObjects = mChart.getCombinedData().getAllData();
  for (int i = 0; i < dataObjects.size(); i++) {
    ChartData dataObject = dataObjects.get(i);
    // in case of BarData, let the BarHighlighter take over
    if (barHighlighter != null && dataObject instanceof BarData) {
      Highlight high = barHighlighter.getHighlight(x, y);
      if (high != null) {
        high.setDataIndex(i);
        mHighlightBuffer.add(high);
      }
    } else {
      for (int j = 0, dataSetCount = dataObject.getDataSetCount(); j < dataSetCount; j++) {
        IDataSet dataSet = dataObjects.get(i).getDataSetByIndex(j);
        // don't include datasets that cannot be highlighted
        if (!dataSet.isHighlightEnabled())
          continue;
        List<Highlight> highs = buildHighlights(dataSet, j, xVal, DataSet.Rounding.CLOSEST);
        for (Highlight high : highs)
        {
          high.setDataIndex(i);
          mHighlightBuffer.add(high);
        }
      }
    }
  }
  return mHighlightBuffer;
}

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

@Override
protected List<Highlight> getHighlightsAtXValue(float xVal, float x, float y) {
  mHighlightBuffer.clear();
  List<BarLineScatterCandleBubbleData> dataObjects = mChart.getCombinedData().getAllData();
  for (int i = 0; i < dataObjects.size(); i++) {
    ChartData dataObject = dataObjects.get(i);
    // in case of BarData, let the BarHighlighter take over
    if (barHighlighter != null && dataObject instanceof BarData) {
      Highlight high = barHighlighter.getHighlight(x, y);
      if (high != null) {
        high.setDataIndex(i);
        mHighlightBuffer.add(high);
      }
    } else {
      for (int j = 0, dataSetCount = dataObject.getDataSetCount(); j < dataSetCount; j++) {
        IDataSet dataSet = dataObjects.get(i).getDataSetByIndex(j);
        // don't include datasets that cannot be highlighted
        if (!dataSet.isHighlightEnabled())
          continue;
        List<Highlight> highs = buildHighlights(dataSet, j, xVal, DataSet.Rounding.CLOSEST);
        for (Highlight high : highs)
        {
          high.setDataIndex(i);
          mHighlightBuffer.add(high);
        }
      }
    }
  }
  return mHighlightBuffer;
}

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

@Override
protected List<Highlight> getHighlightsAtXValue(float xVal, float x, float y) {
  mHighlightBuffer.clear();
  List<BarLineScatterCandleBubbleData> dataObjects = mChart.getCombinedData().getAllData();
  for (int i = 0; i < dataObjects.size(); i++) {
    ChartData dataObject = dataObjects.get(i);
    // in case of BarData, let the BarHighlighter take over
    if (barHighlighter != null && dataObject instanceof BarData) {
      Highlight high = barHighlighter.getHighlight(x, y);
      if (high != null) {
        high.setDataIndex(i);
        mHighlightBuffer.add(high);
      }
    } else {
      for (int j = 0, dataSetCount = dataObject.getDataSetCount(); j < dataSetCount; j++) {
        IDataSet dataSet = dataObjects.get(i).getDataSetByIndex(j);
        // don't include datasets that cannot be highlighted
        if (!dataSet.isHighlightEnabled()) {
          continue;
        }
        List<Highlight> highs = buildHighlights(dataSet, j, xVal, DataSet.Rounding.CLOSEST);
        for (Highlight high : highs) {
          high.setDataIndex(i);
          mHighlightBuffer.add(high);
        }
      }
    }
  }
  return mHighlightBuffer;
}

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

@Override
protected List<Highlight> getHighlightsAtXValue(float xVal, float x, float y) {
  mHighlightBuffer.clear();
  List<BarLineScatterCandleBubbleData> dataObjects = mChart.getCombinedData().getAllData();
  for (int i = 0; i < dataObjects.size(); i++) {
    ChartData dataObject = dataObjects.get(i);
    // in case of BarData, let the BarHighlighter take over
    if (barHighlighter != null && dataObject instanceof BarData) {
      Highlight high = barHighlighter.getHighlight(x, y);
      if (high != null) {
        high.setDataIndex(i);
        mHighlightBuffer.add(high);
      }
    } else {
      for (int j = 0, dataSetCount = dataObject.getDataSetCount(); j < dataSetCount; j++) {
        IDataSet dataSet = dataObjects.get(i).getDataSetByIndex(j);
        // don't include datasets that cannot be highlighted
        if (!dataSet.isHighlightEnabled())
          continue;
        List<Highlight> highs = buildHighlights(dataSet, j, xVal, DataSet.Rounding.CLOSEST);
        for (Highlight high : highs)
        {
          high.setDataIndex(i);
          mHighlightBuffer.add(high);
        }
      }
    }
  }
  return mHighlightBuffer;
}

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

@Override
public void onValueSelected(Entry e, Highlight h) {
  barChart.highlightValue(h);
  Highlight highlight = new Highlight(h.getX(), 0, h.getStackIndex());
  highlight.setDataIndex(1);
  candleChart.highlightValues(new Highlight[]{highlight});
  updateText(e.getXIndex(), true);
}

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

@Override
public void onValueSelected(Entry e, Highlight h) {
  candleChart.highlightValue(h);
  if (barChart.getData().getBarData().getDataSets().size() != 0) {
    Highlight highlight = new Highlight(h.getX(), h.getDataSetIndex(), h.getStackIndex());
    highlight.setDataIndex(h.getDataIndex());
    barChart.highlightValues(new Highlight[]{highlight});
  } else {
    Highlight highlight = new Highlight(h.getX(), 2, h.getStackIndex());
    highlight.setDataIndex(0);
    barChart.highlightValues(new Highlight[]{highlight});
  }
  updateText(e.getXIndex(), true);
}

相关文章