Java Code Examples for com.github.mikephil.charting.interfaces.datasets.IDataSet#getEntryCount()
The following examples show how to use
com.github.mikephil.charting.interfaces.datasets.IDataSet#getEntryCount() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CombinedChartKline.java From shinny-futures-android with GNU General Public License v3.0 | 5 votes |
@Override protected void drawMarkers(Canvas canvas) { // if there is no marker view or drawing marker is disabled if (mMarker == null || !isDrawMarkersEnabled() || !valuesToHighlight()) return; for (Highlight highlight : mIndicesToHighlight) { IDataSet set = mData.getDataSetByIndex(highlight.getDataSetIndex()); Entry e = getEntryForHighlight(highlight); int entryIndex = set.getEntryIndex(e); // make sure entry not null if (e == null || entryIndex > set.getEntryCount() * mAnimator.getPhaseX()) continue; float[] pos = getMarkerPosition(highlight); // check bounds // if (!mViewPortHandler.isInBounds(pos[0], pos[1])) // continue; // callbacks to initQuotes the content mMarker.refreshContent(e, highlight); // draw the marker mMarker.draw(canvas, pos[0], pos[1]); } }
Example 2
Source File: CombinedChartCurrentDay.java From shinny-futures-android with GNU General Public License v3.0 | 5 votes |
@Override protected void drawMarkers(Canvas canvas) { // if there is no marker view or drawing marker is disabled if (mMarker == null || !isDrawMarkersEnabled() || !valuesToHighlight()) return; for (Highlight highlight : mIndicesToHighlight) { IDataSet set = mData.getDataSetByIndex(highlight.getDataSetIndex()); Entry e = getEntryForHighlight(highlight); int entryIndex = set.getEntryIndex(e); // make sure entry not null if (e == null || entryIndex > set.getEntryCount() * mAnimator.getPhaseX()) continue; float[] pos = getMarkerPosition(highlight); //注释掉,在三图范围内,保持marker始终出现 // check bounds // if (!mViewPortHandler.isInBoundsX(pos[0])) // continue; // callbacks to initQuotes the content mMarker.refreshContent(e, highlight); // draw the marker mMarker.draw(canvas, pos[0], pos[1]); } }
Example 3
Source File: Chart.java From StockChart-MPAndroidChart with MIT License | 5 votes |
/** * draws all MarkerViews on the highlighted positions */ protected void drawMarkers(Canvas canvas) { // if there is no marker view or drawing marker is disabled if (mMarker == null || !isDrawMarkersEnabled() || !valuesToHighlight()) { return; } for (int i = 0; i < mIndicesToHighlight.length; i++) { Highlight highlight = mIndicesToHighlight[i]; IDataSet set = mData.getDataSetByIndex(highlight.getDataSetIndex()); Entry e = mData.getEntryForHighlight(mIndicesToHighlight[i]); int entryIndex = set.getEntryIndex(e); // make sure entry not null if (e == null || entryIndex > set.getEntryCount() * mAnimator.getPhaseX()) { continue; } float[] pos = getMarkerPosition(highlight); // check bounds if (!mViewPortHandler.isInBounds(pos[0], pos[1])) { continue; } // callbacks to update the content mMarker.refreshContent(e, highlight); // draw the marker mMarker.draw(canvas, pos[0], pos[1]); } }
Example 4
Source File: CombinedChart.java From Ticket-Analysis with MIT License | 5 votes |
/** * draws all MarkerViews on the highlighted positions */ protected void drawMarkers(Canvas canvas) { // if there is no marker view or drawing marker is disabled if (mMarker == null || !isDrawMarkersEnabled() || !valuesToHighlight()) return; for (int i = 0; i < mIndicesToHighlight.length; i++) { Highlight highlight = mIndicesToHighlight[i]; IDataSet set = mData.getDataSetByHighlight(highlight); Entry e = mData.getEntryForHighlight(highlight); if (e == null) continue; int entryIndex = set.getEntryIndex(e); // make sure entry not null if (entryIndex > set.getEntryCount() * mAnimator.getPhaseX()) continue; float[] pos = getMarkerPosition(highlight); // check bounds if (!mViewPortHandler.isInBounds(pos[0], pos[1])) continue; // callbacks to update the content mMarker.refreshContent(e, highlight); // draw the marker mMarker.draw(canvas, pos[0], pos[1]); } }
Example 5
Source File: Chart.java From Ticket-Analysis with MIT License | 5 votes |
/** * draws all MarkerViews on the highlighted positions */ protected void drawMarkers(Canvas canvas) { // if there is no marker view or drawing marker is disabled if (mMarker == null || !isDrawMarkersEnabled() || !valuesToHighlight()) return; for (int i = 0; i < mIndicesToHighlight.length; i++) { Highlight highlight = mIndicesToHighlight[i]; IDataSet set = mData.getDataSetByIndex(highlight.getDataSetIndex()); Entry e = mData.getEntryForHighlight(mIndicesToHighlight[i]); int entryIndex = set.getEntryIndex(e); // make sure entry not null if (e == null || entryIndex > set.getEntryCount() * mAnimator.getPhaseX()) continue; float[] pos = getMarkerPosition(highlight); // check bounds if (!mViewPortHandler.isInBounds(pos[0], pos[1])) continue; // callbacks to update the content mMarker.refreshContent(e, highlight); // draw the marker mMarker.draw(canvas, pos[0], pos[1]); } }
Example 6
Source File: Chart.java From android-kline with Apache License 2.0 | 5 votes |
/** * draws all MarkerViews on the highlighted positions */ protected void drawMarkers(Canvas canvas) { // if there is no marker view or drawing marker is disabled if (mMarker == null || !isDrawMarkersEnabled() || !valuesToHighlight()) return; for (int i = 0; i < mIndicesToHighlight.length; i++) { Highlight highlight = mIndicesToHighlight[i]; IDataSet set = mData.getDataSetByIndex(highlight.getDataSetIndex()); Entry e = mData.getEntryForHighlight(mIndicesToHighlight[i]); int entryIndex = set.getEntryIndex(e); // make sure entry not null if (e == null || entryIndex > set.getEntryCount() * mAnimator.getPhaseX()) continue; float[] pos = getMarkerPosition(highlight); // check bounds if (!mViewPortHandler.isInBounds(pos[0], pos[1])) continue; // callbacks to update the content mMarker.refreshContent(e, highlight); // draw the marker mMarker.draw(canvas, pos[0], pos[1]); } }
Example 7
Source File: CombinedChart.java From StockChart-MPAndroidChart with MIT License | 4 votes |
/** * draws all MarkerViews on the highlighted positions */ @Override protected void drawMarkers(Canvas canvas) { // if there is no marker view or drawing marker is disabled if (mMarker == null || !isDrawMarkersEnabled() || !valuesToHighlight()) { return; } for (int i = 0; i < mIndicesToHighlight.length; i++) { Highlight highlight = mIndicesToHighlight[i]; IDataSet set = mData.getDataSetByHighlight(highlight); Entry e = mData.getEntryForHighlight(highlight); if (e == null) { continue; } int entryIndex = set.getEntryIndex(e); // make sure entry not null if (entryIndex > set.getEntryCount() * mAnimator.getPhaseX()) { continue; } float[] pos = getMarkerPosition(highlight); // check bounds if (!mViewPortHandler.isInBounds(pos[0], pos[1])) { continue; } // callbacks to update the content mMarker.refreshContent(e, highlight); // draw the marker mMarker.draw(canvas, pos[0], pos[1]); } }
Example 8
Source File: TimeBarChart.java From StockChart-MPAndroidChart with MIT License | 4 votes |
@Override protected void drawMarkers(Canvas canvas) { // if there is no marker view or drawing marker is disabled if (!isDrawMarkersEnabled() || !valuesToHighlight()) { return; } for (int i = 0; i < mIndicesToHighlight.length; i++) { Highlight highlight = mIndicesToHighlight[i]; IDataSet set = mData.getDataSetByIndex(highlight.getDataSetIndex()); Entry e = mData.getEntryForHighlight(mIndicesToHighlight[i]); int entryIndex = set.getEntryIndex(e); // make sure entry not null if (e == null || entryIndex > set.getEntryCount() * mAnimator.getPhaseX()) { continue; } float[] pos = getMarkerPosition(highlight); // check bounds if (!mViewPortHandler.isInBounds(pos[0], pos[1])) { continue; } String date = ""; date = DataTimeUtil.secToTime(kTimeData.getDatas().get((int) e.getX()).getTimeMills());//分时图显示的数据 markerBottom.setData(date); markerBottom.refreshContent(e, highlight); markerBottom.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); markerBottom.layout(0, 0, markerBottom.getMeasuredWidth(), markerBottom.getMeasuredHeight()); int width = markerBottom.getWidth() / 2; if (mViewPortHandler.contentRight() - pos[0] <= width) { markerBottom.draw(canvas, mViewPortHandler.contentRight() - markerBottom.getWidth() / 2, mViewPortHandler.contentBottom() + markerBottom.getHeight());//-markerBottom.getHeight() CommonUtil.dip2px(getContext(),65.8f) } else if (pos[0] - mViewPortHandler.contentLeft() <= width) { markerBottom.draw(canvas, mViewPortHandler.contentLeft() + markerBottom.getWidth() / 2, mViewPortHandler.contentBottom() + markerBottom.getHeight()); } else { markerBottom.draw(canvas, pos[0], mViewPortHandler.contentBottom() + markerBottom.getHeight()); } // callbacks to update the content // mMarker.refreshContent(e, highlight); // draw the marker // mMarker.draw(canvas, pos[0], pos[1]); } }
Example 9
Source File: TimeLineChart.java From StockChart-MPAndroidChart with MIT License | 4 votes |
@Override protected void drawMarkers(Canvas canvas) { // if there is no marker view or drawing marker is disabled if (!isDrawMarkersEnabled() || !valuesToHighlight()) { return; } for (int i = 0; i < mIndicesToHighlight.length; i++) { Highlight highlight = mIndicesToHighlight[i]; IDataSet set = mData.getDataSetByIndex(highlight.getDataSetIndex()); Entry e = mData.getEntryForHighlight(mIndicesToHighlight[i]); int entryIndex = set.getEntryIndex(e); // make sure entry not null if (e == null || entryIndex > set.getEntryCount() * mAnimator.getPhaseX()) { continue; } float[] pos = getMarkerPosition(highlight); // check bounds if (!mViewPortHandler.isInBounds(pos[0], pos[1])) { continue; } float yValForXIndex1 = (float) kTimeData.getDatas().get((int) mIndicesToHighlight[i].getX()).getNowPrice(); float yValForXIndex2 = (float) kTimeData.getDatas().get((int) mIndicesToHighlight[i].getX()).getPer(); if (volSelected != null) { volSelected.onVolSelected(kTimeData.getDatas().get((int) mIndicesToHighlight[i].getX()).getVolume()); volSelected.onValuesSelected(kTimeData.getDatas().get((int) mIndicesToHighlight[i].getX()).getNowPrice(), kTimeData.getDatas().get((int) mIndicesToHighlight[i].getX()).getPer(), kTimeData.getDatas().get((int) mIndicesToHighlight[i].getX()).getVolume(), kTimeData.getDatas().get((int) mIndicesToHighlight[i].getX()).getAveragePrice()); } myMarkerViewLeft.setData(yValForXIndex1); myMarkerViewRight.setData(yValForXIndex2); myMarkerViewLeft.refreshContent(e, mIndicesToHighlight[i]); myMarkerViewRight.refreshContent(e, mIndicesToHighlight[i]); /*修复bug*/ // invalidate(); /*重新计算大小*/ myMarkerViewLeft.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); myMarkerViewLeft.layout(0, 0, myMarkerViewLeft.getMeasuredWidth(), myMarkerViewLeft.getMeasuredHeight()); myMarkerViewRight.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); myMarkerViewRight.layout(0, 0, myMarkerViewRight.getMeasuredWidth(), myMarkerViewRight.getMeasuredHeight()); if (getAxisLeft().getLabelPosition() == YAxis.YAxisLabelPosition.OUTSIDE_CHART) { myMarkerViewLeft.draw(canvas, mViewPortHandler.contentLeft() - myMarkerViewLeft.getWidth() / 2, pos[1] + myMarkerViewLeft.getHeight() / 2); } else { myMarkerViewLeft.draw(canvas, mViewPortHandler.contentLeft() + myMarkerViewLeft.getWidth() / 2, pos[1] + myMarkerViewLeft.getHeight() / 2); } if (getAxisRight().getLabelPosition() == YAxis.YAxisLabelPosition.OUTSIDE_CHART) { myMarkerViewRight.draw(canvas, mViewPortHandler.contentRight() + myMarkerViewRight.getWidth() / 2, pos[1] + myMarkerViewRight.getHeight() / 2);//- myMarkerViewRight.getWidth() } else { myMarkerViewRight.draw(canvas, mViewPortHandler.contentRight() - myMarkerViewRight.getWidth() / 2, pos[1] + myMarkerViewRight.getHeight() / 2);//- myMarkerViewRight.getWidth() } // callbacks to update the content // mMarker.refreshContent(e, highlight); // draw the marker // mMarker.draw(canvas, pos[0], pos[1]); } }
Example 10
Source File: CandleCombinedChart.java From StockChart-MPAndroidChart with MIT License | 4 votes |
@Override protected void drawMarkers(Canvas canvas) { // if there is no marker view or drawing marker is disabled if (!isDrawMarkersEnabled() || !valuesToHighlight()) { return; } for (int i = 0; i < mIndicesToHighlight.length; i++) { Highlight highlight = mIndicesToHighlight[i]; IDataSet set = mData.getDataSetByIndex(highlight.getDataSetIndex()); Entry e = mData.getEntryForHighlight(mIndicesToHighlight[i]); int entryIndex = set.getEntryIndex(e); // make sure entry not null if (e == null || entryIndex > set.getEntryCount() * mAnimator.getPhaseX()) { continue; } float[] pos = getMarkerPosition(highlight); // check bounds if (!mViewPortHandler.isInBounds(pos[0], pos[1])) { continue; } if (pos[0] >= CommonUtil.getWindowWidth(getContext()) / 2) { float yValForXIndex1 = (float) kLineData.getKLineDatas().get((int) mIndicesToHighlight[i].getX()).getClose(); myMarkerViewLeft.setData(yValForXIndex1); myMarkerViewLeft.refreshContent(e, mIndicesToHighlight[i]); myMarkerViewLeft.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); myMarkerViewLeft.layout(0, 0, myMarkerViewLeft.getMeasuredWidth(), myMarkerViewLeft.getMeasuredHeight()); if (getAxisLeft().getLabelPosition() == YAxis.YAxisLabelPosition.OUTSIDE_CHART) { myMarkerViewLeft.draw(canvas, mViewPortHandler.contentLeft() - myMarkerViewLeft.getWidth() / 2, pos[1] + myMarkerViewLeft.getHeight() / 2);//+ CommonUtil.dip2px(getContext(),20) - myMarkerViewLeft.getHeight() / 2 } else { myMarkerViewLeft.draw(canvas, mViewPortHandler.contentLeft() + myMarkerViewLeft.getWidth() / 2, pos[1] + myMarkerViewLeft.getHeight() / 2);//+ CommonUtil.dip2px(getContext(),20) - myMarkerViewLeft.getHeight() / 2 } } else { float yValForXIndex2 = (float) kLineData.getKLineDatas().get((int) mIndicesToHighlight[i].getX()).getClose(); myMarkerViewRight.setData(yValForXIndex2); myMarkerViewRight.refreshContent(e, mIndicesToHighlight[i]); myMarkerViewRight.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); myMarkerViewRight.layout(0, 0, myMarkerViewRight.getMeasuredWidth(), myMarkerViewRight.getMeasuredHeight());// - myMarkerViewRight.getHeight() / 2 if (getAxisRight().getLabelPosition() == YAxis.YAxisLabelPosition.OUTSIDE_CHART) { myMarkerViewRight.draw(canvas, mViewPortHandler.contentRight() + myMarkerViewRight.getWidth() / 2, pos[1] + myMarkerViewLeft.getHeight() / 2);// - CommonUtil.dip2px(getContext(),20) } else { myMarkerViewRight.draw(canvas, mViewPortHandler.contentRight() - myMarkerViewRight.getWidth() / 2, pos[1] + myMarkerViewLeft.getHeight() / 2);// - CommonUtil.dip2px(getContext(),20) } } } }
Example 11
Source File: MyCombinedChart.java From StockChart-MPAndroidChart with MIT License | 4 votes |
@Override protected void drawMarkers(Canvas canvas) { // if there is no marker view or drawing marker is disabled if (!isDrawMarkersEnabled() || !valuesToHighlight()) { return; } for (int i = 0; i < mIndicesToHighlight.length; i++) { Highlight highlight = mIndicesToHighlight[i]; IDataSet set = mData.getDataSetByIndex(highlight.getDataSetIndex()); if(set == null){ continue; } Entry e = mData.getEntryForHighlight(mIndicesToHighlight[i]); int entryIndex = set.getEntryIndex(e); // make sure entry not null if (e == null || entryIndex > set.getEntryCount() * mAnimator.getPhaseX()) { continue; } float[] pos = getMarkerPosition(highlight); // check bounds if (!mViewPortHandler.isInBounds(pos[0], pos[1])) { continue; } String date = null; if (this.timeType == TimeType.TIME_HOUR) { date = DataTimeUtil.secToTime(kLineData.getKLineDatas().get((int) e.getX()).getDateMills()); } else { date = DataTimeUtil.secToDate(kLineData.getKLineDatas().get((int) e.getX()).getDateMills()); } markerBottom.setData(date); markerBottom.refreshContent(e, highlight); markerBottom.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); markerBottom.layout(0, 0, markerBottom.getMeasuredWidth(), markerBottom.getMeasuredHeight()); int width = markerBottom.getWidth() / 2; if (mViewPortHandler.contentRight() - pos[0] <= width) { markerBottom.draw(canvas, mViewPortHandler.contentRight() - markerBottom.getWidth() / 2, mViewPortHandler.contentBottom() + markerBottom.getHeight());//-markerBottom.getHeight() CommonUtil.dip2px(getContext(),65.8f) } else if (pos[0] - mViewPortHandler.contentLeft() <= width) { markerBottom.draw(canvas, mViewPortHandler.contentLeft() + markerBottom.getWidth() / 2, mViewPortHandler.contentBottom() + markerBottom.getHeight()); } else { markerBottom.draw(canvas, pos[0], mViewPortHandler.contentBottom() + markerBottom.getHeight()); } } }
Example 12
Source File: AppCombinedChart.java From android-kline with Apache License 2.0 | 4 votes |
@Override protected void drawMarkers(Canvas canvas) { if (mMarker == null || mXMarker == null || !isDrawMarkersEnabled() || !valuesToHighlight()) return; for (int i = 0; i < mIndicesToHighlight.length; i++) { Highlight highlight = mIndicesToHighlight[i]; IDataSet set = mData.getDataSetByIndex(highlight.getDataSetIndex()); Entry e = mData.getEntryForHighlight(mIndicesToHighlight[i]); int entryIndex = set.getEntryIndex(e); // make sure entry not null if (e == null || entryIndex > set.getEntryCount() * mAnimator.getPhaseX()) continue; float[] pos = getMarkerPosition(highlight); // check bounds if (!mViewPortHandler.isInBounds(pos[0], pos[1])) continue; // callbacks to update the content mMarker.refreshContent(e, highlight); mXMarker.refreshContent(e, highlight); // draw the marker // if (mMarker instanceof LineChartYMarkerView) { LineChartYMarkerView yMarker = (LineChartYMarkerView) mMarker; LineChartXMarkerView xMarker = (LineChartXMarkerView) mXMarker; int width = yMarker.getMeasuredWidth(); mMarker.draw(canvas, getMeasuredWidth() - width * 1.05f, pos[1] - yMarker.getMeasuredHeight() / 2); mXMarker.draw(canvas, pos[0] - (xMarker.getMeasuredWidth() / 2), getMeasuredHeight()); // } else { // mMarker.draw(canvas, pos[0], pos[1]); // } } }