0

Sorry for using laymans terms here but let me make you clear what i want to achieve:

I have this object in my Relative Layout,

<com.github.mikephil.charting.charts.PieChart
    android:id="@+id/piechart"
    android:layout_width="match_parent"
    android:visibility="visible"
    android:layout_marginTop="16dp"
    android:layout_below="@+id/editText3"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_height="425dp" />

which is a generated PieChart, but i believe it could be any other object like for example a image view for my matter. This thing is filled with data by the user in my Android Application and i want to allow the user to share this object as a .png via facebook, google, whatsapp or anything else, even save it to the device.

I firmly believe that there has to be a way for me to do this, and i've heard of things like bitmaps before but i've not entirely understood yet. Thank you for your patience reading this question.

Niklas Daute
  • 75
  • 1
  • 7

1 Answers1

0

From MPAndroidChart Wiki

saveToGallery(String title): Saves the current chart state as an image to the gallery. Don't forget to add "WRITE_EXTERNAL_STORAGE" permission to your manifest.

saveToPath(String title, String pathOnSD): Saves the current chart state as an image to the specified path. Don't forget to add "WRITE_EXTERNAL_STORAGE" permission to your manifest.

getChartBitmap(): Returns the Bitmap object that represents the chart, this Bitmap always contains the latest drawing state of the chart.

So just call yourChart.getChartBitmap() and you've got bitmap from your chart. Or save it to whatever you want with two other methods.

Community
  • 1
  • 1
Jozef Dochan
  • 926
  • 10
  • 27
  • to complement the answer, and here how to get a bitmap into a file: http://stackoverflow.com/questions/649154/save-bitmap-to-location – Budius Jan 16 '17 at 22:24