2

我正在开发一个需要实现折线图的应用程序。

为此,我正在使用 Achart 引擎绘制折线图,​​但我想使用一些示例坐标绘制垂直线,但我未能实现。但是我可以画水平线,但不能画垂直直线。

 int[] x = { 1,2,3,4,5,6,7,8 };
                    int[] systolic = { 90,90,100,70,90,100,110,70};
                    //int[] systolic = { 90,90,90,90,90,90,90,90};
                  /*  int[] diastolic = {70, 60, 65, 70, 45, 60, 70, 90 };
                    int[] pulse = {45, 60, 45, 80, 65, 50, 90, 70};*/

                    // Creating an  XYSeries for Income
                    XYSeries systolicSeries = new XYSeries("Systolic");
                    // Creating an  XYSeries for Expense
                    XYSeries diastolicSeries = new XYSeries("Diastolic");
                    // Creating an  XYSeries for Expense
                    XYSeries pulseSeries = new XYSeries("Pulse");

                    // Adding data to Income and Expense Series
                    for(int i=0;i<x.length;i++){
                        systolicSeries.add(x[1], systolic[i]);
                      //  diastolicSeries.add(x[i],diastolic[i]);
                      //  pulseSeries.add(x[i],pulse[i]);
                    }

                    // Creating a dataset to hold each series
                    XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
                    // Adding Income Series to the dataset
                    dataset.addSeries(systolicSeries);
                    // Adding Expense Series to dataset
                  //  dataset.addSeries(diastolicSeries);
                    // Adding Expense Series to dataset
                  //  dataset.addSeries(pulseSeries);



                    // Creating XYSeriesRenderer to customize incomeSeries
                    XYSeriesRenderer incomeRenderer = new XYSeriesRenderer();
                    incomeRenderer.setColor(Color.WHITE);
                    incomeRenderer.setPointStyle(PointStyle.CIRCLE);
                    incomeRenderer.setFillPoints(true);
                    incomeRenderer.setLineWidth(2);
                    incomeRenderer.setDisplayChartValues(true);

                /*    // Creating XYSeriesRenderer to customize expenseSeries
                    XYSeriesRenderer expenseRenderer = new XYSeriesRenderer();
                    expenseRenderer.setColor(Color.YELLOW);
                    expenseRenderer.setPointStyle(PointStyle.CIRCLE);
                    expenseRenderer.setFillPoints(true);
                    expenseRenderer.setLineWidth(2);
                    expenseRenderer.setDisplayChartValues(true);

                 // Creating XYSeriesRenderer to customize incomeSeries
                    XYSeriesRenderer pulseRenderer = new XYSeriesRenderer();
                    incomeRenderer.setColor(Color.WHITE);
                    incomeRenderer.setPointStyle(PointStyle.CIRCLE);
                    incomeRenderer.setFillPoints(true);
                    incomeRenderer.setLineWidth(2);
                    incomeRenderer.setDisplayChartValues(true);*/

                    // Creating a XYMultipleSeriesRenderer to customize the whole chart
                    XYMultipleSeriesRenderer multiRenderer = new XYMultipleSeriesRenderer();
                    multiRenderer.setXLabels(0);
                    multiRenderer.setChartTitle("Blood Pressure");
                    multiRenderer.setXTitle("Date");
                    multiRenderer.setYTitle("Value");
                    multiRenderer.setZoomButtonsVisible(true);
                    for(int i=0;i<x.length;i++){
                        multiRenderer.addXTextLabel(i+1, mMonth[i]);
                    }

                    // Adding incomeRenderer and expenseRenderer to multipleRenderer
                    // Note: The order of adding dataseries to dataset and renderers to multipleRenderer
                    // should be same
                    multiRenderer.addSeriesRenderer(incomeRenderer);
                  //  multiRenderer.addSeriesRenderer(expenseRenderer);
                  //  multiRenderer.addSeriesRenderer(pulseRenderer);

                    mChartView = ChartFactory.getLineChartView(this, dataset, multiRenderer);
                    mChartView.setBackgroundColor(Color.BLACK);

                    linlayChartLogContainer.addView(mChartView);

                }
            catch (Exception e)
                {
                    e.printStackTrace();
                }
4

1 回答 1

0

您是否尝试过 AchartEngine 中的条形图?它可以画垂直线

于 2013-08-12T10:36:44.657 回答