9

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);   
Christian Loncle
  • 1,584
  • 3
  • 20
  • 30
  • Seems like we are missing a large part of the code that could be the problem. Firstly determineMinMax(targetSteps, samples); I don't find this as part of achartengine so I guess it's yours. Are you 100% sure that works as intended? Also I can't see what targetSteps has for value. From your picture there are several odd things, there are 6 dataPoints shown but only 5 labels. Also the start point for the dataPoints are off related to the start point for the labels. I would guess you have some problem with the span not being the same for the labels and the datapoints. – larlin Jun 28 '12 at 13:02

2 Answers2

3
renderer.setYLabelsAlign(Align.RIGHT);

Change to:

renderer.setYLabelsAlign(Align.CENTER);
nickhar
  • 19,981
  • 12
  • 60
  • 73
JP409
  • 225
  • 1
  • 2
  • 13
0

The solution to this was added recently. Just call:

renderer.setXRoundedLabels(false)
Dan D.
  • 32,246
  • 5
  • 63
  • 79