githubbub / achartengine

Automatically exported from code.google.com/p/achartengine
0 stars 0 forks source link

Android AchartEngine1.1 bar chart didn't drow nagative value #313

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. draw bar chart
2. android 4.1 draw well negative value
3. but android2.2 didn't draw negative value; positive value draw well;

What is the expected output? What do you see instead?

i want to my app can draw negative value any android version;

Please provide a source code snippet that we can use to replicate the issue.
mDataset = new XYMultipleSeriesDataset();
        mRenderer = new XYMultipleSeriesRenderer();
        mRenderer.setApplyBackgroundColor(true);
        mRenderer.setBackgroundColor(Color.argb(100, 50, 50, 50));// 
        mRenderer.setXLabels(11);// 
        mRenderer.setYLabels(12);//
        mRenderer.setYLabelsAlign(Align.RIGHT);// 
        mRenderer.setShowLabels(true);
        mRenderer.setShowLegend(false); //
        mRenderer.setXLabelsColor(Color.BLACK);// 
        mRenderer.setLabelsTextSize(19);// 
        mRenderer.setShowGridY(true);
        mRenderer.setShowGridX(true);
        mRenderer.setShowCustomTextGrid(true);
        mRenderer.setMargins(new int[] { 30, 50, 0, 10 });
        mRenderer.setZoomButtonsVisible(false);
        mRenderer.setYAxisMin(-100);//
        mRenderer.setYAxisMax(20);// 
        mRenderer.setXAxisMin(0);//

        mainSpectrum = new XYSeriesRenderer();
        mainSpectrum.setColor(Color.WHITE);
        mainSpectrum.setPointStyle(PointStyle.POINT);
        mainSpectrum.setFillPoints(true);
        mRenderer.setPointSize(5);
        peakSpectrum = new XYSeriesRenderer();
        peakSpectrum.setPointStyle(PointStyle.DIAMOND);
        peakSpectrum.setColor(Color.RED);
        peakSpectrum.setFillPoints(true);
        mRenderer.setPointSize(5);
        minSpectrum = new XYSeriesRenderer();
        minSpectrum.setPointStyle(PointStyle.SQUARE);
        minSpectrum.setColor(Color.rgb(0, 216, 255));
        minSpectrum.setFillPoints(true);
        mRenderer.setPointSize(5);

    dataSeries = new XYSeries("01");
        if(SpectrumActivity.startEndSet==false){//startend,centerspan 
            for (byte item : showData) {
                double temp = ((item & 0xff) * 100 / 255.0) * (-1);
                if (temp > maxY) {
                    maxY = temp;
                    maxX = index;
                }
                if(temp < minY){
                    minY = temp;
                    minX = index;
                }
//              dataSeries.add(index, temp+(offsetValue/10)+indicatorValue * 10);
                dataSeries.add(index, temp+indicatorValue * 10);
                index++;
            }
        }else{
            int tempIndex=0;
            for(index = (int) SpectrumActivity.startXAxis; index < SpectrumActivity.endXAxis+1;index++){
                double temp = ((showData[index] & 0xff) * 100 / 255.0) * (-1);
                if (temp > maxY) {
                    maxY = temp;
                    maxX = tempIndex;
                }
                if(temp < minY){
                    minY = temp;
                    minX = tempIndex;
                }
//              dataSeries.add(tempIndex, temp+(offsetValue/10)+indicatorValue * 10);
                dataSeries.add(tempIndex, temp+indicatorValue * 10);
                tempIndex++;
            }
            mRenderer.setXAxisMax(tempIndex);
        }
        mDataset.addSeries(dataSeries);

        peakSeries = new XYSeries("02");
        peakSeries.add(maxX, dataSeries.getMaxY());
        mDataset.addSeries(peakSeries);

        minSeries = new XYSeries("03");
        minSeries.add(minX, dataSeries.getMinY());
        mDataset.addSeries(minSeries);

        faTop = new XYSeries("04");
        faTop.add(faStart*10, (int)-(indicatorValue * -10)-150);
        faTop.add(faEnd*10, (int)-(indicatorValue * -10)-150) ;
        mDataset.addSeries(faTop);

        faBottom = new XYSeries("05");
        faBottom.add(faStart*10, (int)(indicatorValue * -10)+150);
        faBottom.add(faEnd*10, (int)(indicatorValue * -10)+150);
        mDataset.addSeries(faBottom);

        mRenderer.addSeriesRenderer(mainSpectrum);

        mRenderer.addSeriesRenderer(peakSpectrum);

        mRenderer.addSeriesRenderer(minSpectrum);

        mRenderer.setBarSpacing(90);

        faTopSpectrum = new XYSeriesRenderer();
        faTopSpectrum.setColor(Color.GREEN);
        mRenderer.addSeriesRenderer(faTopSpectrum);

        faBottomSpectrum = new XYSeriesRenderer();
        faBottomSpectrum.setColor(Color.GREEN);
        mRenderer.addSeriesRenderer(faBottomSpectrum);

        if (SpectrumActivity.startEndSet == true) {
            min = (SpectrumActivity.startXAxis / 10) + getBandFrequency();
            max = (SpectrumActivity.endXAxis / 10) +  getBandFrequency();
            startMHz.setText(String.format("%.2f",(min)) + " MHz");
            endMHz.setText(String.format("%.2f", max) + " MHz");
            SpectrumActivity.timeDomainStartFreq = (int) min;
            SpectrumActivity.timeDomainEndFreq = (int) max;
            step.setText(String.format("%.2f", ((max- min)/ 10)) +" MHz");
        } else {
            startMHz.setText(String.format("%.2f", (startFrequencyValue+ getBandFrequency()))+ " MHz");
            SpectrumActivity.timeDomainStartFreq = (int) (startFrequencyValue+ getBandFrequency());
//          System.out.println("NomralSpectrum to TimeDomainStart "+ 
SpectrumActivity.timeDomainStartFreq );
            endMHz.setText(String.format("%.2f", (endFrequencyValue+  getBandFrequency()))+ " MHz");
            SpectrumActivity.timeDomainEndFreq = (int) (endFrequencyValue+  getBandFrequency());
//          System.out.println("NomralSpectrum to TimeDomainEnd "+ 
SpectrumActivity.timeDomainEndFreq );
            step.setText(String.format("%.2f", ((endFrequencyValue - startFrequencyValue)/ 10)) +" MHz");
        }

        mRenderer.setYAxisMin(-100 + indicatorValue * 10);
        mRenderer.setYAxisMax(20 + indicatorValue * 10);
What version of the product binary library are you using?
AchartEngine1.1

Please provide any additional information below.

my english skill is not good, please understand my explanation;

Original issue reported on code.google.com by simsoolt...@gmail.com on 7 Jun 2013 at 9:02

Attachments:

GoogleCodeExporter commented 9 years ago
Try this version of the library and let me know if it works:
https://repository-achartengine.forge.cloudbees.com/snapshot/org/achartengine/ac
hartengine/1.2.0/

Original comment by dandrome...@gmail.com on 7 Jun 2013 at 10:18

GoogleCodeExporter commented 9 years ago
Thank you so much!!!
This version works very well!!

Original comment by simsoolt...@gmail.com on 10 Jun 2013 at 1:10

GoogleCodeExporter commented 9 years ago

Original comment by dandrome...@gmail.com on 10 Jun 2013 at 6:16