最牛逼android上的图表库MpChart(一) 介绍篇

最牛逼android上的图表库MpChart(一) 介绍篇

最近工作中,用到了mpchart图表库,现在分享受下mpchart图表库的各个图表在实际工作应用场景:

  • 最牛逼android上的图表库MpChart(一) 介绍篇
  • 最牛逼android上的图表库MpChart(二) 折线图
  • 最牛逼android上的图表库MpChart(三) 条形图
  • 最牛逼android上的图表库MpChart(四) 饼图
  • 最牛逼android上的图表库MpChart(五) 泡泡图

写在前面的:学习任何新的开源库,首先不要怕,第二不要慌,大多都有对应的wiki,如MpChart是philjay提供的,其主要优点如下:

MpChart优点

  • 8种不同的图表类型
  • 缩放两个轴(与触摸手势,轴分别或捏变焦)
  • 拖动/平移(触摸手势)
  • 组合图表(线,酒吧,散射,蜡烛数据)
  • 双(独立)轴
  • 可定制的轴(X,Y轴)
  • 突出价值观(可定制的弹出视图)
  • 图表保存到SD卡(如图像,或为.txt文件)
  • 预定义的颜色模板
  • 传奇(自动生成,可定制)
  • 动画(建立动画,在X和Y轴)
  • 限制线(提供额外的信息,最大值,…)
  • 完全可定制的(油漆、字体、颜色、背景、传说、手势、虚线,…)
  • 平滑缩放和滚动的多达30个数据点,线和条线图
  • Gradle支持
  • 绘图数据直接从realm.io移动数据库

MpChart是什么?

MPAndroidChart :zap: is a powerful & easy to use chart library for Android. It runs on API level 8 and upwards.(强大,易用的图表库,支持api 8以上)
As an additional feature, this library allows cross-platform development between Android and iOS as an iOS version of this library is also available: Charts :zap:(除此之外,还支持跨平台,iOS也能用)

MpChart支持哪些图表?

图表类型
条型图
折线图
饼图
散点图
泡泡图
直方图
雷达图
组合图

MpChart效果如何?

LineChart (with legend, simple design)
这里写图片描述

LineChart (with legend, simple design)
这里写图片描述

LineChart (cubic lines)
这里写图片描述

LineChart (gradient fill)
这里写图片描述

Combined-Chart (bar- and linechart in this case)
这里写图片描述

BarChart (with legend, simple design)
这里写图片描述

BarChart (grouped DataSets)
这里写图片描述

Horizontal-BarChart
这里写图片描述

PieChart (with selection, …)
这里写图片描述

未完待续

  • 7
    点赞
  • 50
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
好的,下面是一个简单的 Android Binder Demo。 首先,我们定义一个 AIDL 接口文件 `IDemoService.aidl`,它包含一个方法 `int add(int a, int b)`,用于计算两个整数的和。 ```aidl // IDemoService.aidl interface IDemoService { int add(int a, int b); } ``` 然后,我们实现这个接口,创建一个名为 `DemoService` 的服务类,它继承自 `IDemoService.Stub`,实现 `add()` 方法。 ```java // DemoService.java public class DemoService extends IDemoService.Stub { @Override public int add(int a, int b) throws RemoteException { return a + b; } } ``` 接下来,我们创建一个 `Service` 类 `DemoServiceClass`,并在其中实现 `onBind()` 方法,返回 `DemoService` 对象。 ```java // DemoServiceClass.java public class DemoServiceClass extends Service { private DemoService demoService; @Override public void onCreate() { super.onCreate(); demoService = new DemoService(); } @Nullable @Override public IBinder onBind(Intent intent) { return demoService; } } ``` 最后,在 `AndroidManifest.xml` 中声明服务。 ```xml <!-- AndroidManifest.xml --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.binderdemo"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <!-- 声明 DemoServiceClass --> <service android:name=".DemoServiceClass" /> <activity android:name=".MainActivity" android:theme="@style/AppTheme.NoActionBar"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> ``` 现在,我们可以在 `MainActivity` 中创建一个远程服务连接,调用 `add()` 方法并显示结果。 ```java // MainActivity.java public class MainActivity extends AppCompatActivity { private IDemoService demoService; private boolean connected = false; private ServiceConnection connection = new ServiceConnection() { @Override public void onServiceConnected(ComponentName componentName, IBinder iBinder) { demoService = IDemoService.Stub.asInterface(iBinder); connected = true; } @Override public void onServiceDisconnected(ComponentName componentName) { demoService = null; connected = false; } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Intent intent = new Intent(this, DemoServiceClass.class); bindService(intent, connection, Context.BIND_AUTO_CREATE); Button button = findViewById(R.id.button); final TextView result = findViewById(R.id.result); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (connected) { try { int a = Integer.parseInt(((EditText) findViewById(R.id.input1)).getText().toString()); int b = Integer.parseInt(((EditText) findViewById(R.id.input2)).getText().toString()); int sum = demoService.add(a, b); result.setText(String.valueOf(sum)); } catch (RemoteException e) { e.printStackTrace(); } } else { result.setText("Service not connected"); } } }); } @Override protected void onDestroy() { super.onDestroy(); unbindService(connection); } } ``` 这就是一个简单的 Android Binder Demo。它演示了如何创建一个远程服务,实现 AIDL 接口并将其绑定到 Activity。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值