curve line android achartengine

146 views Asked by At

I need to draw a straight horizontal and vertical lines. For drawing in android, i am using ACharEngine.

My code:

        public void onClick(View v) {
            TimeSeries horizontalLine = new TimeSeries("horizontalLine");
            horizontalLine.add(50.0, 0.0);
            horizontalLine.add(-50.0, 0.0);

            TimeSeries verticalLine = new TimeSeries("verticalLine");
            verticalLine.add(0.0, 50.0);
            verticalLine.add(0.0, -50.0);

            XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
            dataset.addSeries(horizontalLine);
            dataset.addSeries(verticalLine);

            XYSeriesRenderer renderHorizontal = new XYSeriesRenderer();
            renderHorizontal.setShowLegendItem(true);
            renderHorizontal.setColor(Color.BLACK);
            renderHorizontal.setLineWidth(3);

            XYSeriesRenderer renderVertical = new XYSeriesRenderer();
            renderVertical.setShowLegendItem(true);
            renderVertical.setColor(Color.RED);
            renderVertical.setLineWidth(3);

            XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer();
            mRenderer.addSeriesRenderer(renderVertical);
            mRenderer.addSeriesRenderer(renderHorizontal);

            mRenderer.setMarginsColor(Color.argb(0x00, 0xff, 0x00, 0x00));
            mRenderer.setGridColor(Color.GRAY);
            mRenderer.setShowGrid(true);
            mRenderer.setZoomButtonsVisible(true);
            mRenderer.setGridColor(Color.GRAY);
            mRenderer.setYLabelsPadding(-12);
            mLinearView.removeAllViews();
            mLinearView.addView(ChartFactory.getLineChartView(getActivity(), dataset, mRenderer));
        }

The horizontal line painted a very good, but with vertical have some inaccuracy. My Picture: https://i.stack.imgur.com/nwCf6.png

I can not understand what the problem is

1

There are 1 answers

0
Dmytro Ivanov On
TimeSeries horizontalLine = new TimeSeries("horizontalLine");

replace on

XYValueSeries horizontalLine = new XYValueSeries("horizontalLine");