Pregunta

I'm new to achartengine ,and i would like to know how to change the y axis scale. I'm trying to get a bar chart , to display the wifi signal strength and channels .I need for X axis (1,2,3..14) and Y axis (-90,-80,-70...-30) scales. But i don't know where to do that in the code. EDIT Now i'm having the desired scale ,but i don't have anymore the bars ,they became without color ,i just can see the their tops that shows the Y coordinate.Well i just see numbers . This is the code i'm using :

  public Intent execute(Context context) {
String[] titles = new String[] { "2008", "2007" };
List<double[]> values = new ArrayList<double[]>();


/* values.add(new double[] { 14230, 12300, 0, 15244, 15900, 19200, 22030, 21200, 19500, `15500,`
        12600, 14000 });
         values.add(new double[] { 5230, 7300, 0, 10540, 7900, 9200, 12030, 11200, 9500, `10500,`
        11600, 13500 });*/



  values.add(new double[] { -65, -71, 0, -80, -90, -20, -10, -95, -89, -75,
    -95, -35,-45,-68 });
 values.add(new double[] { -71, -65, 0, -80, -90, -10, -20, -95, -89, -75,
            -95, -35,-45,-68 });


int[] colors = new int[] { Color.BLUE, Color.CYAN };
XYMultipleSeriesRenderer renderer = buildBarRenderer(colors);
//EDITED the SetChartSettings


setChartSettings(renderer, "Monthly sales in the last 2 years", "Month", "Units sold", 0,
        12, -100, -30, Color.GRAY, Color.LTGRAY);
renderer.getSeriesRendererAt(0).setDisplayChartValues(true);
renderer.getSeriesRendererAt(1).setDisplayChartValues(true);
renderer.setXLabels(12);
renderer.setYLabels(10);
renderer.setXLabelsAlign(Align.LEFT);
renderer.setYLabelsAlign(Align.LEFT);
renderer.setPanEnabled(true, false);
// renderer.setZoomEnabled(false);
renderer.setZoomRate(1.1f);
renderer.setBarSpacing(0.5f);
return ChartFactory.getBarChartIntent(context, buildBarDataset(titles, values), renderer,
    Type.STACKED);


 }

PS :this code displays two bar charts . Thank you for helping.

¿Fue útil?

Solución

Setting value for x-Axis,

XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer();
mRenderer.addTextLabel(1,1);
        mRenderer.addTextLabel(2,2);
        mRenderer.addTextLabel(3,3);
        mRenderer.addTextLabel(4,14);

Setting value for y-Axis,

public Intent getIntent(Context context) {
    // TODO Auto-generated method stub

    int y[] = {25,10,15,20};

    CategorySeries series = new CategorySeries("Bar1");
    for(int i=0; i < y.length; i++){
        series.add("Bar"+(i+1),y[i]);

}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top