gorteganesh / achartengine

Automatically exported from code.google.com/p/achartengine
0 stars 0 forks source link

toBitmap is returning null #115

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. get view from get*ChartView 
2. setDrawingCacheEnabled(true) 
3. img = toBitmap()

What is the expected output? What do you see instead?
Expected to have a bitmap.  Null was returned instead.

Please provide a source code snippet that we can use to replicate the issue.
        GraphicalView achartView = ChartFactory.getLineChartView(context, buildDataset(titles, x, values), renderer);
        achartView.setDrawingCacheEnabled(true); 
        Bitmap bitmap = achartView.toBitmap();

What version of the product binary library are you using?
achartengine-0.7.0.jar

Please provide any additional information below.
I saw in the google groups that I'm not alone here.  Graphs working if I call 
them with an intent, but not working here.  I had a small line graph with only 
5 plots.

Original issue reported on code.google.com by chrispar...@gmail.com on 12 Aug 2011 at 2:09

GoogleCodeExporter commented 9 years ago
toBitmap() works fine for displaying charts.
It seems like you don't display it, but just want to save an image.

Original comment by dandrome...@gmail.com on 23 Aug 2011 at 12:18

GoogleCodeExporter commented 9 years ago
It's absolutely not working fine.  For me and many others.  Not sure why this 
was closed. 

Original comment by chrispar...@gmail.com on 23 Aug 2011 at 12:42

GoogleCodeExporter commented 9 years ago
I have the same problem. toBitmap method returns null for a simple pie graph 

int[] colors = new int[]{Color.RED, Color.YELLOW, Color.BLUE};
DefaultRenderer renderer = buildCategoryRenderer(colors);
CategorySeries categorySeries = new CategorySeries("Vehicles Chart");
categorySeries.add("cars ", 30);
categorySeries.add("trucks", 20);
categorySeries.add("bikes ", 60);

GraphicalView pieChartView = ChartFactory.getPieChartView(context, 
categorySeries, renderer);
Bitmap b = pieChartView.toBitmap()

Original comment by sebastij...@gmail.com on 17 Jan 2012 at 12:36

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Hi.

Maybe try to set size of the Chart View.

chartView.setDrawingCacheEnabled(true);
chartView.measure(MeasureSpec.makeMeasureSpec(0, 
MeasureSpec.UNSPECIFIED),MeasureSpec.makeMeasureSpec(0, 
MeasureSpec.UNSPECIFIED));
chartView.layout(0, 
0,chartView.getMeasuredWidth(),chartView.getMeasuredHeight());
chartView.buildDrawingCache(true);
Bitmap bitmap = Bitmap.createBitmap(chartView.getDrawingCache());

This problem is at MapView in google maps API.

Toni

Original comment by toniabc@gmail.com on 25 Jan 2012 at 11:57

GoogleCodeExporter commented 9 years ago
Some comments from a user related to this issue:

I also had an issue, the background of the chart was white when i exported it 
as a bitmap, so i used :
  renderer.setBackgroundColor(Color.BLACK);
  renderer.setApplyBackgroundColor(true);
To configure the renderer and then:
  v.setBackgroundColor(renderer.getBackgroundColor());
Before buidling the drawing cache

And it worked, i just let the code if anyone has this trouble.

Original comment by dandrome...@gmail.com on 10 May 2012 at 9:22

GoogleCodeExporter commented 9 years ago

Original comment by dandrome...@gmail.com on 11 May 2012 at 6:28