在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);//設置值選中後進行顯示
設置節點、X、Y軸屬性:
List<BubbleValue> pointValues = new ArrayList<BubbleValue>();// 節點數據結合
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軸刻度值的數據集合
ArrayList<AxisValue> axisValuesY = new ArrayList<AxisValue>();//定義Y軸刻度值的數據集合
axisX.setValues(axisValuesX);//爲X軸顯示的刻度值設置數據集合
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設置數據:
BubbleChartData bubbleDate=new BubbleChartData(List<BubbleValue> values);//定義氣泡圖的數據對象
bubbleDate.setBubbleScale(float bubbleScale);//設置氣泡的比例大小
bubbleDate.setHasLabelsOnlyForSelected(boolean hasLabelsOnlyForSelected);//設置文本只有當點擊時顯示
bubbleDate.setMinBubbleRadius(int minBubbleRadius);//設置氣泡的最小半徑
bubbleDate.setValueLabelsTextColor(Color.BLACK);// 設置數據文字顏色
bubbleDate.setValueLabelTextSize(15);// 設置數據文字大小
bubbleDate.setValueLabelTypeface(Typeface.MONOSPACE);// 設置數據文字樣式
bubbleDate.setAxisYLeft(axisY);// 將Y軸屬性設置到左邊
bubbleDate.setAxisXBottom(axisX);// 將X軸屬性設置到底部
bubbleDate.setAxisYRight(axisYRight);//設置右邊顯示的軸
bubbleDate.setAxisXTop(axisXTop);//設置頂部顯示的軸
bubbleChart.setBubbleChartData(BubbleChartData bubbleChartData);//將數據設置給氣泡圖
<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);//設置值選中後進行顯示
設置節點、X、Y軸屬性:
List<BubbleValue> pointValues = new ArrayList<BubbleValue>();// 節點數據結合
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軸刻度值的數據集合
ArrayList<AxisValue> axisValuesY = new ArrayList<AxisValue>();//定義Y軸刻度值的數據集合
axisX.setValues(axisValuesX);//爲X軸顯示的刻度值設置數據集合
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設置數據:
BubbleChartData bubbleDate=new BubbleChartData(List<BubbleValue> values);//定義氣泡圖的數據對象
bubbleDate.setBubbleScale(float bubbleScale);//設置氣泡的比例大小
bubbleDate.setHasLabelsOnlyForSelected(boolean hasLabelsOnlyForSelected);//設置文本只有當點擊時顯示
bubbleDate.setMinBubbleRadius(int minBubbleRadius);//設置氣泡的最小半徑
bubbleDate.setValueLabelsTextColor(Color.BLACK);// 設置數據文字顏色
bubbleDate.setValueLabelTextSize(15);// 設置數據文字大小
bubbleDate.setValueLabelTypeface(Typeface.MONOSPACE);// 設置數據文字樣式
bubbleDate.setAxisYLeft(axisY);// 將Y軸屬性設置到左邊
bubbleDate.setAxisXBottom(axisX);// 將X軸屬性設置到底部
bubbleDate.setAxisYRight(axisYRight);//設置右邊顯示的軸
bubbleDate.setAxisXTop(axisXTop);//設置頂部顯示的軸
bubbleChart.setBubbleChartData(BubbleChartData bubbleChartData);//將數據設置給氣泡圖