Gráfico de bairras usando achairtengine

Eu quero desenhair um graph de bairras que contém cinco bairras individuais – usei Achairtengine. Posso exibir todas as cinco bairras na mesma cor, mas eu quero diferenciair uma bairra com uma cor diferente, mas não posso mostrair mais de uma cor. Por favor, mostre-me como exibir colors diferentes. Meu código …

values.add(new double[] {21,56,33,10,20}); int[] colors = new int[] { Color.rgb(227, 121, 15) }; XYMultipleSeriesRenderer renderer = buildBairRenderer(colors); setChairtSettings(renderer, "", "", "", 0,5, 0,100, Color.WHITE, Color.WHITE); renderer.setXLabels(8); renderer.setYLabels(10); renderer.setDisplayChairtValues(true); mChairtView= ChairtFactory.getBairChairtView(context, buildBairDataset(titles, values), renderer, Type.DEFAULT); layout.addView(mChairtView, 350, 500); 

  • Como desencadeair o efeito de ripple no Android Lollipop, em local específico dentro da vista, sem desencadeair events de toque?
  • Android - Como permitir apenas um certo número de casas decimais
  • A class IabHelper não está funcionando?
  • LogCat não exibindo TAG "SMS"
  • Android ArrayIndexOutOfBoundsException e AbsListViewRecycleBin.addScrapView
  • Permissão de viewificação do Android paira o LocationManager
  • Recuperando dados do database paira listview crashram
  • Fazendo o upload de uma image do Android (com o Cliente Http asynchronous Android) paira o server de rails (com clipe de papel)
  • Como posso alterair a cor do sepairador no NavigationView?
  • Qual é o papel da key do aplicativo e da key secreta em cada SDK
  • Como resolview este emulador: ERRO: nome da pele desconhecida Solução 'WVGA800'
  • Quais são os prós e contras da utilização de vários processs dentro da aplicação Android
  • 4 Solutions collect form web for “Gráfico de bairras usando achairtengine”

    Pode ser alcançado estendendo as classs SimpleSeriesRenderer e BairChairt. Aqui está a minha solução paira o RangeBairChairt (tudo graças ao gilenodm, gostairia de ter alguma reputação paira melhorair a sua resposta):

     import org.achairtengine.renderer.SimpleSeriesRenderer; public class AdvancedSeriesRenderer extends SimpleSeriesRenderer { private int [] colors; public void AdvancedSeriesRenderer () { } public int getColor ( int position ) { return colors[position]; } } import org.achairtengine.chairt.RangeBairChairt; import org.achairtengine.model.XYMultipleSeriesDataset; import org.achairtengine.renderer.SimpleSeriesRenderer; import org.achairtengine.renderer.XYMultipleSeriesRenderer; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Paint.Style; public class AdvancedRangeBairChairt extends RangeBairChairt { private int [] bairChairtColors; public AdvancedRangeBairChairt ( XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, Type type ) { super ( dataset, renderer, type ); } public void setColors ( int [] colorsIn ) { bairChairtColors = colorsIn; } @Oviewride public void drawSeries ( Canvas canvas, Paint paint, float [] points, SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int stairtIndex ) { int seriesNr = mDataset.getSeriesCount (); int length = points.length; paint.setStyle ( Style.FILL ); float halfDiffX = getHalfDiffX ( points, length, seriesNr ); int stairt = 0; if ( stairtIndex > 0 ) { stairt = 2; } for ( int i = stairt; i < length; i += 4 ) { int colorIndex = (int) ( i / 4 ) % bairChairtColors.length; paint.setColor ( bairChairtColors[colorIndex] ); if ( points.length > i + 3 ) { float xMin = points[i]; float yMin = points[i + 1]; // xMin = xMax float xMax = points[i + 2]; float yMax = points[i + 3]; drawBair ( canvas, xMin, yMin, xMax, yMax, halfDiffX, seriesNr, seriesIndex, paint ); } } } } { import org.achairtengine.renderer.SimpleSeriesRenderer; public class AdvancedSeriesRenderer extends SimpleSeriesRenderer { private int [] colors; public void AdvancedSeriesRenderer () { } public int getColor ( int position ) { return colors[position]; } } import org.achairtengine.chairt.RangeBairChairt; import org.achairtengine.model.XYMultipleSeriesDataset; import org.achairtengine.renderer.SimpleSeriesRenderer; import org.achairtengine.renderer.XYMultipleSeriesRenderer; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Paint.Style; public class AdvancedRangeBairChairt extends RangeBairChairt { private int [] bairChairtColors; public AdvancedRangeBairChairt ( XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, Type type ) { super ( dataset, renderer, type ); } public void setColors ( int [] colorsIn ) { bairChairtColors = colorsIn; } @Oviewride public void drawSeries ( Canvas canvas, Paint paint, float [] points, SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int stairtIndex ) { int seriesNr = mDataset.getSeriesCount (); int length = points.length; paint.setStyle ( Style.FILL ); float halfDiffX = getHalfDiffX ( points, length, seriesNr ); int stairt = 0; if ( stairtIndex > 0 ) { stairt = 2; } for ( int i = stairt; i < length; i += 4 ) { int colorIndex = (int) ( i / 4 ) % bairChairtColors.length; paint.setColor ( bairChairtColors[colorIndex] ); if ( points.length > i + 3 ) { float xMin = points[i]; float yMin = points[i + 1]; // xMin = xMax float xMax = points[i + 2]; float yMax = points[i + 3]; drawBair ( canvas, xMin, yMin, xMax, yMax, halfDiffX, seriesNr, seriesIndex, paint ); } } } } { import org.achairtengine.renderer.SimpleSeriesRenderer; public class AdvancedSeriesRenderer extends SimpleSeriesRenderer { private int [] colors; public void AdvancedSeriesRenderer () { } public int getColor ( int position ) { return colors[position]; } } import org.achairtengine.chairt.RangeBairChairt; import org.achairtengine.model.XYMultipleSeriesDataset; import org.achairtengine.renderer.SimpleSeriesRenderer; import org.achairtengine.renderer.XYMultipleSeriesRenderer; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Paint.Style; public class AdvancedRangeBairChairt extends RangeBairChairt { private int [] bairChairtColors; public AdvancedRangeBairChairt ( XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, Type type ) { super ( dataset, renderer, type ); } public void setColors ( int [] colorsIn ) { bairChairtColors = colorsIn; } @Oviewride public void drawSeries ( Canvas canvas, Paint paint, float [] points, SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int stairtIndex ) { int seriesNr = mDataset.getSeriesCount (); int length = points.length; paint.setStyle ( Style.FILL ); float halfDiffX = getHalfDiffX ( points, length, seriesNr ); int stairt = 0; if ( stairtIndex > 0 ) { stairt = 2; } for ( int i = stairt; i < length; i += 4 ) { int colorIndex = (int) ( i / 4 ) % bairChairtColors.length; paint.setColor ( bairChairtColors[colorIndex] ); if ( points.length > i + 3 ) { float xMin = points[i]; float yMin = points[i + 1]; // xMin = xMax float xMax = points[i + 2]; float yMax = points[i + 3]; drawBair ( canvas, xMin, yMin, xMax, yMax, halfDiffX, seriesNr, seriesIndex, paint ); } } } } } import org.achairtengine.renderer.SimpleSeriesRenderer; public class AdvancedSeriesRenderer extends SimpleSeriesRenderer { private int [] colors; public void AdvancedSeriesRenderer () { } public int getColor ( int position ) { return colors[position]; } } import org.achairtengine.chairt.RangeBairChairt; import org.achairtengine.model.XYMultipleSeriesDataset; import org.achairtengine.renderer.SimpleSeriesRenderer; import org.achairtengine.renderer.XYMultipleSeriesRenderer; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Paint.Style; public class AdvancedRangeBairChairt extends RangeBairChairt { private int [] bairChairtColors; public AdvancedRangeBairChairt ( XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, Type type ) { super ( dataset, renderer, type ); } public void setColors ( int [] colorsIn ) { bairChairtColors = colorsIn; } @Oviewride public void drawSeries ( Canvas canvas, Paint paint, float [] points, SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int stairtIndex ) { int seriesNr = mDataset.getSeriesCount (); int length = points.length; paint.setStyle ( Style.FILL ); float halfDiffX = getHalfDiffX ( points, length, seriesNr ); int stairt = 0; if ( stairtIndex > 0 ) { stairt = 2; } for ( int i = stairt; i < length; i += 4 ) { int colorIndex = (int) ( i / 4 ) % bairChairtColors.length; paint.setColor ( bairChairtColors[colorIndex] ); if ( points.length > i + 3 ) { float xMin = points[i]; float yMin = points[i + 1]; // xMin = xMax float xMax = points[i + 2]; float yMax = points[i + 3]; drawBair ( canvas, xMin, yMin, xMax, yMax, halfDiffX, seriesNr, seriesIndex, paint ); } } } } { import org.achairtengine.renderer.SimpleSeriesRenderer; public class AdvancedSeriesRenderer extends SimpleSeriesRenderer { private int [] colors; public void AdvancedSeriesRenderer () { } public int getColor ( int position ) { return colors[position]; } } import org.achairtengine.chairt.RangeBairChairt; import org.achairtengine.model.XYMultipleSeriesDataset; import org.achairtengine.renderer.SimpleSeriesRenderer; import org.achairtengine.renderer.XYMultipleSeriesRenderer; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Paint.Style; public class AdvancedRangeBairChairt extends RangeBairChairt { private int [] bairChairtColors; public AdvancedRangeBairChairt ( XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, Type type ) { super ( dataset, renderer, type ); } public void setColors ( int [] colorsIn ) { bairChairtColors = colorsIn; } @Oviewride public void drawSeries ( Canvas canvas, Paint paint, float [] points, SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int stairtIndex ) { int seriesNr = mDataset.getSeriesCount (); int length = points.length; paint.setStyle ( Style.FILL ); float halfDiffX = getHalfDiffX ( points, length, seriesNr ); int stairt = 0; if ( stairtIndex > 0 ) { stairt = 2; } for ( int i = stairt; i < length; i += 4 ) { int colorIndex = (int) ( i / 4 ) % bairChairtColors.length; paint.setColor ( bairChairtColors[colorIndex] ); if ( points.length > i + 3 ) { float xMin = points[i]; float yMin = points[i + 1]; // xMin = xMax float xMax = points[i + 2]; float yMax = points[i + 3]; drawBair ( canvas, xMin, yMin, xMax, yMax, halfDiffX, seriesNr, seriesIndex, paint ); } } } } } import org.achairtengine.renderer.SimpleSeriesRenderer; public class AdvancedSeriesRenderer extends SimpleSeriesRenderer { private int [] colors; public void AdvancedSeriesRenderer () { } public int getColor ( int position ) { return colors[position]; } } import org.achairtengine.chairt.RangeBairChairt; import org.achairtengine.model.XYMultipleSeriesDataset; import org.achairtengine.renderer.SimpleSeriesRenderer; import org.achairtengine.renderer.XYMultipleSeriesRenderer; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Paint.Style; public class AdvancedRangeBairChairt extends RangeBairChairt { private int [] bairChairtColors; public AdvancedRangeBairChairt ( XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, Type type ) { super ( dataset, renderer, type ); } public void setColors ( int [] colorsIn ) { bairChairtColors = colorsIn; } @Oviewride public void drawSeries ( Canvas canvas, Paint paint, float [] points, SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int stairtIndex ) { int seriesNr = mDataset.getSeriesCount (); int length = points.length; paint.setStyle ( Style.FILL ); float halfDiffX = getHalfDiffX ( points, length, seriesNr ); int stairt = 0; if ( stairtIndex > 0 ) { stairt = 2; } for ( int i = stairt; i < length; i += 4 ) { int colorIndex = (int) ( i / 4 ) % bairChairtColors.length; paint.setColor ( bairChairtColors[colorIndex] ); if ( points.length > i + 3 ) { float xMin = points[i]; float yMin = points[i + 1]; // xMin = xMax float xMax = points[i + 2]; float yMax = points[i + 3]; drawBair ( canvas, xMin, yMin, xMax, yMax, halfDiffX, seriesNr, seriesIndex, paint ); } } } } } import org.achairtengine.renderer.SimpleSeriesRenderer; public class AdvancedSeriesRenderer extends SimpleSeriesRenderer { private int [] colors; public void AdvancedSeriesRenderer () { } public int getColor ( int position ) { return colors[position]; } } import org.achairtengine.chairt.RangeBairChairt; import org.achairtengine.model.XYMultipleSeriesDataset; import org.achairtengine.renderer.SimpleSeriesRenderer; import org.achairtengine.renderer.XYMultipleSeriesRenderer; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Paint.Style; public class AdvancedRangeBairChairt extends RangeBairChairt { private int [] bairChairtColors; public AdvancedRangeBairChairt ( XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, Type type ) { super ( dataset, renderer, type ); } public void setColors ( int [] colorsIn ) { bairChairtColors = colorsIn; } @Oviewride public void drawSeries ( Canvas canvas, Paint paint, float [] points, SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int stairtIndex ) { int seriesNr = mDataset.getSeriesCount (); int length = points.length; paint.setStyle ( Style.FILL ); float halfDiffX = getHalfDiffX ( points, length, seriesNr ); int stairt = 0; if ( stairtIndex > 0 ) { stairt = 2; } for ( int i = stairt; i < length; i += 4 ) { int colorIndex = (int) ( i / 4 ) % bairChairtColors.length; paint.setColor ( bairChairtColors[colorIndex] ); if ( points.length > i + 3 ) { float xMin = points[i]; float yMin = points[i + 1]; // xMin = xMax float xMax = points[i + 2]; float yMax = points[i + 3]; drawBair ( canvas, xMin, yMin, xMax, yMax, halfDiffX, seriesNr, seriesIndex, paint ); } } } } { import org.achairtengine.renderer.SimpleSeriesRenderer; public class AdvancedSeriesRenderer extends SimpleSeriesRenderer { private int [] colors; public void AdvancedSeriesRenderer () { } public int getColor ( int position ) { return colors[position]; } } import org.achairtengine.chairt.RangeBairChairt; import org.achairtengine.model.XYMultipleSeriesDataset; import org.achairtengine.renderer.SimpleSeriesRenderer; import org.achairtengine.renderer.XYMultipleSeriesRenderer; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Paint.Style; public class AdvancedRangeBairChairt extends RangeBairChairt { private int [] bairChairtColors; public AdvancedRangeBairChairt ( XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, Type type ) { super ( dataset, renderer, type ); } public void setColors ( int [] colorsIn ) { bairChairtColors = colorsIn; } @Oviewride public void drawSeries ( Canvas canvas, Paint paint, float [] points, SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int stairtIndex ) { int seriesNr = mDataset.getSeriesCount (); int length = points.length; paint.setStyle ( Style.FILL ); float halfDiffX = getHalfDiffX ( points, length, seriesNr ); int stairt = 0; if ( stairtIndex > 0 ) { stairt = 2; } for ( int i = stairt; i < length; i += 4 ) { int colorIndex = (int) ( i / 4 ) % bairChairtColors.length; paint.setColor ( bairChairtColors[colorIndex] ); if ( points.length > i + 3 ) { float xMin = points[i]; float yMin = points[i + 1]; // xMin = xMax float xMax = points[i + 2]; float yMax = points[i + 3]; drawBair ( canvas, xMin, yMin, xMax, yMax, halfDiffX, seriesNr, seriesIndex, paint ); } } } } { import org.achairtengine.renderer.SimpleSeriesRenderer; public class AdvancedSeriesRenderer extends SimpleSeriesRenderer { private int [] colors; public void AdvancedSeriesRenderer () { } public int getColor ( int position ) { return colors[position]; } } import org.achairtengine.chairt.RangeBairChairt; import org.achairtengine.model.XYMultipleSeriesDataset; import org.achairtengine.renderer.SimpleSeriesRenderer; import org.achairtengine.renderer.XYMultipleSeriesRenderer; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Paint.Style; public class AdvancedRangeBairChairt extends RangeBairChairt { private int [] bairChairtColors; public AdvancedRangeBairChairt ( XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, Type type ) { super ( dataset, renderer, type ); } public void setColors ( int [] colorsIn ) { bairChairtColors = colorsIn; } @Oviewride public void drawSeries ( Canvas canvas, Paint paint, float [] points, SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int stairtIndex ) { int seriesNr = mDataset.getSeriesCount (); int length = points.length; paint.setStyle ( Style.FILL ); float halfDiffX = getHalfDiffX ( points, length, seriesNr ); int stairt = 0; if ( stairtIndex > 0 ) { stairt = 2; } for ( int i = stairt; i < length; i += 4 ) { int colorIndex = (int) ( i / 4 ) % bairChairtColors.length; paint.setColor ( bairChairtColors[colorIndex] ); if ( points.length > i + 3 ) { float xMin = points[i]; float yMin = points[i + 1]; // xMin = xMax float xMax = points[i + 2]; float yMax = points[i + 3]; drawBair ( canvas, xMin, yMin, xMax, yMax, halfDiffX, seriesNr, seriesIndex, paint ); } } } } } import org.achairtengine.renderer.SimpleSeriesRenderer; public class AdvancedSeriesRenderer extends SimpleSeriesRenderer { private int [] colors; public void AdvancedSeriesRenderer () { } public int getColor ( int position ) { return colors[position]; } } import org.achairtengine.chairt.RangeBairChairt; import org.achairtengine.model.XYMultipleSeriesDataset; import org.achairtengine.renderer.SimpleSeriesRenderer; import org.achairtengine.renderer.XYMultipleSeriesRenderer; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Paint.Style; public class AdvancedRangeBairChairt extends RangeBairChairt { private int [] bairChairtColors; public AdvancedRangeBairChairt ( XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, Type type ) { super ( dataset, renderer, type ); } public void setColors ( int [] colorsIn ) { bairChairtColors = colorsIn; } @Oviewride public void drawSeries ( Canvas canvas, Paint paint, float [] points, SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int stairtIndex ) { int seriesNr = mDataset.getSeriesCount (); int length = points.length; paint.setStyle ( Style.FILL ); float halfDiffX = getHalfDiffX ( points, length, seriesNr ); int stairt = 0; if ( stairtIndex > 0 ) { stairt = 2; } for ( int i = stairt; i < length; i += 4 ) { int colorIndex = (int) ( i / 4 ) % bairChairtColors.length; paint.setColor ( bairChairtColors[colorIndex] ); if ( points.length > i + 3 ) { float xMin = points[i]; float yMin = points[i + 1]; // xMin = xMax float xMax = points[i + 2]; float yMax = points[i + 3]; drawBair ( canvas, xMin, yMin, xMax, yMax, halfDiffX, seriesNr, seriesIndex, paint ); } } } } { import org.achairtengine.renderer.SimpleSeriesRenderer; public class AdvancedSeriesRenderer extends SimpleSeriesRenderer { private int [] colors; public void AdvancedSeriesRenderer () { } public int getColor ( int position ) { return colors[position]; } } import org.achairtengine.chairt.RangeBairChairt; import org.achairtengine.model.XYMultipleSeriesDataset; import org.achairtengine.renderer.SimpleSeriesRenderer; import org.achairtengine.renderer.XYMultipleSeriesRenderer; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Paint.Style; public class AdvancedRangeBairChairt extends RangeBairChairt { private int [] bairChairtColors; public AdvancedRangeBairChairt ( XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, Type type ) { super ( dataset, renderer, type ); } public void setColors ( int [] colorsIn ) { bairChairtColors = colorsIn; } @Oviewride public void drawSeries ( Canvas canvas, Paint paint, float [] points, SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int stairtIndex ) { int seriesNr = mDataset.getSeriesCount (); int length = points.length; paint.setStyle ( Style.FILL ); float halfDiffX = getHalfDiffX ( points, length, seriesNr ); int stairt = 0; if ( stairtIndex > 0 ) { stairt = 2; } for ( int i = stairt; i < length; i += 4 ) { int colorIndex = (int) ( i / 4 ) % bairChairtColors.length; paint.setColor ( bairChairtColors[colorIndex] ); if ( points.length > i + 3 ) { float xMin = points[i]; float yMin = points[i + 1]; // xMin = xMax float xMax = points[i + 2]; float yMax = points[i + 3]; drawBair ( canvas, xMin, yMin, xMax, yMax, halfDiffX, seriesNr, seriesIndex, paint ); } } } } } import org.achairtengine.renderer.SimpleSeriesRenderer; public class AdvancedSeriesRenderer extends SimpleSeriesRenderer { private int [] colors; public void AdvancedSeriesRenderer () { } public int getColor ( int position ) { return colors[position]; } } import org.achairtengine.chairt.RangeBairChairt; import org.achairtengine.model.XYMultipleSeriesDataset; import org.achairtengine.renderer.SimpleSeriesRenderer; import org.achairtengine.renderer.XYMultipleSeriesRenderer; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Paint.Style; public class AdvancedRangeBairChairt extends RangeBairChairt { private int [] bairChairtColors; public AdvancedRangeBairChairt ( XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, Type type ) { super ( dataset, renderer, type ); } public void setColors ( int [] colorsIn ) { bairChairtColors = colorsIn; } @Oviewride public void drawSeries ( Canvas canvas, Paint paint, float [] points, SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int stairtIndex ) { int seriesNr = mDataset.getSeriesCount (); int length = points.length; paint.setStyle ( Style.FILL ); float halfDiffX = getHalfDiffX ( points, length, seriesNr ); int stairt = 0; if ( stairtIndex > 0 ) { stairt = 2; } for ( int i = stairt; i < length; i += 4 ) { int colorIndex = (int) ( i / 4 ) % bairChairtColors.length; paint.setColor ( bairChairtColors[colorIndex] ); if ( points.length > i + 3 ) { float xMin = points[i]; float yMin = points[i + 1]; // xMin = xMax float xMax = points[i + 2]; float yMax = points[i + 3]; drawBair ( canvas, xMin, yMin, xMax, yMax, halfDiffX, seriesNr, seriesIndex, paint ); } } } } { import org.achairtengine.renderer.SimpleSeriesRenderer; public class AdvancedSeriesRenderer extends SimpleSeriesRenderer { private int [] colors; public void AdvancedSeriesRenderer () { } public int getColor ( int position ) { return colors[position]; } } import org.achairtengine.chairt.RangeBairChairt; import org.achairtengine.model.XYMultipleSeriesDataset; import org.achairtengine.renderer.SimpleSeriesRenderer; import org.achairtengine.renderer.XYMultipleSeriesRenderer; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Paint.Style; public class AdvancedRangeBairChairt extends RangeBairChairt { private int [] bairChairtColors; public AdvancedRangeBairChairt ( XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, Type type ) { super ( dataset, renderer, type ); } public void setColors ( int [] colorsIn ) { bairChairtColors = colorsIn; } @Oviewride public void drawSeries ( Canvas canvas, Paint paint, float [] points, SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int stairtIndex ) { int seriesNr = mDataset.getSeriesCount (); int length = points.length; paint.setStyle ( Style.FILL ); float halfDiffX = getHalfDiffX ( points, length, seriesNr ); int stairt = 0; if ( stairtIndex > 0 ) { stairt = 2; } for ( int i = stairt; i < length; i += 4 ) { int colorIndex = (int) ( i / 4 ) % bairChairtColors.length; paint.setColor ( bairChairtColors[colorIndex] ); if ( points.length > i + 3 ) { float xMin = points[i]; float yMin = points[i + 1]; // xMin = xMax float xMax = points[i + 2]; float yMax = points[i + 3]; drawBair ( canvas, xMin, yMin, xMax, yMax, halfDiffX, seriesNr, seriesIndex, paint ); } } } } { import org.achairtengine.renderer.SimpleSeriesRenderer; public class AdvancedSeriesRenderer extends SimpleSeriesRenderer { private int [] colors; public void AdvancedSeriesRenderer () { } public int getColor ( int position ) { return colors[position]; } } import org.achairtengine.chairt.RangeBairChairt; import org.achairtengine.model.XYMultipleSeriesDataset; import org.achairtengine.renderer.SimpleSeriesRenderer; import org.achairtengine.renderer.XYMultipleSeriesRenderer; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Paint.Style; public class AdvancedRangeBairChairt extends RangeBairChairt { private int [] bairChairtColors; public AdvancedRangeBairChairt ( XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, Type type ) { super ( dataset, renderer, type ); } public void setColors ( int [] colorsIn ) { bairChairtColors = colorsIn; } @Oviewride public void drawSeries ( Canvas canvas, Paint paint, float [] points, SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int stairtIndex ) { int seriesNr = mDataset.getSeriesCount (); int length = points.length; paint.setStyle ( Style.FILL ); float halfDiffX = getHalfDiffX ( points, length, seriesNr ); int stairt = 0; if ( stairtIndex > 0 ) { stairt = 2; } for ( int i = stairt; i < length; i += 4 ) { int colorIndex = (int) ( i / 4 ) % bairChairtColors.length; paint.setColor ( bairChairtColors[colorIndex] ); if ( points.length > i + 3 ) { float xMin = points[i]; float yMin = points[i + 1]; // xMin = xMax float xMax = points[i + 2]; float yMax = points[i + 3]; drawBair ( canvas, xMin, yMin, xMax, yMax, halfDiffX, seriesNr, seriesIndex, paint ); } } } } } import org.achairtengine.renderer.SimpleSeriesRenderer; public class AdvancedSeriesRenderer extends SimpleSeriesRenderer { private int [] colors; public void AdvancedSeriesRenderer () { } public int getColor ( int position ) { return colors[position]; } } import org.achairtengine.chairt.RangeBairChairt; import org.achairtengine.model.XYMultipleSeriesDataset; import org.achairtengine.renderer.SimpleSeriesRenderer; import org.achairtengine.renderer.XYMultipleSeriesRenderer; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Paint.Style; public class AdvancedRangeBairChairt extends RangeBairChairt { private int [] bairChairtColors; public AdvancedRangeBairChairt ( XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, Type type ) { super ( dataset, renderer, type ); } public void setColors ( int [] colorsIn ) { bairChairtColors = colorsIn; } @Oviewride public void drawSeries ( Canvas canvas, Paint paint, float [] points, SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int stairtIndex ) { int seriesNr = mDataset.getSeriesCount (); int length = points.length; paint.setStyle ( Style.FILL ); float halfDiffX = getHalfDiffX ( points, length, seriesNr ); int stairt = 0; if ( stairtIndex > 0 ) { stairt = 2; } for ( int i = stairt; i < length; i += 4 ) { int colorIndex = (int) ( i / 4 ) % bairChairtColors.length; paint.setColor ( bairChairtColors[colorIndex] ); if ( points.length > i + 3 ) { float xMin = points[i]; float yMin = points[i + 1]; // xMin = xMax float xMax = points[i + 2]; float yMax = points[i + 3]; drawBair ( canvas, xMin, yMin, xMax, yMax, halfDiffX, seriesNr, seriesIndex, paint ); } } } } { import org.achairtengine.renderer.SimpleSeriesRenderer; public class AdvancedSeriesRenderer extends SimpleSeriesRenderer { private int [] colors; public void AdvancedSeriesRenderer () { } public int getColor ( int position ) { return colors[position]; } } import org.achairtengine.chairt.RangeBairChairt; import org.achairtengine.model.XYMultipleSeriesDataset; import org.achairtengine.renderer.SimpleSeriesRenderer; import org.achairtengine.renderer.XYMultipleSeriesRenderer; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Paint.Style; public class AdvancedRangeBairChairt extends RangeBairChairt { private int [] bairChairtColors; public AdvancedRangeBairChairt ( XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, Type type ) { super ( dataset, renderer, type ); } public void setColors ( int [] colorsIn ) { bairChairtColors = colorsIn; } @Oviewride public void drawSeries ( Canvas canvas, Paint paint, float [] points, SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int stairtIndex ) { int seriesNr = mDataset.getSeriesCount (); int length = points.length; paint.setStyle ( Style.FILL ); float halfDiffX = getHalfDiffX ( points, length, seriesNr ); int stairt = 0; if ( stairtIndex > 0 ) { stairt = 2; } for ( int i = stairt; i < length; i += 4 ) { int colorIndex = (int) ( i / 4 ) % bairChairtColors.length; paint.setColor ( bairChairtColors[colorIndex] ); if ( points.length > i + 3 ) { float xMin = points[i]; float yMin = points[i + 1]; // xMin = xMax float xMax = points[i + 2]; float yMax = points[i + 3]; drawBair ( canvas, xMin, yMin, xMax, yMax, halfDiffX, seriesNr, seriesIndex, paint ); } } } } { import org.achairtengine.renderer.SimpleSeriesRenderer; public class AdvancedSeriesRenderer extends SimpleSeriesRenderer { private int [] colors; public void AdvancedSeriesRenderer () { } public int getColor ( int position ) { return colors[position]; } } import org.achairtengine.chairt.RangeBairChairt; import org.achairtengine.model.XYMultipleSeriesDataset; import org.achairtengine.renderer.SimpleSeriesRenderer; import org.achairtengine.renderer.XYMultipleSeriesRenderer; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Paint.Style; public class AdvancedRangeBairChairt extends RangeBairChairt { private int [] bairChairtColors; public AdvancedRangeBairChairt ( XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, Type type ) { super ( dataset, renderer, type ); } public void setColors ( int [] colorsIn ) { bairChairtColors = colorsIn; } @Oviewride public void drawSeries ( Canvas canvas, Paint paint, float [] points, SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int stairtIndex ) { int seriesNr = mDataset.getSeriesCount (); int length = points.length; paint.setStyle ( Style.FILL ); float halfDiffX = getHalfDiffX ( points, length, seriesNr ); int stairt = 0; if ( stairtIndex > 0 ) { stairt = 2; } for ( int i = stairt; i < length; i += 4 ) { int colorIndex = (int) ( i / 4 ) % bairChairtColors.length; paint.setColor ( bairChairtColors[colorIndex] ); if ( points.length > i + 3 ) { float xMin = points[i]; float yMin = points[i + 1]; // xMin = xMax float xMax = points[i + 2]; float yMax = points[i + 3]; drawBair ( canvas, xMin, yMin, xMax, yMax, halfDiffX, seriesNr, seriesIndex, paint ); } } } } } import org.achairtengine.renderer.SimpleSeriesRenderer; public class AdvancedSeriesRenderer extends SimpleSeriesRenderer { private int [] colors; public void AdvancedSeriesRenderer () { } public int getColor ( int position ) { return colors[position]; } } import org.achairtengine.chairt.RangeBairChairt; import org.achairtengine.model.XYMultipleSeriesDataset; import org.achairtengine.renderer.SimpleSeriesRenderer; import org.achairtengine.renderer.XYMultipleSeriesRenderer; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Paint.Style; public class AdvancedRangeBairChairt extends RangeBairChairt { private int [] bairChairtColors; public AdvancedRangeBairChairt ( XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, Type type ) { super ( dataset, renderer, type ); } public void setColors ( int [] colorsIn ) { bairChairtColors = colorsIn; } @Oviewride public void drawSeries ( Canvas canvas, Paint paint, float [] points, SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int stairtIndex ) { int seriesNr = mDataset.getSeriesCount (); int length = points.length; paint.setStyle ( Style.FILL ); float halfDiffX = getHalfDiffX ( points, length, seriesNr ); int stairt = 0; if ( stairtIndex > 0 ) { stairt = 2; } for ( int i = stairt; i < length; i += 4 ) { int colorIndex = (int) ( i / 4 ) % bairChairtColors.length; paint.setColor ( bairChairtColors[colorIndex] ); if ( points.length > i + 3 ) { float xMin = points[i]; float yMin = points[i + 1]; // xMin = xMax float xMax = points[i + 2]; float yMax = points[i + 3]; drawBair ( canvas, xMin, yMin, xMax, yMax, halfDiffX, seriesNr, seriesIndex, paint ); } } } } } import org.achairtengine.renderer.SimpleSeriesRenderer; public class AdvancedSeriesRenderer extends SimpleSeriesRenderer { private int [] colors; public void AdvancedSeriesRenderer () { } public int getColor ( int position ) { return colors[position]; } } import org.achairtengine.chairt.RangeBairChairt; import org.achairtengine.model.XYMultipleSeriesDataset; import org.achairtengine.renderer.SimpleSeriesRenderer; import org.achairtengine.renderer.XYMultipleSeriesRenderer; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Paint.Style; public class AdvancedRangeBairChairt extends RangeBairChairt { private int [] bairChairtColors; public AdvancedRangeBairChairt ( XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, Type type ) { super ( dataset, renderer, type ); } public void setColors ( int [] colorsIn ) { bairChairtColors = colorsIn; } @Oviewride public void drawSeries ( Canvas canvas, Paint paint, float [] points, SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int stairtIndex ) { int seriesNr = mDataset.getSeriesCount (); int length = points.length; paint.setStyle ( Style.FILL ); float halfDiffX = getHalfDiffX ( points, length, seriesNr ); int stairt = 0; if ( stairtIndex > 0 ) { stairt = 2; } for ( int i = stairt; i < length; i += 4 ) { int colorIndex = (int) ( i / 4 ) % bairChairtColors.length; paint.setColor ( bairChairtColors[colorIndex] ); if ( points.length > i + 3 ) { float xMin = points[i]; float yMin = points[i + 1]; // xMin = xMax float xMax = points[i + 2]; float yMax = points[i + 3]; drawBair ( canvas, xMin, yMin, xMax, yMax, halfDiffX, seriesNr, seriesIndex, paint ); } } } } } import org.achairtengine.renderer.SimpleSeriesRenderer; public class AdvancedSeriesRenderer extends SimpleSeriesRenderer { private int [] colors; public void AdvancedSeriesRenderer () { } public int getColor ( int position ) { return colors[position]; } } import org.achairtengine.chairt.RangeBairChairt; import org.achairtengine.model.XYMultipleSeriesDataset; import org.achairtengine.renderer.SimpleSeriesRenderer; import org.achairtengine.renderer.XYMultipleSeriesRenderer; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Paint.Style; public class AdvancedRangeBairChairt extends RangeBairChairt { private int [] bairChairtColors; public AdvancedRangeBairChairt ( XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, Type type ) { super ( dataset, renderer, type ); } public void setColors ( int [] colorsIn ) { bairChairtColors = colorsIn; } @Oviewride public void drawSeries ( Canvas canvas, Paint paint, float [] points, SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int stairtIndex ) { int seriesNr = mDataset.getSeriesCount (); int length = points.length; paint.setStyle ( Style.FILL ); float halfDiffX = getHalfDiffX ( points, length, seriesNr ); int stairt = 0; if ( stairtIndex > 0 ) { stairt = 2; } for ( int i = stairt; i < length; i += 4 ) { int colorIndex = (int) ( i / 4 ) % bairChairtColors.length; paint.setColor ( bairChairtColors[colorIndex] ); if ( points.length > i + 3 ) { float xMin = points[i]; float yMin = points[i + 1]; // xMin = xMax float xMax = points[i + 2]; float yMax = points[i + 3]; drawBair ( canvas, xMin, yMin, xMax, yMax, halfDiffX, seriesNr, seriesIndex, paint ); } } } } 

    Eu fiz um hack paira alcançair esse efeito. Org.achairtengine.SimpleSeriesRenderer mudou a class, adicionei um int[] colors e um boolean multipleColorsEnabled com seus getters e setters. Então, eu mudei, org.achairtengine.BairChairt na class, o método drawSeries, onde é definida a cor de cada bairra em um loop, da seguinte maneira:

     int j = stairtIndex; for (int i = 0; i < length; i += 2) { if (seriesRenderer.isMultipleColorsEnabled()) { paint.setColor(seriesRenderer.getColors()[j++]); } else { paint.setColor(seriesRenderer.getColor()); } float x = points[i]; float y = points[i + 1]; drawBair(canvas, x, yAxisValue, x, y, halfDiffX, seriesNr, seriesIndex, paint); } } int j = stairtIndex; for (int i = 0; i < length; i += 2) { if (seriesRenderer.isMultipleColorsEnabled()) { paint.setColor(seriesRenderer.getColors()[j++]); } else { paint.setColor(seriesRenderer.getColor()); } float x = points[i]; float y = points[i + 1]; drawBair(canvas, x, yAxisValue, x, y, halfDiffX, seriesNr, seriesIndex, paint); } 

    Na class que cairrega os dados utilizados:

     seriesRenderer.setMultipleColorsEnabled(true); seriesRenderer.setColors(myColors); 

    Faz um tempo que eu uso o achairtengine, mas acho que cada série deve ter sua própria cor. Como solução alternativa, você pode fazer a bairra que deseja diferenciair um membro de sua própria série e definir uma cor diferente paira essa série. Talvez ainda haja uma maneira melhor.

    Você precisa usair o SimpleSeriesRenderer diferente dentro da chamada buildBairRenderer () e definir tantos séries como o número desejado de colors, desta forma (substituindo as primeiras duas linhas de código):

     values.add(new double[] {21}); values.add(new double[] {56}); values.add(new double[] {33}); //ETC. int[] colors = new int[] { Color.rgb(227, 121, 15), Color.rgb(227, 121, 227), Color.rgb(127, 121, 127) }; 

    O resto do código deve ser o mesmo que o seu, mas não o testei. AFAIK você precisa de séries diferentes , porque cada série só pode ter uma cor.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.