Java Code Examples for com.github.mikephil.charting.interfaces.datasets.IScatterDataSet#isDrawIconsEnabled()
The following examples show how to use
com.github.mikephil.charting.interfaces.datasets.IScatterDataSet#isDrawIconsEnabled() .
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: ScatterChartRenderer.java From StockChart-MPAndroidChart with MIT License | 4 votes |
@Override public void drawValues(Canvas c) { // if values are drawn if (isDrawingValuesAllowed(mChart)) { List<IScatterDataSet> dataSets = mChart.getScatterData().getDataSets(); for (int i = 0; i < mChart.getScatterData().getDataSetCount(); i++) { IScatterDataSet dataSet = dataSets.get(i); if (!shouldDrawValues(dataSet) || dataSet.getEntryCount() < 1) continue; // apply the text-styling defined by the DataSet applyValueTextStyle(dataSet); mXBounds.set(mChart, dataSet); float[] positions = mChart.getTransformer(dataSet.getAxisDependency()) .generateTransformedValuesScatter(dataSet, mAnimator.getPhaseX(), mAnimator.getPhaseY(), mXBounds.min, mXBounds.max); float shapeSize = Utils.convertDpToPixel(dataSet.getScatterShapeSize()); ValueFormatter formatter = dataSet.getValueFormatter(); MPPointF iconsOffset = MPPointF.getInstance(dataSet.getIconsOffset()); iconsOffset.x = Utils.convertDpToPixel(iconsOffset.x); iconsOffset.y = Utils.convertDpToPixel(iconsOffset.y); for (int j = 0; j < positions.length; j += 2) { if (!mViewPortHandler.isInBoundsRight(positions[j])) break; // make sure the lines don't do shitty things outside bounds if ((!mViewPortHandler.isInBoundsLeft(positions[j]) || !mViewPortHandler.isInBoundsY(positions[j + 1]))) continue; Entry entry = dataSet.getEntryForIndex(j / 2 + mXBounds.min); if (dataSet.isDrawValuesEnabled()) { drawValue(c, formatter.getPointLabel(entry), positions[j], positions[j + 1] - shapeSize, dataSet.getValueTextColor(j / 2 + mXBounds.min)); } if (entry.getIcon() != null && dataSet.isDrawIconsEnabled()) { Drawable icon = entry.getIcon(); Utils.drawImage( c, icon, (int) (positions[j] + iconsOffset.x), (int) (positions[j + 1] + iconsOffset.y), icon.getIntrinsicWidth(), icon.getIntrinsicHeight()); } } MPPointF.recycleInstance(iconsOffset); } } }
Example 2
Source File: ScatterChartRenderer.java From Ticket-Analysis with MIT License | 4 votes |
@Override public void drawValues(Canvas c) { // if values are drawn if (isDrawingValuesAllowed(mChart)) { List<IScatterDataSet> dataSets = mChart.getScatterData().getDataSets(); for (int i = 0; i < mChart.getScatterData().getDataSetCount(); i++) { IScatterDataSet dataSet = dataSets.get(i); if (!shouldDrawValues(dataSet)) continue; // apply the text-styling defined by the DataSet applyValueTextStyle(dataSet); mXBounds.set(mChart, dataSet); float[] positions = mChart.getTransformer(dataSet.getAxisDependency()) .generateTransformedValuesScatter(dataSet, mAnimator.getPhaseX(), mAnimator.getPhaseY(), mXBounds.min, mXBounds.max); float shapeSize = Utils.convertDpToPixel(dataSet.getScatterShapeSize()); MPPointF iconsOffset = MPPointF.getInstance(dataSet.getIconsOffset()); iconsOffset.x = Utils.convertDpToPixel(iconsOffset.x); iconsOffset.y = Utils.convertDpToPixel(iconsOffset.y); for (int j = 0; j < positions.length; j += 2) { if (!mViewPortHandler.isInBoundsRight(positions[j])) break; // make sure the lines don't do shitty things outside bounds if ((!mViewPortHandler.isInBoundsLeft(positions[j]) || !mViewPortHandler.isInBoundsY(positions[j + 1]))) continue; Entry entry = dataSet.getEntryForIndex(j / 2 + mXBounds.min); if (dataSet.isDrawValuesEnabled()) { drawValue(c, dataSet.getValueFormatter(), entry.getY(), entry, i, positions[j], positions[j + 1] - shapeSize, dataSet.getValueTextColor(j / 2 + mXBounds.min)); } if (entry.getIcon() != null && dataSet.isDrawIconsEnabled()) { Drawable icon = entry.getIcon(); Utils.drawImage( c, icon, (int)(positions[j] + iconsOffset.x), (int)(positions[j + 1] + iconsOffset.y), icon.getIntrinsicWidth(), icon.getIntrinsicHeight()); } } MPPointF.recycleInstance(iconsOffset); } } }
Example 3
Source File: ScatterChartRenderer.java From android-kline with Apache License 2.0 | 4 votes |
@Override public void drawValues(Canvas c) { // if values are drawn if (isDrawingValuesAllowed(mChart)) { List<IScatterDataSet> dataSets = mChart.getScatterData().getDataSets(); for (int i = 0; i < mChart.getScatterData().getDataSetCount(); i++) { IScatterDataSet dataSet = dataSets.get(i); if (!shouldDrawValues(dataSet)) continue; // apply the text-styling defined by the DataSet applyValueTextStyle(dataSet); mXBounds.set(mChart, dataSet); float[] positions = mChart.getTransformer(dataSet.getAxisDependency()) .generateTransformedValuesScatter(dataSet, mAnimator.getPhaseX(), mAnimator.getPhaseY(), mXBounds.min, mXBounds.max); float shapeSize = Utils.convertDpToPixel(dataSet.getScatterShapeSize()); MPPointF iconsOffset = MPPointF.getInstance(dataSet.getIconsOffset()); iconsOffset.x = Utils.convertDpToPixel(iconsOffset.x); iconsOffset.y = Utils.convertDpToPixel(iconsOffset.y); for (int j = 0; j < positions.length; j += 2) { if (!mViewPortHandler.isInBoundsRight(positions[j])) break; // make sure the lines don't do shitty things outside bounds if ((!mViewPortHandler.isInBoundsLeft(positions[j]) || !mViewPortHandler.isInBoundsY(positions[j + 1]))) continue; Entry entry = dataSet.getEntryForIndex(j / 2 + mXBounds.min); if (dataSet.isDrawValuesEnabled()) { drawValue(c, dataSet.getValueFormatter(), entry.getY(), entry, i, positions[j], positions[j + 1] - shapeSize, dataSet.getValueTextColor(j / 2 + mXBounds.min)); } if (entry.getIcon() != null && dataSet.isDrawIconsEnabled()) { Drawable icon = entry.getIcon(); Utils.drawImage( c, icon, (int)(positions[j] + iconsOffset.x), (int)(positions[j + 1] + iconsOffset.y), icon.getIntrinsicWidth(), icon.getIntrinsicHeight()); } } MPPointF.recycleInstance(iconsOffset); } } }
Example 4
Source File: ScatterChartRenderer.java From android-kline with Apache License 2.0 | 4 votes |
@Override public void drawValues(Canvas c) { // if values are drawn if (isDrawingValuesAllowed(mChart)) { List<IScatterDataSet> dataSets = mChart.getScatterData().getDataSets(); for (int i = 0; i < mChart.getScatterData().getDataSetCount(); i++) { IScatterDataSet dataSet = dataSets.get(i); if (!shouldDrawValues(dataSet)) continue; // apply the text-styling defined by the DataSet applyValueTextStyle(dataSet); mXBounds.set(mChart, dataSet); float[] positions = mChart.getTransformer(dataSet.getAxisDependency()) .generateTransformedValuesScatter(dataSet, mAnimator.getPhaseX(), mAnimator.getPhaseY(), mXBounds.min, mXBounds.max); float shapeSize = Utils.convertDpToPixel(dataSet.getScatterShapeSize()); MPPointF iconsOffset = MPPointF.getInstance(dataSet.getIconsOffset()); iconsOffset.x = Utils.convertDpToPixel(iconsOffset.x); iconsOffset.y = Utils.convertDpToPixel(iconsOffset.y); for (int j = 0; j < positions.length; j += 2) { if (!mViewPortHandler.isInBoundsRight(positions[j])) break; // make sure the lines don't do shitty things outside bounds if ((!mViewPortHandler.isInBoundsLeft(positions[j]) || !mViewPortHandler.isInBoundsY(positions[j + 1]))) continue; Entry entry = dataSet.getEntryForIndex(j / 2 + mXBounds.min); if (dataSet.isDrawValuesEnabled()) { drawValue(c, dataSet.getValueFormatter(), entry.getY(), entry, i, positions[j], positions[j + 1] - shapeSize, dataSet.getValueTextColor(j / 2 + mXBounds.min)); } if (entry.getIcon() != null && dataSet.isDrawIconsEnabled()) { Drawable icon = entry.getIcon(); Utils.drawImage( c, icon, (int)(positions[j] + iconsOffset.x), (int)(positions[j + 1] + iconsOffset.y), icon.getIntrinsicWidth(), icon.getIntrinsicHeight()); } } MPPointF.recycleInstance(iconsOffset); } } }