AndroidPlot - горизонтальные линии - PullRequest
0 голосов
/ 28 августа 2018

Кто-нибудь знает, возможно ли построить горизонтальные линии поверх сгенерированных графиков? Например, если я хочу добавить горизонтальную линию в 9.1: enter image description here

Есть ли метод, который выполняет это с помощью XYPlot? Или любым другим способом? Спасибо.

final Number[] domainLabels = {1, 2, 3, 6, 7, 8, 9, 10, 13, 14};
    Number[] series1Numbers = {1, 4, 2, 8, 4, 16, 8, 32, 16, 64};
    Number[] series2Numbers = {5, 2, 10, 5, 20, 10, 40, 20, 80, 40};

    // turn the above arrays into XYSeries':
    // (Y_VALS_ONLY means use the element index as the x value)
    XYSeries series1 = new SimpleXYSeries(
            Arrays.asList(series1Numbers), SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "Series1");
    XYSeries series2 = new SimpleXYSeries(
            Arrays.asList(series2Numbers), SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "Series2");


    LineAndPointFormatter series1Format =
            new LineAndPointFormatter(this, R.xml.line_point_formatter_with_labels);

    LineAndPointFormatter series2Format =
            new LineAndPointFormatter(this, R.xml.line_point_formatter_with_labels_2);


    series2Format.getLinePaint().setPathEffect(new DashPathEffect(new float[] {


            PixelUtils.dpToPix(20),
            PixelUtils.dpToPix(15)}, 0));

    // add a new series' to the xyplot:
    plot.addSeries(series1, series1Format);
    plot.addSeries(series2, series2Format);

    plot.getGraph().getLineLabelStyle(XYGraphWidget.Edge.BOTTOM).setFormat(new Format() {
        @Override
        public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos) {
            int i = Math.round(((Number) obj).floatValue());
            return toAppendTo.append(domainLabels[i]);
        }
        @Override
        public Object parseObject(String source, ParsePosition pos) {
            return null;
        }
    });
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...