achartengine x-axis labels shift compared to values

守給你的承諾、 提交于 2019-12-20 14:23:27

问题


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);   

回答1:


renderer.setYLabelsAlign(Align.RIGHT);

Change to:

renderer.setYLabelsAlign(Align.CENTER);



回答2:


The solution to this was added recently. Just call:

renderer.setXRoundedLabels(false)


来源:https://stackoverflow.com/questions/6576164/achartengine-x-axis-labels-shift-compared-to-values

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!