本文介绍了圆环图中AchartEngine半径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我米试图设置圆环图内圆半径和aChartengine outter圆半径,下面是我的code:

I m trying to set doughnut chart inner circle radius and outter circle radius in aChartengine, below is my code :

public class MainActivity extends Activity {
    GraphicalView gv;
    RelativeLayout rl;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        List<double[]> values1 = new ArrayList<double[]>();

        values1.add(new double[] { 15, 5 });


        gv = createIntent(values1);

        rl = (RelativeLayout) findViewById(R.id.rel);
        rl.addView(gv);    
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    public GraphicalView createIntent(List<double[]> values1) {

        List<String[]> titles = new ArrayList<String[]>();

        titles.add(new String[] { " ", " " });
        int[] colors = new int[] { Color.BLUE, Color.GREEN };

        DefaultRenderer renderer = buildCategoryRenderer(colors);
        renderer.setApplyBackgroundColor(true);
        renderer.setShowLegend(false);

        renderer.setShowLabels(false);
        renderer.setStartAngle(270);
        renderer.setBackgroundColor(Color.rgb(222, 222, 200));
        renderer.setLabelsColor(Color.GRAY);



        return ChartFactory.getDoughnutChartView(MainActivity.this,
                buildMultipleCategoryDataset("Project budget", titles, values1),
                renderer);
    }

    protected MultipleCategorySeries buildMultipleCategoryDataset(String title,
            List<String[]> titles, List<double[]> values) {
        MultipleCategorySeries series = new MultipleCategorySeries(title);
        int k = 0;
        for (double[] value : values) {
            series.add(2007 + k + "", titles.get(k), value);
            k++;
        }
        return series;
    }

    protected DefaultRenderer buildCategoryRenderer(int[] colors) {
        DefaultRenderer renderer = new DefaultRenderer();
        renderer.setLabelsTextSize(15);
        renderer.setLegendTextSize(15);
        renderer.setMargins(new int[] { 20, 30, 15, 0 });
        for (int color : colors) {
            SimpleSeriesRenderer r = new SimpleSeriesRenderer();
            r.setColor(color);
            renderer.addSeriesRenderer(r);
        }
        return renderer;
    }

但我的浏览器设置半径此查询,在很多搜索,我发现半径在画布上,但在我的情况,我没有画布。

But I have browser this query of setting radius , in many search I have found radius on canvas but in my case I don't have canvas.

谁能告诉我怎么在这里设置半径在我的code?

Can anyone tell me how to set radius here in my code ?

推荐答案

renderer.setScale((flaot)1.3)解决了我的问题,但内,外半径约为并不prefect。

renderer.setScale((flaot)1.3) solved my problem but the inner and outer radius is approx not prefect.

这篇关于圆环图中AchartEngine半径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 21:55