资讯专栏INFORMATION COLUMN

MPAndroidChart的相关图表设置

dance / 926人阅读

摘要:是否启用网格背景是否设置轴坐标设置网格竖线是否显示设置在轴上是否是从开始显示是否在轴显示数据,就是曲线上的数据设置网格在上的右下角加描述曲线图设置轴上的单位设置透明度设置网格底下的那条线的颜色设置轴前后倒置设置高亮显示设置是否可以触摸,如为

//是否启用网格背景
mChart.setDrawGridBackground(false);
//是否设置Y轴坐标
mChart.setDrawYLabels(false);
//设置网格竖线是否显示
mChart.setDrawVerticalGrid(false);
// 设置在Y轴上是否是从0开始显示
mChart.setStartAtZero(false);
//是否在Y轴显示数据,就是曲线上的数据
mChart.setDrawYValues(true);
//设置网格
mChart.setDrawBorder(false);
mChart.setBorderPositions(new BarLineChartBase.BorderPosition[]{
BarLineChartBase.BorderPosition.BOTTOM});
//在chart上的右下角加描述
//mChart.setDescription("曲线图");
//设置Y轴上的单位
mChart.setUnit("");
//设置透明度
mChart.setAlpha(0.8f);
//设置网格底下的那条线的颜色
mChart.setBorderColor(Color.rgb(213, 216, 214));
//设置Y轴前后倒置
mChart.setInvertYAxisEnabled(false);
//设置高亮显示
mChart.setHighlightEnabled(true);
//设置是否可以触摸,如为false,则不能拖动,缩放等
mChart.setTouchEnabled(true);
//设置是否可以拖拽,缩放
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
//设置是否能扩大扩小
mChart.setPinchZoom(true);
// 设置背景颜色
mChart.setBackgroundResource(R.mipmap.mpandroidchart_bc);
//设置点击chart图对应的数据弹出标注
//MyMarkerView mv = new MyMarkerView(this, R.layout.custom_marker_view);
// define an offset to change the original position of the marker
// (optional)
//定义一个偏移量来改变标记的原始位置
//mv.setOffsets(-mv.getMeasuredWidth() / 2, -mv.getMeasuredHeight());
// set the marker to the chart
//设置标记图
//mChart.setMarkerView(mv);
// enable/disable highlight indicators (the lines that indicate the
// highlighted Entry)
//启用/禁用突出指标(表明行突出显示的条目)
mChart.setHighlightIndicatorEnabled(false);
XLabels xl = mChart.getXLabels();
// xl.setAvoidFirstLastClipping(true);
// xl.setAdjustXLabels(true);
xl.setPosition(XLabels.XLabelPosition.BOTTOM); // 设置X轴的数据在底部显示
xl.setTextSize(10f); // 设置字体大小
xl.setSpaceBetweenLabels(3); // 设置数据之间的间距
YLabels yl = mChart.getYLabels();
// yl.setPosition(YLabelPosition.LEFT_INSIDE); // set the position
yl.setTextSize(10f); // s设置字体大小
yl.setLabelCount(5); // 设置Y轴最多显示的数据个数
// 加载数据
setData();

//从X轴进入的动画
mChart.animateX(2000);
mChart.animateY(2000); //从Y轴进入的动画
mChart.animateXY(2000, 2000); //从XY轴一起进入的动画

//设置最小的缩放
mChart.setScaleMinima(0.5f, 1f);
//设置视口
// mChart.centerViewPort(10, 50);
// get the legend (only possible after setting data)
//后得到图例(唯一可能设置数据)

Legend l = mChart.getLegend();
l.setForm(Legend.LegendForm.LINE);  //设置图最下面显示的类型
l.setTextSize(15);
l.setTextColor(Color.rgb(104, 241, 175));
l.setFormSize(30f); // set the size of the legend forms/shapes 图例形式/形状的大小

// 刷新图表
mChart.invalidate();

        set1.setDrawCubic(true);  //设置曲线为圆滑的线
set1.setCubicIntensity(0.2f);
set1.setDrawFilled(false);  //设置包括的范围区域填充颜色
set1.setDrawCircles(true);  //设置有圆点
set1.setLineWidth(2f);    //设置线的宽度
set1.setCircleSize(5f);   //设置小圆的大小
set1.setHighLightColor(Color.rgb(244, 117, 117));
set1.setColor(Color.rgb(104, 241, 175));    //设置曲线的颜色
// create a data object with the datasets
LineData data = new LineData(xVals, set1);

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/70825.html

相关文章

  • Android干货框架集锦,搭建项目必不可少

    摘要:最佳解析最佳解析最佳解析是一个依赖注入框架,由谷歌开发,最早的版本由公司开发。在对的介绍中指出,即,这里的即数据结构中的有向无环图。也就是说,是一个基于有向无环图结构的依赖注入库,因此的使用过程中不能出现循环依赖。 在开发过程中使用过很多优秀框架,比如网络的okhttp,图片的Fresco,注入的Gagger2等,都是非常优秀的框架。 所以今天在此介绍下至今本人知道的一些比较流行主流且...

    zhisheng 评论0 收藏0
  • 响应式 React Native Echarts 组件

    摘要:额外的三个参数赋给的参数对象,发生变化后内部会自动调用,实现响应式刷新。利用,实现了通知执行在中,可利用实现的事件向组件的通信。 一种在 React Native 中封装的响应式 Echarts 组件,使用与示例请参见:react-native-echarts-demo 近年来,随着移动端对数据可视化的要求越来越高,类似 MPAndroidChart 这样的传统图表库已经不能满足产品...

    plokmju88 评论0 收藏0

发表评论

0条评论

最新活动
阅读需要支付1元查看
<