java如何绘制温度实时曲线_Android实现天气预报温度/气温折线趋势图

本文介绍了如何在Android平台上使用MPAndroidChart库来绘制天气预报的温度折线图,包括高温线和低温线。详细讲解了设置X轴、Y轴、数据点以及折线样式的方法,并提供了主Activity的代码示例。
摘要由CSDN通过智能技术生成



Android实现天气预报温度/气温折线趋势图

天气预报的APP应用中,难免会遇到绘制天气温度/气温,等关于数据趋势的折线或者曲线图,这类关于气温/温度的折线图,一般会有两条线,一条是高温线,一条是低温线。

我之前介绍了一个Android平台上第三方开源框架的统计图表库MPAndroidChart(文章链接地址:http://blog.csdn.net/zhangphil/article/details/47656521 ),具体使用方法详情请看这篇文章。

现在基于Android平台上的MPAndroidChart实现气温/温度折线图。

主Activity:MainActivity.java的全部代码:

package zhangphil.chart;

import java.text.DecimalFormat;

import java.util.ArrayList;

import android.app.Activity;

import android.graphics.Color;

import android.os.Bundle;

import com.github.mikephil.charting.charts.LineChart;

import com.github.mikephil.charting.components.Legend;

import com.github.mikephil.charting.components.Legend.LegendForm;

import com.github.mikephil.charting.components.Legend.LegendPosition;

import com.github.mikephil.charting.components.XAxis;

import com.github.mikephil.charting.components.XAxis.XAxisPosition;

import com.github.mikephil.charting.components.YAxis;

import com.github.mikephil.charting.components.YAxis.AxisDependency;

import com.github.mikephil.charting.data.Entry;

import com.github.mikephil.charting.data.LineData;

import com.github.mikephil.charting.data.LineDataSet;

import com.github.mikephil.charting.utils.ValueFormatter;

public class MainActivity extends Activity {

@Override

protected void onCrea

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值