HelloCharts開源圖表庫(一)之折線圖,hellocharts開源

來源:互聯網
上載者:User

HelloCharts開源圖表庫(一)之折線圖,hellocharts開源

前面我們介紹了開源圖表庫MPAndroidChart,請參考:

http://blog.csdn.net/shineflowers/article/details/44704723

我們今天介紹的將是一個更為優秀的圖表庫,比MPAndroidChart效能更好,功能更完善,UI風格更美觀,座標軸更精細。

  • 支援縮放、滑動以及平移。Zoom(pinch to zoom, double tap zoom), scroll and fling

  • 支援自訂座標軸(比如座標軸位置:上下左右內部),支援自動產生座標軸。Custom and auto-generated axes(top, bottom, left, right, inside)

  • 動畫(Animations)

  • 支援預覽,即在chart下面會有一個座標密度更細的附屬chart,當選中附屬chart的某一地區,附屬chart上面的chart會顯示選中地區的更詳細情況。

  • GitHub地址:

  • https://github.com/lecho/hellocharts-android

  • 下面主要實現折線圖:

  • 1.從上面的地址中下載最新hellocharts-library-1.5.3.jar包, 然後copy到項目的libs中

    2. 定義xml檔案


  • 3. 顯示折線圖的部分邏輯如下:

            for (int i = 0; i < 10 ; i++) {                mPointValues.add(new PointValue(i, new Random().nextInt(10)));                mAxisValues.add(new AxisValue(i).setLabel(i)); //為每個對應的i設定相應的label(顯示在X軸)        }        Line line = new Line(mPointValues).setColor(BLUE).setCubic(false);        List<Line> lines = new ArrayList<Line>();        lines.add(line);        LineChartData data = new LineChartData();        data.setLines(lines);        //座標軸        Axis axisX = new Axis(); //X軸        axisX.setHasTiltedLabels(true);        axisX.setTextColor(BLUE);        axisX.setName("採集時間");        axisX.setMaxLabelChars(10);        axisX.setValues(mAxisValues);        data.setAxisXBottom(axisX);        Axis axisY = new Axis();  //Y軸        axisY.setMaxLabelChars(7); //預設是3,只能看最後三個數字        data.setAxisYLeft(axisY);        //設定行為屬性,支援縮放、滑動以及平移        mLineChartView.setInteractive(true);        mLineChartView.setZoomType(ZoomType.HORIZONTAL);        mLineChartView.setContainerScrollEnabled(true, ContainerScrollType.HORIZONTAL);        mLineChartView.setLineChartData(data);        mLineChartView.setVisibility(View.VISIBLE);


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.