Hey Phil,
Thanks for this amazing library.
I have created line chart using this library and everything works great. Now what I want is use images instead of the default circles to show on graph for each data entry.
Any help would be really appreciated.
chart.setRenderer(new YourLineChartRender(chart, chart.getAnimator(), chart.getViewPortHandler()));
override drawCircles(Canvas c),copy the library code and replace the code below
//Bitmap circleBitmap = imageCache.getBitmap(j); //library code
Bitmap circleBitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.your_img);
@603530013 can you explain more what you did ?
@noam2
set a custom render for your chart
chart.setRenderer(new YourCustomRender(chart, chart.getAnimator(), chart.getViewPortHandler()));
your customized render
private class YourCustomRender extends LineChartRenderer{
public YourCustomRender(LineDataProvider chart, ChartAnimator animator, ViewPortHandler viewPortHandler) {
super(chart, animator, viewPortHandler);
}
@Override
protected void drawCircles(Canvas c) {
//copy the codes in library code
}
}
find the below code in your drawCircles(Canvas c) and replace with your img
//Bitmap circleBitmap = imageCache.getBitmap(j); //library code
Bitmap circleBitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.your_img);//your img
thank u very much man
On Fri, Jul 7, 2017 at 4:26 AM, 603530013 notifications@github.com wrote:
@noam2 https://github.com/noam2
set a customized render for your chartchart.setRenderer(new YourCustomizedRender(chart, chart.getAnimator(), chart.getViewPortHandler()));
your customized render
private class YourCustomizedRenderextends LineChartRenderer{
public YourCustomizedRender(LineDataProvider chart, ChartAnimator animator, ViewPortHandler viewPortHandler) {
super(chart, animator, viewPortHandler);
}@Override protected void drawCircles(Canvas c) { //copy the codes in library code } }find the below code in your drawCircles(Canvas c) and replace with your img
//Bitmap circleBitmap = imageCache.getBitmap(j); //library codeBitmap circleBitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.your_img);//your img
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/PhilJay/MPAndroidChart/issues/2769#issuecomment-313562407,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ATLyK7Ga3BxAgPTZyvOUklQoTpLrqxkvks5sLYk0gaJpZM4L2C6k
.
FYI, as of v3.0.2, you can use dataSet.setDrawIcons(true) and add in entries new Entry(x, y, drawable) for data points that you want images drawn for.
Seems like this is solved, closing
@noam2
Can you explain a bit more?
Wen i copy your code to MainActivity.java, i m getting error on mXBounds.
FYI, as of
v3.0.2, you can usedataSet.setDrawIcons(true)and add in entriesnew Entry(x, y, drawable)for data points that you want images drawn for.
@jlo1 I am trying this solution but unable to get the icon for LineDataSet having single Entry. Can you point me to some example? Thanks.
FYI, as of
v3.0.2, you can usedataSet.setDrawIcons(true)and add in entriesnew Entry(x, y, drawable)for data points that you want images drawn for.
Can't make my drawable appear on LineDataSet using v3.0.3, following this approach. Is there any requirement for our drawables? Like a max height/width?
Most helpful comment
FYI, as of
v3.0.2, you can usedataSet.setDrawIcons(true)and add in entriesnew Entry(x, y, drawable)for data points that you want images drawn for.