HelloChart--BubbleChartView(氣泡圖)

在XML中的定義:

<lecho.lib.hellocharts.view.BubbleChartView

            android:id="@+id/bubblechart"

            android:layout_width="wrap_content"

            android:layout_height="wrap_content" >

        </lecho.lib.hellocharts.view.BubbleChartView>

控件實例化:

       BubbleChartView  bubbleChart;
       bubbleChart = (BubbleChartView) findViewById(R.id.bubblechart);

chart屬性設置:

bubbleChart.setZoomEnabled(boolean isZoomEnabled)//設置是否支持縮放
bubbleChart.setOnValueTouchListener(LineChartOnValueSelectListener touchListener);//為圖表設置值得觸摸事件
bubbleChart.setInteractive(boolean isInteractive);// 用戶是否對其可以進行互動
bubbleChart.setValueSelectionEnabled(boolean isSelection);//設置值選中后進行顯示

設置節(jié)點、X、Y軸屬性:

    List<BubbleValue> pointValues = new ArrayList<BubbleValue>();// 節(jié)點數(shù)據(jù)結合
        Axis axisY = new Axis().setHasLines(true);// Y軸屬性
        Axis axisX = new Axis();// X軸屬性
        axisY.setName(String yName);//設置Y軸顯示名稱
        axisX.setName(String xName);//設置X軸顯示名稱
        ArrayList<AxisValue> axisValuesX = new ArrayList<AxisValue>();//定義X軸刻度值的數(shù)據(jù)集合
               ArrayList<AxisValue> axisValuesY = new ArrayList<AxisValue>();//定義Y軸刻度值的數(shù)據(jù)集合
        axisX.setValues(axisValuesX);//為X軸顯示的刻度值設置數(shù)據(jù)集合
        axisX.setLineColor(Color.BLACK);// 設置X軸軸線顏色
        axisY.setLineColor(Color.BLACK);// 設置Y軸軸線顏色
        axisX.setTextColor(Color color);// 設置X軸文字顏色
        axisY.setTextColor(Color color);// 設置Y軸文字顏色
        axisX.setTextSize(14);// 設置X軸文字大小
        axisX.setTypeface(Typeface.DEFAULT);// 設置文字樣式,此處為默認
        axisX.setHasTiltedLabels(bolean isHasTit);// 設置X軸文字向左旋轉45度
        axisX.setHasLines(boolean isHasLines);// 是否顯示X軸網格線
                axisY.setHasLines(boolean isHasLines);// 是否顯示Y軸網格線
        axisX.setHasSeparationLine(boolean isHasSeparationLine);// 設置是否有分割線
        axisX.setInside(boolean isInside);// 設置X軸文字是否在X軸內部
                BubbleValue v=new BubbleValue();//定義氣泡
            v.set(float x,float y,float z);//設置氣泡的橫縱坐標x、y,z為氣泡的半徑
            v.setColor(int color);//設置氣泡的顏色
            v.setLabel(String label);//設置氣泡中顯示的文本
            v.setShape(ValueShape shape);//設置氣泡的形狀

設置BubbleChartData屬性及為chart設置數(shù)據(jù):

        BubbleChartData bubbleDate=new BubbleChartData(List<BubbleValue> values);//定義氣泡圖的數(shù)據(jù)對象
        bubbleDate.setBubbleScale(float bubbleScale);//設置氣泡的比例大小
        bubbleDate.setHasLabelsOnlyForSelected(boolean hasLabelsOnlyForSelected);//設置文本只有當點擊時顯示
        bubbleDate.setMinBubbleRadius(int minBubbleRadius);//設置氣泡的最小半徑
       bubbleDate.setValueLabelsTextColor(Color.BLACK);// 設置數(shù)據(jù)文字顏色
        bubbleDate.setValueLabelTextSize(15);// 設置數(shù)據(jù)文字大小
        bubbleDate.setValueLabelTypeface(Typeface.MONOSPACE);// 設置數(shù)據(jù)文字樣式
        bubbleDate.setAxisYLeft(axisY);// 將Y軸屬性設置到左邊
        bubbleDate.setAxisXBottom(axisX);// 將X軸屬性設置到底部
        bubbleDate.setAxisYRight(axisYRight);//設置右邊顯示的軸
        bubbleDate.setAxisXTop(axisXTop);//設置頂部顯示的軸
        bubbleChart.setBubbleChartData(BubbleChartData bubbleChartData);//將數(shù)據(jù)設置給氣泡圖
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容