Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to save custom chart #2073

Closed
sarathraj-coder opened this issue Jul 27, 2016 · 1 comment
Closed

Not able to save custom chart #2073

sarathraj-coder opened this issue Jul 27, 2016 · 1 comment

Comments

@sarathraj-coder
Copy link

sarathraj-coder commented Jul 27, 2016

hi , while i am saving a dynamically created chart like below .
pieChart = new PieChart(getContext());
then i am getting error while saving

try {
                    if (pieChart.saveToGallery(getFileName(fullPath),50)) {
                        Toast.makeText(getContext(), "Saving SUCCESSFUL!",
                                Toast.LENGTH_SHORT).show();
                        openFile(fullPath);
                    } else {
                        Toast.makeText(getContext(), "Saving FAILED!", Toast.LENGTH_SHORT)
                                .show();
                    }
                }catch (Exception e){
                    e.printStackTrace();
                }

Error is

java.lang.IllegalArgumentException: width and height must be > 0
07-27 17:22:04.639 19413-19413/com.acelrtech.tracer W/System.err:     at android.graphics.Bitmap.createBitmap(Bitmap.java:807)
07-27 17:22:04.639 19413-19413/com.acelrtech.tracer W/System.err:     at android.graphics.Bitmap.createBitmap(Bitmap.java:786)
07-27 17:22:04.639 19413-19413/com.acelrtech.tracer W/System.err:     at android.graphics.Bitmap.createBitmap(Bitmap.java:753)
07-27 17:22:04.639 19413-19413/com.acelrtech.tracer W/System.err:     at com.github.mikephil.charting.charts.Chart.getChartBitmap(Chart.java:1501)
07-27 17:22:04.639 19413-19413/com.acelrtech.tracer W/System.err:     at com.github.mikephil.charting.charts.Chart.saveToGallery(Chart.java:1607)
07-27 17:22:04.639 19413-19413/com.acelrtech.tracer W/System.err:     at com.github.mikephil.charting.charts.Chart.saveToGallery(Chart.java:1646)
07-27 17:22:04.639 19413-19413/com.acelrtech.tracer W/System.err:     at com.acelrtech.graphlibrary.GraphFragment.saveGraph(GraphFragment.java:153)
07-27 17:22:04.639 19413-19413/com.acelrtech.tracer W/System.err:     at com.acelrtech.graphlibrary.GraphFragment.draw_multi_bar_chart(GraphFragment.java:426)
07-27 17:22:04.639 19413-19413/com.acelrtech.tracer W/System.err:     at com.acelrtech.graphlibrary.GraphFragment.generateGraph(GraphFragment.java:111)
07-27 17:22:04.639 19413-19413/com.acelrtech.tracer W/System.err:     at com.acelrtech.graphlibrary.GraphFragment.onCreateView(GraphFragment.java:93)
@sarathraj-coder sarathraj-coder changed the title Not able to save Not able to save custom chart Jul 27, 2016
@PhilJay
Copy link
Owner

PhilJay commented Aug 13, 2016

This error occurs because you have not added your chart to a layout, and therefore it has no size (which it needs).

@PhilJay PhilJay closed this as completed Aug 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants