Androidplot - Не се показва в пейзаж

Ако начертая лентова диаграма с помощта на Androidplot и след това променя ориентацията на телефона си от портретна на пейзажна, цялата информация в диаграмата изчезва. (линк към екранни снимки).

Пейзаж --- няма данни за диаграма

https://drive.google.com/file/d/0B4CxFPSlLEYpSXV1VnZFVFUtWGc/edit?usp=sharing

Портрет --- данни от диаграмата

https://drive.google.com/file/d/0B4CxFPSlLEYpdGZCMm8xdGZHTlk/edit?usp=sharing

След няколко опита и грешки установих, че ако задам ширината на диаграмата да бъде 0,96 от ширината на екрана на устройството, цялата информация за диаграмата се появява отново.

Как мога да накарам Androidplot да заема 100% от ширината на екрана на устройството, когато е в пейзаж?

Моят код за създаване на диаграмата може да бъде намерен на Androidplot - етикетите на X-Axis отрязани


person Mark    schedule 11.09.2014    source източник
comment
Какво се случва, ако проведете горния експеримент на DemoApp's активност на лентовата диаграма? Проявява ли същото поведение? Работи на моето устройство.   -  person Nick    schedule 11.09.2014
comment
Не, диаграмата се показва в пейзажен режим. Какво се случва, ако стартирате кода ми на stackoverflow.com/q/25780552/816754 проявява ли неправилно поведение?   -  person Mark    schedule 12.09.2014
comment
@Mark Тук се появява и в двата режима. Но в портретен режим се свива.   -  person keshav    schedule 16.09.2014


Отговори (1)


Направете нещо подобно

 private View createBarGraph()
    {
        // initialize our XYPlot reference:
        XYPlot plot = (XYPlot) this.findViewById(R.id.mySimpleXYPlot1);

        // Create a couple arrays of y-values to plot:
        Number[] series1Numbers = GenerateGraphValues();

        // Turn the above arrays into XYSeries':
        XYSeries series1 = new SimpleXYSeries(Arrays.asList(series1Numbers), 
        SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, // Y_VALS_ONLY means use the
                                                                                                // element index as the x value
                "Series1"); // Set the display title of the series

        BarFormatter series1Format = new BarFormatter(Color.rgb(51, 181, 229), Color.TRANSPARENT);
        PointLabelFormatter plf = new PointLabelFormatter();
        plf.getTextPaint().setTextSize(18);
        plf.getTextPaint().setColor(Color.BLACK);
        series1Format.setPointLabelFormatter(plf);

        series1Format.setPointLabeler(new PointLabeler(){
            DecimalFormat df = new DecimalFormat("##0.00");

            public String getLabel(XYSeries series, int index)
            {

                // need to check for null
                if(series.getY(index) == null) return "";

                return df.format(series.getY(index));
            }
        });

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

        // Y axis config
        plot.setRangeLabel("Values"); // label
        plot.setRangeBoundaries(0, 110, BoundaryMode.FIXED); // scale
        plot.setRangeStep(XYStepMode.INCREMENT_BY_VAL, 10); // steps
        plot.getGraphWidget().getRangeLabelPaint().setTextSize(26); // font size
        DecimalFormat nf = new DecimalFormat("#0");
        plot.setRangeValueFormat(nf);

        // X Axs config
        plot.setDomainLabel("Indexes");
        plot.setDomainStep(XYStepMode.INCREMENT_BY_VAL, 1);
         plot.getGraphWidget().setDomainValueFormat(new DecimalFormat("0"));
        plot.getGraphWidget().getDomainLabelPaint().setTextSize(18);
        plot.getGraphWidget().setMarginTop(20);
        plot.getGraphWidget().setMarginBottom(15);
        plot.getGraphWidget().setMarginLeft(15);
        plot.getGraphWidget().setMarginRight(15);
//      plot.getLegendWidget().setHeight(14);
        plot.getGraphWidget().setGridPaddingLeft(15);
        plot.getGraphWidget().setGridPaddingRight(15);
//      plot.getGraphWidget().setGridPaddingBottom(20);
        // other config
        plot.getLegendWidget().setVisible(false); // hide legend
        plot.getGraphWidget().getDomainGridLinePaint().setColor(Color.TRANSPARENT); // hide
                                                                                                                                                                // grid
                                                                                                                                                                // lines
        plot.getGraphWidget().getRangeGridLinePaint().setColor(Color.TRANSPARENT); // hide
                                                                                                                                                                // grid
                                                                                                                                                                // lines
//      plot.getGraphWidget().setGridPaddingLeft(40); // give some padding
//      plot.getGraphWidget().setGridPaddingRight(40); // give some padding
        plot.getGraphWidget().getGridBackgroundPaint().setColor(Color.WHITE); // background
                                                                                                                                                    // color
//      plot.getTitleWidget().setPaddingTop(10); // give some padding

        // set bar width
        BarRenderer<?> renderer = (BarRenderer<?>) plot.getRenderer(BarRenderer.class);
        renderer.setBarWidth(20);
        return plot;

    }
person keshav    schedule 16.09.2014