Skip to content Skip to sidebar Skip to footer

Exporting Charts As Images In Android

I'm stucked in this for almost a month. I have a perfect chart in my android code using 'afreechart', however, the library does not seem to have support for exporting the chart as

Solution 1:

You can get a image bitmap from a view by doing:

  Bitmap bitmap;
    chart.setDrawingCacheEnabled(true);
    bitmap = Bitmap.createBitmap(chart.getDrawingCache());
    chart.setDrawingCacheEnabled(false);

if you can't call getDrawingCache on the chart, try to place it inside a layout like RelativeLayout or something like that. and call it on the layout.

After that you can save it as a image..

If the image is still black, you need to make sure the chart is created before getting the bitmap.

Hope this will help you

Post a Comment for "Exporting Charts As Images In Android"