Saving chart to bitmap [Android]



Im trying to save my ChartView to an image, however I do not get any of the LineSeries on it with the way I am trying currently, only the Axis and Legends.

private String takeScreenshot(){
		// image naming and path to include sd card appending name you choose for file
		String path = Environment.getExternalStorageDirectory().toString() + "/" + "shareChart.jpg";   

		// create bitmap screen capture
		Bitmap bitmap;
		ChartView v1 = (ChartView) mView.findViewById(;
		bitmap = Bitmap.createBitmap(v1.getDrawingCache());

		OutputStream fout = null;
		File imageFile = new File(path);

		try {
		    fout = new FileOutputStream(imageFile);
		    bitmap.compress(Bitmap.CompressFormat.JPEG, 90, fout);

		} catch (FileNotFoundException e) {
		    return null;
		} catch (IOException e) {
		    return null;
		return path;

The ChartView has multiple LineSeries on it, so all of them would need to be saved?  I assume I need to enable to drawing cache on the childern or LineSeries but cant figure out how…

Any help is appreciated!



We don’t currently have any built-in feature for taking screen shots. The approach you have taken captures the parts of the chart that are drawn via the Android API, but not the plot area itself which is rendered using OpenGL. 

I’d suggest you take a look at as a starting point. We haven’t used this, but it looks like it might be promising.


Robin Sillem


That sadly requires including extra NDK items, which I’d like to avoid.  The more promising idea is to get access to the GLSurfaceView.Rendered (, … is there any way I can get access to this via extension of one of the existing classes?