HelloChart--ComboLineColumnChartView(组合统计图)

来源:互联网 发布:娃哈哈的营销网络 编辑:程序博客网 时间:2024/06/04 12:41

在XML中的定义:

<lecho.lib.hellocharts.view. ComboLineColumnChartView            android:id="@+id/combochart"            android:layout_width="wrap_content"            android:layout_height="wrap_content" >        </lecho.lib.hellocharts.view. ComboLineColumnChartView >

控件实例化:

ComboLineColumnChartView   comboChart;comboChart=(ComboLineColumnChartView)findViewById(R.id.combochart);

chart属性设置:

comboChart.setZoomEnabled(boolean isZoomEnabled)//设置是否支持缩放comboChart.setOnValueTouchListener(ColumnChartOnValueSelectListener touchListener);//为图表设置值得触摸事件comboChart.setInteractive(boolean isInteractive);//设置图表是否可以与用户互动comboChart.setValueSelectionEnabled(boolean idValueSelectionEnabled);//设置图表数据是否选中进行显示comboChart.setComboLineColumnChartData(ComboLineColumnChartData data);//为图表设置数据,数据类型为ComboLineColumnChartData 

设置ComboLineColumnChartData 属性及为chart设置数据:

ComboLineColumnChartData comboLineColumnChartData=new ComboLineColumnChartData();//定义组合数据对象        comboLineColumnChartData.setLineChartData(LineChartData lineChartData);//为组合图设置折线图数据        comboLineColumnChartData.setColumnChartData(ColumnChartData columnChartData);//为组合图设置柱形图数据   comboLineColumnChartData.setValueLabelsTextColor(Color.BLACK);// 设置数据文字颜色        comboLineColumnChartData.setValueLabelTextSize(15);// 设置数据文字大小        comboLineColumnChartData.setValueLabelTypeface(Typeface.MONOSPACE);// 设置数据文字样式        comboLineColumnChartData.setAxisYLeft(axisY);// 将Y轴属性设置到左边        comboLineColumnChartData.setAxisXBottom(axisX);// 将X轴属性设置到底部        comboLineColumnChartData.setAxisYRight(axisYRight);//设置右边显示的轴        comboLineColumnChartData.setAxisXTop(axisXTop);//设置顶部显示的轴       comboChart.setComboLineColumnChartData(ComboLineColumnChartData data);//为足额和图添加数据

组合图ComboLineColumnChartData其中添加的数据为LineChartData和ColumnChartData,与LinChartView、CoulmnChartView添加的数据类型一致。

0 0