Como desenhair um graph de torta no Android

Gostairia de desenhair um graph de torta na minha aplicação paira Android. Você poderia sugerir-me uma maneira de fazer isso de uma maneira simples? Eu escrevi uma class de exibição paira esse propósito, mas não é gratificante. Então, eu apreciairia se você me dissesse uma boa e alta tabela de graphs de alto performance.

  • Android - Ativação do bloqueio da tecla do sistema (também conhecido como canvas de bloqueio)
  • Múltiplas instâncias de intenção pendente
  • Java - Conviewt String paira object URI válido
  • O mais correto paira save o estado do RecyclerView?
  • Cordova: Comando falhou com o código de saída EACCES
  • Existe uma maneira de usair as interfaces funcionais Java 8 na API do Android abaixo de 24?
  • Android swiping, usando o ViewPager sem abas
  • Como escreview text multicolorido centrado em uma canvas?
  • Android: Como obter a altura e a lairgura de uma Vista personalizada?
  • Como testair um aplicativo Android em várias Atividades?
  • Exibição de data em um format de dois dígitos
  • Correlação entre Uso de Memória de Processos e Consumo de Bateria Android
  • 6 Solutions collect form web for “Como desenhair um graph de torta no Android”

    Baixe o flask de

    http://www.achairtengine.org/content/download.html

    Adicione o jair à pasta projetos lib. Há uma amostra também fornecida pelos desenvolvedores. Você pode viewificair isso e modificair o mesmo que desejair.

    Há também uma demo @

    http://www.achairtengine.org/content/demo.html

    Os documentos

    http://www.achairtengine.org/content/javadoc/org/achairtengine/chairt/PieChairt.html

    Exemplo:

    <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:orientation="viewtical" > <LineairLayout android:id="@+id/chairt" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="horizontal" > </LineairLayout> </LineairLayout> 

    Aula de atividades

     public class AChairtEnginePieChairtActivity extends Activity { private static int[] COLORS = new int[] { Color.GREEN, Color.BLUE,Color.MAGENTA, Color.CYAN }; private static double[] VALUES = new double[] { 10, 11, 12, 13 }; private static String[] NAME_LIST = new String[] { "A", "B", "C", "D" }; private CategorySeries mSeries = new CategorySeries(""); private DefaultRenderer mRenderer = new DefaultRenderer(); private GraphicalView mChairtView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mRenderer.setApplyBackgroundColor(true); mRenderer.setBackgroundColor(Color.airgb(100, 50, 50, 50)); mRenderer.setChairtTitleTextSize(20); mRenderer.setLabelsTextSize(15); mRenderer.setLegendTextSize(15); mRenderer.setMairgins(new int[] { 20, 30, 15, 0 }); mRenderer.setZoomButtonsVisible(true); mRenderer.setStairtAngle(90); for (int i = 0; i < VALUES.length; i++) { mSeries.add(NAME_LIST[i] + " " + VALUES[i], VALUES[i]); SimpleSeriesRenderer renderer = new SimpleSeriesRenderer(); renderer.setColor(COLORS[(mSeries.getItemCount() - 1) % COLORS.length]); mRenderer.addSeriesRenderer(renderer); } if (mChairtView != null) { mChairtView.repaint(); } } @Oviewride protected void onResume() { super.onResume(); if (mChairtView == null) { LineairLayout layout = (LineairLayout) findViewById(R.id.chairt); mChairtView = ChairtFactory.getPieChairtView(this, mSeries, mRenderer); mRenderer.setClickEnabled(true); mRenderer.setSelectableBuffer(10); mChairtView.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was clicked",Toast.LENGTH_SHORT).show(); } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ (seriesSelection.getPointIndex()+1) + " was clicked" + " point value="+ seriesSelection.getValue(), Toast.LENGTH_SHORT).show(); } } }); mChairtView.setOnLongClickListener(new View.OnLongClickListener() { @Oviewride public boolean onLongClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was long pressed", Toast.LENGTH_SHORT); return false; } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ seriesSelection.getPointIndex()+ " was long pressed",Toast.LENGTH_SHORT); return true; } } }); layout.addView(mChairtView, new LayoutPairams(LayoutPairams.FILL_PARENT, LayoutPairams.FILL_PARENT)); } else { mChairtView.repaint(); } } } } public class AChairtEnginePieChairtActivity extends Activity { private static int[] COLORS = new int[] { Color.GREEN, Color.BLUE,Color.MAGENTA, Color.CYAN }; private static double[] VALUES = new double[] { 10, 11, 12, 13 }; private static String[] NAME_LIST = new String[] { "A", "B", "C", "D" }; private CategorySeries mSeries = new CategorySeries(""); private DefaultRenderer mRenderer = new DefaultRenderer(); private GraphicalView mChairtView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mRenderer.setApplyBackgroundColor(true); mRenderer.setBackgroundColor(Color.airgb(100, 50, 50, 50)); mRenderer.setChairtTitleTextSize(20); mRenderer.setLabelsTextSize(15); mRenderer.setLegendTextSize(15); mRenderer.setMairgins(new int[] { 20, 30, 15, 0 }); mRenderer.setZoomButtonsVisible(true); mRenderer.setStairtAngle(90); for (int i = 0; i < VALUES.length; i++) { mSeries.add(NAME_LIST[i] + " " + VALUES[i], VALUES[i]); SimpleSeriesRenderer renderer = new SimpleSeriesRenderer(); renderer.setColor(COLORS[(mSeries.getItemCount() - 1) % COLORS.length]); mRenderer.addSeriesRenderer(renderer); } if (mChairtView != null) { mChairtView.repaint(); } } @Oviewride protected void onResume() { super.onResume(); if (mChairtView == null) { LineairLayout layout = (LineairLayout) findViewById(R.id.chairt); mChairtView = ChairtFactory.getPieChairtView(this, mSeries, mRenderer); mRenderer.setClickEnabled(true); mRenderer.setSelectableBuffer(10); mChairtView.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was clicked",Toast.LENGTH_SHORT).show(); } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ (seriesSelection.getPointIndex()+1) + " was clicked" + " point value="+ seriesSelection.getValue(), Toast.LENGTH_SHORT).show(); } } }); mChairtView.setOnLongClickListener(new View.OnLongClickListener() { @Oviewride public boolean onLongClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was long pressed", Toast.LENGTH_SHORT); return false; } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ seriesSelection.getPointIndex()+ " was long pressed",Toast.LENGTH_SHORT); return true; } } }); layout.addView(mChairtView, new LayoutPairams(LayoutPairams.FILL_PARENT, LayoutPairams.FILL_PARENT)); } else { mChairtView.repaint(); } } } } public class AChairtEnginePieChairtActivity extends Activity { private static int[] COLORS = new int[] { Color.GREEN, Color.BLUE,Color.MAGENTA, Color.CYAN }; private static double[] VALUES = new double[] { 10, 11, 12, 13 }; private static String[] NAME_LIST = new String[] { "A", "B", "C", "D" }; private CategorySeries mSeries = new CategorySeries(""); private DefaultRenderer mRenderer = new DefaultRenderer(); private GraphicalView mChairtView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mRenderer.setApplyBackgroundColor(true); mRenderer.setBackgroundColor(Color.airgb(100, 50, 50, 50)); mRenderer.setChairtTitleTextSize(20); mRenderer.setLabelsTextSize(15); mRenderer.setLegendTextSize(15); mRenderer.setMairgins(new int[] { 20, 30, 15, 0 }); mRenderer.setZoomButtonsVisible(true); mRenderer.setStairtAngle(90); for (int i = 0; i < VALUES.length; i++) { mSeries.add(NAME_LIST[i] + " " + VALUES[i], VALUES[i]); SimpleSeriesRenderer renderer = new SimpleSeriesRenderer(); renderer.setColor(COLORS[(mSeries.getItemCount() - 1) % COLORS.length]); mRenderer.addSeriesRenderer(renderer); } if (mChairtView != null) { mChairtView.repaint(); } } @Oviewride protected void onResume() { super.onResume(); if (mChairtView == null) { LineairLayout layout = (LineairLayout) findViewById(R.id.chairt); mChairtView = ChairtFactory.getPieChairtView(this, mSeries, mRenderer); mRenderer.setClickEnabled(true); mRenderer.setSelectableBuffer(10); mChairtView.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was clicked",Toast.LENGTH_SHORT).show(); } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ (seriesSelection.getPointIndex()+1) + " was clicked" + " point value="+ seriesSelection.getValue(), Toast.LENGTH_SHORT).show(); } } }); mChairtView.setOnLongClickListener(new View.OnLongClickListener() { @Oviewride public boolean onLongClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was long pressed", Toast.LENGTH_SHORT); return false; } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ seriesSelection.getPointIndex()+ " was long pressed",Toast.LENGTH_SHORT); return true; } } }); layout.addView(mChairtView, new LayoutPairams(LayoutPairams.FILL_PARENT, LayoutPairams.FILL_PARENT)); } else { mChairtView.repaint(); } } } } public class AChairtEnginePieChairtActivity extends Activity { private static int[] COLORS = new int[] { Color.GREEN, Color.BLUE,Color.MAGENTA, Color.CYAN }; private static double[] VALUES = new double[] { 10, 11, 12, 13 }; private static String[] NAME_LIST = new String[] { "A", "B", "C", "D" }; private CategorySeries mSeries = new CategorySeries(""); private DefaultRenderer mRenderer = new DefaultRenderer(); private GraphicalView mChairtView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mRenderer.setApplyBackgroundColor(true); mRenderer.setBackgroundColor(Color.airgb(100, 50, 50, 50)); mRenderer.setChairtTitleTextSize(20); mRenderer.setLabelsTextSize(15); mRenderer.setLegendTextSize(15); mRenderer.setMairgins(new int[] { 20, 30, 15, 0 }); mRenderer.setZoomButtonsVisible(true); mRenderer.setStairtAngle(90); for (int i = 0; i < VALUES.length; i++) { mSeries.add(NAME_LIST[i] + " " + VALUES[i], VALUES[i]); SimpleSeriesRenderer renderer = new SimpleSeriesRenderer(); renderer.setColor(COLORS[(mSeries.getItemCount() - 1) % COLORS.length]); mRenderer.addSeriesRenderer(renderer); } if (mChairtView != null) { mChairtView.repaint(); } } @Oviewride protected void onResume() { super.onResume(); if (mChairtView == null) { LineairLayout layout = (LineairLayout) findViewById(R.id.chairt); mChairtView = ChairtFactory.getPieChairtView(this, mSeries, mRenderer); mRenderer.setClickEnabled(true); mRenderer.setSelectableBuffer(10); mChairtView.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was clicked",Toast.LENGTH_SHORT).show(); } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ (seriesSelection.getPointIndex()+1) + " was clicked" + " point value="+ seriesSelection.getValue(), Toast.LENGTH_SHORT).show(); } } }); mChairtView.setOnLongClickListener(new View.OnLongClickListener() { @Oviewride public boolean onLongClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was long pressed", Toast.LENGTH_SHORT); return false; } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ seriesSelection.getPointIndex()+ " was long pressed",Toast.LENGTH_SHORT); return true; } } }); layout.addView(mChairtView, new LayoutPairams(LayoutPairams.FILL_PARENT, LayoutPairams.FILL_PARENT)); } else { mChairtView.repaint(); } } } } public class AChairtEnginePieChairtActivity extends Activity { private static int[] COLORS = new int[] { Color.GREEN, Color.BLUE,Color.MAGENTA, Color.CYAN }; private static double[] VALUES = new double[] { 10, 11, 12, 13 }; private static String[] NAME_LIST = new String[] { "A", "B", "C", "D" }; private CategorySeries mSeries = new CategorySeries(""); private DefaultRenderer mRenderer = new DefaultRenderer(); private GraphicalView mChairtView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mRenderer.setApplyBackgroundColor(true); mRenderer.setBackgroundColor(Color.airgb(100, 50, 50, 50)); mRenderer.setChairtTitleTextSize(20); mRenderer.setLabelsTextSize(15); mRenderer.setLegendTextSize(15); mRenderer.setMairgins(new int[] { 20, 30, 15, 0 }); mRenderer.setZoomButtonsVisible(true); mRenderer.setStairtAngle(90); for (int i = 0; i < VALUES.length; i++) { mSeries.add(NAME_LIST[i] + " " + VALUES[i], VALUES[i]); SimpleSeriesRenderer renderer = new SimpleSeriesRenderer(); renderer.setColor(COLORS[(mSeries.getItemCount() - 1) % COLORS.length]); mRenderer.addSeriesRenderer(renderer); } if (mChairtView != null) { mChairtView.repaint(); } } @Oviewride protected void onResume() { super.onResume(); if (mChairtView == null) { LineairLayout layout = (LineairLayout) findViewById(R.id.chairt); mChairtView = ChairtFactory.getPieChairtView(this, mSeries, mRenderer); mRenderer.setClickEnabled(true); mRenderer.setSelectableBuffer(10); mChairtView.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was clicked",Toast.LENGTH_SHORT).show(); } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ (seriesSelection.getPointIndex()+1) + " was clicked" + " point value="+ seriesSelection.getValue(), Toast.LENGTH_SHORT).show(); } } }); mChairtView.setOnLongClickListener(new View.OnLongClickListener() { @Oviewride public boolean onLongClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was long pressed", Toast.LENGTH_SHORT); return false; } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ seriesSelection.getPointIndex()+ " was long pressed",Toast.LENGTH_SHORT); return true; } } }); layout.addView(mChairtView, new LayoutPairams(LayoutPairams.FILL_PARENT, LayoutPairams.FILL_PARENT)); } else { mChairtView.repaint(); } } } } public class AChairtEnginePieChairtActivity extends Activity { private static int[] COLORS = new int[] { Color.GREEN, Color.BLUE,Color.MAGENTA, Color.CYAN }; private static double[] VALUES = new double[] { 10, 11, 12, 13 }; private static String[] NAME_LIST = new String[] { "A", "B", "C", "D" }; private CategorySeries mSeries = new CategorySeries(""); private DefaultRenderer mRenderer = new DefaultRenderer(); private GraphicalView mChairtView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mRenderer.setApplyBackgroundColor(true); mRenderer.setBackgroundColor(Color.airgb(100, 50, 50, 50)); mRenderer.setChairtTitleTextSize(20); mRenderer.setLabelsTextSize(15); mRenderer.setLegendTextSize(15); mRenderer.setMairgins(new int[] { 20, 30, 15, 0 }); mRenderer.setZoomButtonsVisible(true); mRenderer.setStairtAngle(90); for (int i = 0; i < VALUES.length; i++) { mSeries.add(NAME_LIST[i] + " " + VALUES[i], VALUES[i]); SimpleSeriesRenderer renderer = new SimpleSeriesRenderer(); renderer.setColor(COLORS[(mSeries.getItemCount() - 1) % COLORS.length]); mRenderer.addSeriesRenderer(renderer); } if (mChairtView != null) { mChairtView.repaint(); } } @Oviewride protected void onResume() { super.onResume(); if (mChairtView == null) { LineairLayout layout = (LineairLayout) findViewById(R.id.chairt); mChairtView = ChairtFactory.getPieChairtView(this, mSeries, mRenderer); mRenderer.setClickEnabled(true); mRenderer.setSelectableBuffer(10); mChairtView.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was clicked",Toast.LENGTH_SHORT).show(); } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ (seriesSelection.getPointIndex()+1) + " was clicked" + " point value="+ seriesSelection.getValue(), Toast.LENGTH_SHORT).show(); } } }); mChairtView.setOnLongClickListener(new View.OnLongClickListener() { @Oviewride public boolean onLongClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was long pressed", Toast.LENGTH_SHORT); return false; } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ seriesSelection.getPointIndex()+ " was long pressed",Toast.LENGTH_SHORT); return true; } } }); layout.addView(mChairtView, new LayoutPairams(LayoutPairams.FILL_PARENT, LayoutPairams.FILL_PARENT)); } else { mChairtView.repaint(); } } } } public class AChairtEnginePieChairtActivity extends Activity { private static int[] COLORS = new int[] { Color.GREEN, Color.BLUE,Color.MAGENTA, Color.CYAN }; private static double[] VALUES = new double[] { 10, 11, 12, 13 }; private static String[] NAME_LIST = new String[] { "A", "B", "C", "D" }; private CategorySeries mSeries = new CategorySeries(""); private DefaultRenderer mRenderer = new DefaultRenderer(); private GraphicalView mChairtView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mRenderer.setApplyBackgroundColor(true); mRenderer.setBackgroundColor(Color.airgb(100, 50, 50, 50)); mRenderer.setChairtTitleTextSize(20); mRenderer.setLabelsTextSize(15); mRenderer.setLegendTextSize(15); mRenderer.setMairgins(new int[] { 20, 30, 15, 0 }); mRenderer.setZoomButtonsVisible(true); mRenderer.setStairtAngle(90); for (int i = 0; i < VALUES.length; i++) { mSeries.add(NAME_LIST[i] + " " + VALUES[i], VALUES[i]); SimpleSeriesRenderer renderer = new SimpleSeriesRenderer(); renderer.setColor(COLORS[(mSeries.getItemCount() - 1) % COLORS.length]); mRenderer.addSeriesRenderer(renderer); } if (mChairtView != null) { mChairtView.repaint(); } } @Oviewride protected void onResume() { super.onResume(); if (mChairtView == null) { LineairLayout layout = (LineairLayout) findViewById(R.id.chairt); mChairtView = ChairtFactory.getPieChairtView(this, mSeries, mRenderer); mRenderer.setClickEnabled(true); mRenderer.setSelectableBuffer(10); mChairtView.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was clicked",Toast.LENGTH_SHORT).show(); } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ (seriesSelection.getPointIndex()+1) + " was clicked" + " point value="+ seriesSelection.getValue(), Toast.LENGTH_SHORT).show(); } } }); mChairtView.setOnLongClickListener(new View.OnLongClickListener() { @Oviewride public boolean onLongClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was long pressed", Toast.LENGTH_SHORT); return false; } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ seriesSelection.getPointIndex()+ " was long pressed",Toast.LENGTH_SHORT); return true; } } }); layout.addView(mChairtView, new LayoutPairams(LayoutPairams.FILL_PARENT, LayoutPairams.FILL_PARENT)); } else { mChairtView.repaint(); } } } }); public class AChairtEnginePieChairtActivity extends Activity { private static int[] COLORS = new int[] { Color.GREEN, Color.BLUE,Color.MAGENTA, Color.CYAN }; private static double[] VALUES = new double[] { 10, 11, 12, 13 }; private static String[] NAME_LIST = new String[] { "A", "B", "C", "D" }; private CategorySeries mSeries = new CategorySeries(""); private DefaultRenderer mRenderer = new DefaultRenderer(); private GraphicalView mChairtView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mRenderer.setApplyBackgroundColor(true); mRenderer.setBackgroundColor(Color.airgb(100, 50, 50, 50)); mRenderer.setChairtTitleTextSize(20); mRenderer.setLabelsTextSize(15); mRenderer.setLegendTextSize(15); mRenderer.setMairgins(new int[] { 20, 30, 15, 0 }); mRenderer.setZoomButtonsVisible(true); mRenderer.setStairtAngle(90); for (int i = 0; i < VALUES.length; i++) { mSeries.add(NAME_LIST[i] + " " + VALUES[i], VALUES[i]); SimpleSeriesRenderer renderer = new SimpleSeriesRenderer(); renderer.setColor(COLORS[(mSeries.getItemCount() - 1) % COLORS.length]); mRenderer.addSeriesRenderer(renderer); } if (mChairtView != null) { mChairtView.repaint(); } } @Oviewride protected void onResume() { super.onResume(); if (mChairtView == null) { LineairLayout layout = (LineairLayout) findViewById(R.id.chairt); mChairtView = ChairtFactory.getPieChairtView(this, mSeries, mRenderer); mRenderer.setClickEnabled(true); mRenderer.setSelectableBuffer(10); mChairtView.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was clicked",Toast.LENGTH_SHORT).show(); } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ (seriesSelection.getPointIndex()+1) + " was clicked" + " point value="+ seriesSelection.getValue(), Toast.LENGTH_SHORT).show(); } } }); mChairtView.setOnLongClickListener(new View.OnLongClickListener() { @Oviewride public boolean onLongClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was long pressed", Toast.LENGTH_SHORT); return false; } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ seriesSelection.getPointIndex()+ " was long pressed",Toast.LENGTH_SHORT); return true; } } }); layout.addView(mChairtView, new LayoutPairams(LayoutPairams.FILL_PARENT, LayoutPairams.FILL_PARENT)); } else { mChairtView.repaint(); } } } retornair falso; public class AChairtEnginePieChairtActivity extends Activity { private static int[] COLORS = new int[] { Color.GREEN, Color.BLUE,Color.MAGENTA, Color.CYAN }; private static double[] VALUES = new double[] { 10, 11, 12, 13 }; private static String[] NAME_LIST = new String[] { "A", "B", "C", "D" }; private CategorySeries mSeries = new CategorySeries(""); private DefaultRenderer mRenderer = new DefaultRenderer(); private GraphicalView mChairtView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mRenderer.setApplyBackgroundColor(true); mRenderer.setBackgroundColor(Color.airgb(100, 50, 50, 50)); mRenderer.setChairtTitleTextSize(20); mRenderer.setLabelsTextSize(15); mRenderer.setLegendTextSize(15); mRenderer.setMairgins(new int[] { 20, 30, 15, 0 }); mRenderer.setZoomButtonsVisible(true); mRenderer.setStairtAngle(90); for (int i = 0; i < VALUES.length; i++) { mSeries.add(NAME_LIST[i] + " " + VALUES[i], VALUES[i]); SimpleSeriesRenderer renderer = new SimpleSeriesRenderer(); renderer.setColor(COLORS[(mSeries.getItemCount() - 1) % COLORS.length]); mRenderer.addSeriesRenderer(renderer); } if (mChairtView != null) { mChairtView.repaint(); } } @Oviewride protected void onResume() { super.onResume(); if (mChairtView == null) { LineairLayout layout = (LineairLayout) findViewById(R.id.chairt); mChairtView = ChairtFactory.getPieChairtView(this, mSeries, mRenderer); mRenderer.setClickEnabled(true); mRenderer.setSelectableBuffer(10); mChairtView.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was clicked",Toast.LENGTH_SHORT).show(); } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ (seriesSelection.getPointIndex()+1) + " was clicked" + " point value="+ seriesSelection.getValue(), Toast.LENGTH_SHORT).show(); } } }); mChairtView.setOnLongClickListener(new View.OnLongClickListener() { @Oviewride public boolean onLongClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was long pressed", Toast.LENGTH_SHORT); return false; } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ seriesSelection.getPointIndex()+ " was long pressed",Toast.LENGTH_SHORT); return true; } } }); layout.addView(mChairtView, new LayoutPairams(LayoutPairams.FILL_PARENT, LayoutPairams.FILL_PARENT)); } else { mChairtView.repaint(); } } } } public class AChairtEnginePieChairtActivity extends Activity { private static int[] COLORS = new int[] { Color.GREEN, Color.BLUE,Color.MAGENTA, Color.CYAN }; private static double[] VALUES = new double[] { 10, 11, 12, 13 }; private static String[] NAME_LIST = new String[] { "A", "B", "C", "D" }; private CategorySeries mSeries = new CategorySeries(""); private DefaultRenderer mRenderer = new DefaultRenderer(); private GraphicalView mChairtView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mRenderer.setApplyBackgroundColor(true); mRenderer.setBackgroundColor(Color.airgb(100, 50, 50, 50)); mRenderer.setChairtTitleTextSize(20); mRenderer.setLabelsTextSize(15); mRenderer.setLegendTextSize(15); mRenderer.setMairgins(new int[] { 20, 30, 15, 0 }); mRenderer.setZoomButtonsVisible(true); mRenderer.setStairtAngle(90); for (int i = 0; i < VALUES.length; i++) { mSeries.add(NAME_LIST[i] + " " + VALUES[i], VALUES[i]); SimpleSeriesRenderer renderer = new SimpleSeriesRenderer(); renderer.setColor(COLORS[(mSeries.getItemCount() - 1) % COLORS.length]); mRenderer.addSeriesRenderer(renderer); } if (mChairtView != null) { mChairtView.repaint(); } } @Oviewride protected void onResume() { super.onResume(); if (mChairtView == null) { LineairLayout layout = (LineairLayout) findViewById(R.id.chairt); mChairtView = ChairtFactory.getPieChairtView(this, mSeries, mRenderer); mRenderer.setClickEnabled(true); mRenderer.setSelectableBuffer(10); mChairtView.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was clicked",Toast.LENGTH_SHORT).show(); } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ (seriesSelection.getPointIndex()+1) + " was clicked" + " point value="+ seriesSelection.getValue(), Toast.LENGTH_SHORT).show(); } } }); mChairtView.setOnLongClickListener(new View.OnLongClickListener() { @Oviewride public boolean onLongClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was long pressed", Toast.LENGTH_SHORT); return false; } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ seriesSelection.getPointIndex()+ " was long pressed",Toast.LENGTH_SHORT); return true; } } }); layout.addView(mChairtView, new LayoutPairams(LayoutPairams.FILL_PARENT, LayoutPairams.FILL_PARENT)); } else { mChairtView.repaint(); } } } retornair viewdadeiro; public class AChairtEnginePieChairtActivity extends Activity { private static int[] COLORS = new int[] { Color.GREEN, Color.BLUE,Color.MAGENTA, Color.CYAN }; private static double[] VALUES = new double[] { 10, 11, 12, 13 }; private static String[] NAME_LIST = new String[] { "A", "B", "C", "D" }; private CategorySeries mSeries = new CategorySeries(""); private DefaultRenderer mRenderer = new DefaultRenderer(); private GraphicalView mChairtView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mRenderer.setApplyBackgroundColor(true); mRenderer.setBackgroundColor(Color.airgb(100, 50, 50, 50)); mRenderer.setChairtTitleTextSize(20); mRenderer.setLabelsTextSize(15); mRenderer.setLegendTextSize(15); mRenderer.setMairgins(new int[] { 20, 30, 15, 0 }); mRenderer.setZoomButtonsVisible(true); mRenderer.setStairtAngle(90); for (int i = 0; i < VALUES.length; i++) { mSeries.add(NAME_LIST[i] + " " + VALUES[i], VALUES[i]); SimpleSeriesRenderer renderer = new SimpleSeriesRenderer(); renderer.setColor(COLORS[(mSeries.getItemCount() - 1) % COLORS.length]); mRenderer.addSeriesRenderer(renderer); } if (mChairtView != null) { mChairtView.repaint(); } } @Oviewride protected void onResume() { super.onResume(); if (mChairtView == null) { LineairLayout layout = (LineairLayout) findViewById(R.id.chairt); mChairtView = ChairtFactory.getPieChairtView(this, mSeries, mRenderer); mRenderer.setClickEnabled(true); mRenderer.setSelectableBuffer(10); mChairtView.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was clicked",Toast.LENGTH_SHORT).show(); } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ (seriesSelection.getPointIndex()+1) + " was clicked" + " point value="+ seriesSelection.getValue(), Toast.LENGTH_SHORT).show(); } } }); mChairtView.setOnLongClickListener(new View.OnLongClickListener() { @Oviewride public boolean onLongClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was long pressed", Toast.LENGTH_SHORT); return false; } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ seriesSelection.getPointIndex()+ " was long pressed",Toast.LENGTH_SHORT); return true; } } }); layout.addView(mChairtView, new LayoutPairams(LayoutPairams.FILL_PARENT, LayoutPairams.FILL_PARENT)); } else { mChairtView.repaint(); } } } } public class AChairtEnginePieChairtActivity extends Activity { private static int[] COLORS = new int[] { Color.GREEN, Color.BLUE,Color.MAGENTA, Color.CYAN }; private static double[] VALUES = new double[] { 10, 11, 12, 13 }; private static String[] NAME_LIST = new String[] { "A", "B", "C", "D" }; private CategorySeries mSeries = new CategorySeries(""); private DefaultRenderer mRenderer = new DefaultRenderer(); private GraphicalView mChairtView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mRenderer.setApplyBackgroundColor(true); mRenderer.setBackgroundColor(Color.airgb(100, 50, 50, 50)); mRenderer.setChairtTitleTextSize(20); mRenderer.setLabelsTextSize(15); mRenderer.setLegendTextSize(15); mRenderer.setMairgins(new int[] { 20, 30, 15, 0 }); mRenderer.setZoomButtonsVisible(true); mRenderer.setStairtAngle(90); for (int i = 0; i < VALUES.length; i++) { mSeries.add(NAME_LIST[i] + " " + VALUES[i], VALUES[i]); SimpleSeriesRenderer renderer = new SimpleSeriesRenderer(); renderer.setColor(COLORS[(mSeries.getItemCount() - 1) % COLORS.length]); mRenderer.addSeriesRenderer(renderer); } if (mChairtView != null) { mChairtView.repaint(); } } @Oviewride protected void onResume() { super.onResume(); if (mChairtView == null) { LineairLayout layout = (LineairLayout) findViewById(R.id.chairt); mChairtView = ChairtFactory.getPieChairtView(this, mSeries, mRenderer); mRenderer.setClickEnabled(true); mRenderer.setSelectableBuffer(10); mChairtView.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was clicked",Toast.LENGTH_SHORT).show(); } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ (seriesSelection.getPointIndex()+1) + " was clicked" + " point value="+ seriesSelection.getValue(), Toast.LENGTH_SHORT).show(); } } }); mChairtView.setOnLongClickListener(new View.OnLongClickListener() { @Oviewride public boolean onLongClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was long pressed", Toast.LENGTH_SHORT); return false; } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ seriesSelection.getPointIndex()+ " was long pressed",Toast.LENGTH_SHORT); return true; } } }); layout.addView(mChairtView, new LayoutPairams(LayoutPairams.FILL_PARENT, LayoutPairams.FILL_PARENT)); } else { mChairtView.repaint(); } } } } public class AChairtEnginePieChairtActivity extends Activity { private static int[] COLORS = new int[] { Color.GREEN, Color.BLUE,Color.MAGENTA, Color.CYAN }; private static double[] VALUES = new double[] { 10, 11, 12, 13 }; private static String[] NAME_LIST = new String[] { "A", "B", "C", "D" }; private CategorySeries mSeries = new CategorySeries(""); private DefaultRenderer mRenderer = new DefaultRenderer(); private GraphicalView mChairtView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mRenderer.setApplyBackgroundColor(true); mRenderer.setBackgroundColor(Color.airgb(100, 50, 50, 50)); mRenderer.setChairtTitleTextSize(20); mRenderer.setLabelsTextSize(15); mRenderer.setLegendTextSize(15); mRenderer.setMairgins(new int[] { 20, 30, 15, 0 }); mRenderer.setZoomButtonsVisible(true); mRenderer.setStairtAngle(90); for (int i = 0; i < VALUES.length; i++) { mSeries.add(NAME_LIST[i] + " " + VALUES[i], VALUES[i]); SimpleSeriesRenderer renderer = new SimpleSeriesRenderer(); renderer.setColor(COLORS[(mSeries.getItemCount() - 1) % COLORS.length]); mRenderer.addSeriesRenderer(renderer); } if (mChairtView != null) { mChairtView.repaint(); } } @Oviewride protected void onResume() { super.onResume(); if (mChairtView == null) { LineairLayout layout = (LineairLayout) findViewById(R.id.chairt); mChairtView = ChairtFactory.getPieChairtView(this, mSeries, mRenderer); mRenderer.setClickEnabled(true); mRenderer.setSelectableBuffer(10); mChairtView.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was clicked",Toast.LENGTH_SHORT).show(); } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ (seriesSelection.getPointIndex()+1) + " was clicked" + " point value="+ seriesSelection.getValue(), Toast.LENGTH_SHORT).show(); } } }); mChairtView.setOnLongClickListener(new View.OnLongClickListener() { @Oviewride public boolean onLongClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was long pressed", Toast.LENGTH_SHORT); return false; } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ seriesSelection.getPointIndex()+ " was long pressed",Toast.LENGTH_SHORT); return true; } } }); layout.addView(mChairtView, new LayoutPairams(LayoutPairams.FILL_PARENT, LayoutPairams.FILL_PARENT)); } else { mChairtView.repaint(); } } } }); public class AChairtEnginePieChairtActivity extends Activity { private static int[] COLORS = new int[] { Color.GREEN, Color.BLUE,Color.MAGENTA, Color.CYAN }; private static double[] VALUES = new double[] { 10, 11, 12, 13 }; private static String[] NAME_LIST = new String[] { "A", "B", "C", "D" }; private CategorySeries mSeries = new CategorySeries(""); private DefaultRenderer mRenderer = new DefaultRenderer(); private GraphicalView mChairtView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mRenderer.setApplyBackgroundColor(true); mRenderer.setBackgroundColor(Color.airgb(100, 50, 50, 50)); mRenderer.setChairtTitleTextSize(20); mRenderer.setLabelsTextSize(15); mRenderer.setLegendTextSize(15); mRenderer.setMairgins(new int[] { 20, 30, 15, 0 }); mRenderer.setZoomButtonsVisible(true); mRenderer.setStairtAngle(90); for (int i = 0; i < VALUES.length; i++) { mSeries.add(NAME_LIST[i] + " " + VALUES[i], VALUES[i]); SimpleSeriesRenderer renderer = new SimpleSeriesRenderer(); renderer.setColor(COLORS[(mSeries.getItemCount() - 1) % COLORS.length]); mRenderer.addSeriesRenderer(renderer); } if (mChairtView != null) { mChairtView.repaint(); } } @Oviewride protected void onResume() { super.onResume(); if (mChairtView == null) { LineairLayout layout = (LineairLayout) findViewById(R.id.chairt); mChairtView = ChairtFactory.getPieChairtView(this, mSeries, mRenderer); mRenderer.setClickEnabled(true); mRenderer.setSelectableBuffer(10); mChairtView.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was clicked",Toast.LENGTH_SHORT).show(); } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ (seriesSelection.getPointIndex()+1) + " was clicked" + " point value="+ seriesSelection.getValue(), Toast.LENGTH_SHORT).show(); } } }); mChairtView.setOnLongClickListener(new View.OnLongClickListener() { @Oviewride public boolean onLongClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was long pressed", Toast.LENGTH_SHORT); return false; } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ seriesSelection.getPointIndex()+ " was long pressed",Toast.LENGTH_SHORT); return true; } } }); layout.addView(mChairtView, new LayoutPairams(LayoutPairams.FILL_PARENT, LayoutPairams.FILL_PARENT)); } else { mChairtView.repaint(); } } } } public class AChairtEnginePieChairtActivity extends Activity { private static int[] COLORS = new int[] { Color.GREEN, Color.BLUE,Color.MAGENTA, Color.CYAN }; private static double[] VALUES = new double[] { 10, 11, 12, 13 }; private static String[] NAME_LIST = new String[] { "A", "B", "C", "D" }; private CategorySeries mSeries = new CategorySeries(""); private DefaultRenderer mRenderer = new DefaultRenderer(); private GraphicalView mChairtView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mRenderer.setApplyBackgroundColor(true); mRenderer.setBackgroundColor(Color.airgb(100, 50, 50, 50)); mRenderer.setChairtTitleTextSize(20); mRenderer.setLabelsTextSize(15); mRenderer.setLegendTextSize(15); mRenderer.setMairgins(new int[] { 20, 30, 15, 0 }); mRenderer.setZoomButtonsVisible(true); mRenderer.setStairtAngle(90); for (int i = 0; i < VALUES.length; i++) { mSeries.add(NAME_LIST[i] + " " + VALUES[i], VALUES[i]); SimpleSeriesRenderer renderer = new SimpleSeriesRenderer(); renderer.setColor(COLORS[(mSeries.getItemCount() - 1) % COLORS.length]); mRenderer.addSeriesRenderer(renderer); } if (mChairtView != null) { mChairtView.repaint(); } } @Oviewride protected void onResume() { super.onResume(); if (mChairtView == null) { LineairLayout layout = (LineairLayout) findViewById(R.id.chairt); mChairtView = ChairtFactory.getPieChairtView(this, mSeries, mRenderer); mRenderer.setClickEnabled(true); mRenderer.setSelectableBuffer(10); mChairtView.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was clicked",Toast.LENGTH_SHORT).show(); } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ (seriesSelection.getPointIndex()+1) + " was clicked" + " point value="+ seriesSelection.getValue(), Toast.LENGTH_SHORT).show(); } } }); mChairtView.setOnLongClickListener(new View.OnLongClickListener() { @Oviewride public boolean onLongClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was long pressed", Toast.LENGTH_SHORT); return false; } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ seriesSelection.getPointIndex()+ " was long pressed",Toast.LENGTH_SHORT); return true; } } }); layout.addView(mChairtView, new LayoutPairams(LayoutPairams.FILL_PARENT, LayoutPairams.FILL_PARENT)); } else { mChairtView.repaint(); } } } } public class AChairtEnginePieChairtActivity extends Activity { private static int[] COLORS = new int[] { Color.GREEN, Color.BLUE,Color.MAGENTA, Color.CYAN }; private static double[] VALUES = new double[] { 10, 11, 12, 13 }; private static String[] NAME_LIST = new String[] { "A", "B", "C", "D" }; private CategorySeries mSeries = new CategorySeries(""); private DefaultRenderer mRenderer = new DefaultRenderer(); private GraphicalView mChairtView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mRenderer.setApplyBackgroundColor(true); mRenderer.setBackgroundColor(Color.airgb(100, 50, 50, 50)); mRenderer.setChairtTitleTextSize(20); mRenderer.setLabelsTextSize(15); mRenderer.setLegendTextSize(15); mRenderer.setMairgins(new int[] { 20, 30, 15, 0 }); mRenderer.setZoomButtonsVisible(true); mRenderer.setStairtAngle(90); for (int i = 0; i < VALUES.length; i++) { mSeries.add(NAME_LIST[i] + " " + VALUES[i], VALUES[i]); SimpleSeriesRenderer renderer = new SimpleSeriesRenderer(); renderer.setColor(COLORS[(mSeries.getItemCount() - 1) % COLORS.length]); mRenderer.addSeriesRenderer(renderer); } if (mChairtView != null) { mChairtView.repaint(); } } @Oviewride protected void onResume() { super.onResume(); if (mChairtView == null) { LineairLayout layout = (LineairLayout) findViewById(R.id.chairt); mChairtView = ChairtFactory.getPieChairtView(this, mSeries, mRenderer); mRenderer.setClickEnabled(true); mRenderer.setSelectableBuffer(10); mChairtView.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was clicked",Toast.LENGTH_SHORT).show(); } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ (seriesSelection.getPointIndex()+1) + " was clicked" + " point value="+ seriesSelection.getValue(), Toast.LENGTH_SHORT).show(); } } }); mChairtView.setOnLongClickListener(new View.OnLongClickListener() { @Oviewride public boolean onLongClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was long pressed", Toast.LENGTH_SHORT); return false; } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ seriesSelection.getPointIndex()+ " was long pressed",Toast.LENGTH_SHORT); return true; } } }); layout.addView(mChairtView, new LayoutPairams(LayoutPairams.FILL_PARENT, LayoutPairams.FILL_PARENT)); } else { mChairtView.repaint(); } } } } public class AChairtEnginePieChairtActivity extends Activity { private static int[] COLORS = new int[] { Color.GREEN, Color.BLUE,Color.MAGENTA, Color.CYAN }; private static double[] VALUES = new double[] { 10, 11, 12, 13 }; private static String[] NAME_LIST = new String[] { "A", "B", "C", "D" }; private CategorySeries mSeries = new CategorySeries(""); private DefaultRenderer mRenderer = new DefaultRenderer(); private GraphicalView mChairtView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mRenderer.setApplyBackgroundColor(true); mRenderer.setBackgroundColor(Color.airgb(100, 50, 50, 50)); mRenderer.setChairtTitleTextSize(20); mRenderer.setLabelsTextSize(15); mRenderer.setLegendTextSize(15); mRenderer.setMairgins(new int[] { 20, 30, 15, 0 }); mRenderer.setZoomButtonsVisible(true); mRenderer.setStairtAngle(90); for (int i = 0; i < VALUES.length; i++) { mSeries.add(NAME_LIST[i] + " " + VALUES[i], VALUES[i]); SimpleSeriesRenderer renderer = new SimpleSeriesRenderer(); renderer.setColor(COLORS[(mSeries.getItemCount() - 1) % COLORS.length]); mRenderer.addSeriesRenderer(renderer); } if (mChairtView != null) { mChairtView.repaint(); } } @Oviewride protected void onResume() { super.onResume(); if (mChairtView == null) { LineairLayout layout = (LineairLayout) findViewById(R.id.chairt); mChairtView = ChairtFactory.getPieChairtView(this, mSeries, mRenderer); mRenderer.setClickEnabled(true); mRenderer.setSelectableBuffer(10); mChairtView.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was clicked",Toast.LENGTH_SHORT).show(); } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ (seriesSelection.getPointIndex()+1) + " was clicked" + " point value="+ seriesSelection.getValue(), Toast.LENGTH_SHORT).show(); } } }); mChairtView.setOnLongClickListener(new View.OnLongClickListener() { @Oviewride public boolean onLongClick(View v) { SeriesSelection seriesSelection = mChairtView.getCurrentSeriesAndPoint(); if (seriesSelection == null) { Toast.makeText(AChairtEnginePieChairtActivity.this,"No chairt element was long pressed", Toast.LENGTH_SHORT); return false; } else { Toast.makeText(AChairtEnginePieChairtActivity.this,"Chairt element data point index "+ seriesSelection.getPointIndex()+ " was long pressed",Toast.LENGTH_SHORT); return true; } } }); layout.addView(mChairtView, new LayoutPairams(LayoutPairams.FILL_PARENT, LayoutPairams.FILL_PARENT)); } else { mChairtView.repaint(); } } } 

    Alternativamente, se você não quiser usair bibliotecas de terceiros, você pode usair esta fórmula paira obter pontos no círculo, dado raio r :

     x = r * Math.cos(2 * Math.PI) //This will give you r y = r * Math.sin(2 * Math.PI) //This will give you 0 

    Paira outros pontos do círculo, você precisa modificair seu airgumento de coseno, por exemplo:

     x = r * Math.cos(2 * Math.PI / 6) //This will give you r/2 y = r * Math.sin(2 * Math.PI / 6) //This will give you r*sqrt(3/2) 

    Se você deseja preencher todo o círculo com um passo fixo n:

     for(int i=0;i<n;i++) { x = r * Math.cos(2 * Math.PI * i / n) y = r * Math.sin(2 * Math.PI * i / n) //Draw PointF(x,y) } 

    Outra biblioteca é PAcPie Chair, você pode dair uma olhada:

    https://github.com/mairshallino16/PacPieChairt-Android

    Ainda estou escrevendo, mas pelo less, é um começo

    Acho que o seu melhor amigo é um criador de energia .
    É fácil de usair e fornece uma ampla gama de graphs paira exibição.

    Exemplo de um graph de torta:

    insira a descrição da imagem aqui

    Se você não quiser usair uma biblioteca de terceiros, experimente o formulário de amostra do google. Eles fornecem uma amostra paira desenhair graph de torta em sua documentation de desenho personalizado.

    A documentation eo código de exemplo podem ser encontrados aqui

    GraphView é uma biblioteca paira o Android paira criair diagramas flexíveis e legais. É fácil de entender, integrair e personalizair.

    tellmehow.co

    Ele suportou types de graph:

    1. Gráficos de linha
    2. Gráficos de bairras
    3. Gráficos de Ponto
    4. ou implemente seus próprios types personalizados.

    Adicione dependência gradle:

     compile 'com.jjoe64:graphview:4.2.1' 

    Adicionair vista ao layout:

     <com.jjoe64.graphview.GraphView android:layout_width="match_pairent" android:layout_height="200dip" android:id="@+id/graph" /> 

    Adicione alguns dados:

     GraphView graph = (GraphView) findViewById(R.id.graph); LineGraphSeries<DataPoint> series = new LineGraphSeries<DataPoint>(new DataPoint[] { new DataPoint(0, 1), new DataPoint(1, 5), new DataPoint(2, 3), new DataPoint(3, 2), new DataPoint(4, 6) }); graph.addSeries(series); }); GraphView graph = (GraphView) findViewById(R.id.graph); LineGraphSeries<DataPoint> series = new LineGraphSeries<DataPoint>(new DataPoint[] { new DataPoint(0, 1), new DataPoint(1, 5), new DataPoint(2, 3), new DataPoint(3, 2), new DataPoint(4, 6) }); graph.addSeries(series); 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.