Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

achartengine x-axis labels shift compared to values

Tags:

achartengine

I noticed that the Xlabels of my Timechart are out of sync with the X- values. The points should be right above the labels. On the left side it OK, but it shifts towards the right. I don't know how to solve this What i get: http://tinypic.com/r/2uqj905/7 How it should be like: http://www.achartengine.org/dimages/average_temperature.png I tried a line chart or converted the date to a double but that had no effect. Any help would be be nice.

regards, Christian

This is some of my code:

    XYMultipleSeriesRenderer renderer = buildRenderer(colors, styles);
    renderer.setPointSize(5.5f);
    renderer.setZoomEnabled(false, false);
    renderer.setMarginsColor(Color.parseColor("#00FF0000"));
    renderer.setAxisTitleTextSize(16);
    renderer.setYLabelsAlign(Align.RIGHT);
    renderer.setLabelsTextSize(15);
    renderer.setLegendTextSize(15);
    renderer.setMargins(new int[] { 10, 65, 18, 10 });

    int length = renderer.getSeriesRendererCount();
    for (int i = 0; i < length; i++) {
        XYSeriesRenderer seriesRenderer = (XYSeriesRenderer) renderer
                .getSeriesRendererAt(i);
        seriesRenderer.setFillPoints(true);
        seriesRenderer.setLineWidth(4.0f); // dikte van lijn
    }

    MinMax minMax = determineMinMax(targetSteps, samples);

    setChartSettings(renderer, context.getString(R.string.graph_title),
            dateLabelOnScreenType(type),
            context.getString(R.string.graph_y_axis), minMax.minX,
            minMax.maxX, minY, maxY, Color.WHITE,
            Color.BLACK);
    renderer.setXLabels(7);

    renderer.setYLabels(0);
    renderer.setDisplayChartValues(false);
    renderer.setShowGrid(true);
     renderer.setPanEnabled(false, false);


    // set the data
    String[] titles = new String[] {
            context.getString(R.string.graph_legend_target),
            context.getString(R.string.graph_legend_actual) };
    XYMultipleSeriesDataset dataSet = buildDateDataset(titles,
xSeriesList,
            ySeriesList);

    TimeChart chart = new TimeChart(dataSet, renderer);
    chart.setDateFormat(dateFormatOnSampleType(type));
    GraphicalView gview = new GraphicalView(context, chart);   
like image 416
Christian Loncle Avatar asked Jul 04 '11 21:07

Christian Loncle


1 Answers

renderer.setYLabelsAlign(Align.RIGHT);

Change to:

renderer.setYLabelsAlign(Align.CENTER);
like image 92
JP409 Avatar answered Nov 03 '22 21:11

JP409