导航:首页 > 操作系统 > androidlinechart

androidlinechart

发布时间:2022-08-10 13:55:09

android中listview的itemclick的getLineChartView方法错误

你要先写个适配器 ,定位点击的item的position , 这样才能捕捉到
item的点击事件 , 不然即使实现了点击事件 , item的位置也不会确定的 ,
甚至会乱掉 。

⑵ 如何在android画分析图(例如 柱状图、趋势图、饼图)

目前android上图标引擎并不少见,像aChartEngine就能很好的完成绘图:

aChartEngine支持:1、linechart(折线图)2、areachart(面积图;分区图,对比图)3、scatterchart(散点图)4、timechart(时间图;进度表)5、barchart(条形图;柱状图)6、piechart(饼图)7、bubblechart(气泡图)8、doughnutchart(圆环图)9、range(high-low)barchart(范围条形图)10、dialchart/gauge(拨号盘/压力表)11、combined(anycombinationofline,cubicline,scatter,bar,rangebar,bubble)chart(组合图)12、cubiclinechart(立方折线图)

上述所有支持的图表类型,都可以包含多个系列,都支持水平(默认)或垂直方式展示图表,并且支持许多其他的自定义功能。所有图表都可以建立为一个view,也可以建立为一个用于启动activity的intent.

下面是一个饼状图的源码事例:

package org.achartengine.chartdemo.demo.chart;


import org.achartengine.ChartFactory;

import org.achartengine.renderer.DefaultRenderer;


import android.content.Context;

import android.content.Intent;

import android.graphics.Color;


public class BudgetPieChart extends AbstractDemoChart {

public String getName() {

return "Budget chart";

}


public String getDesc() {

return "The budget per project for this year (pie chart)";

}

public Intent execute(Context context) {

double[] values = new double[] { 12, 14, 11, 10, 19 };//饼图分层5块,每块代表的数值

int[] colors = new int[] { Color.BLUE, Color.GREEN, Color.MAGENTA, Color.YELLOW, Color.CYAN };//每块饼图的颜色

DefaultRenderer renderer = buildCategoryRenderer(colors);

renderer.setZoomButtonsVisible(true);//设置显示放大缩小按钮

renderer.setZoomEnabled(true);//设置允许放大缩小.

renderer.setChartTitleTextSize(20);//设置图表标题的文字大小

return ChartFactory.getPieChartIntent(context, buildCategoryDataset("Project budget", values),

renderer, "Budget");//构建Intent, buildCategoryDataset是调用AbstraDemoChart的构建方法.

}


}

安卓怎么在linechart 让图例斜着

如果series1是你的lineseries的id的话series1.y实际上是你的series1在lineChart中的y方向离chart顶部的距离(只是一个位置),而不是你理解的open属性的值或y坐标,如果你没有手动设置过这个值,那么它的值应为0,也就是说你的else语句是永远成立的。 我没用过linechart设置其中部分线段的颜色(没有什么思路),但可以通过lineseries1的items数组中的各个对象或者定制lineseries1的itemrenderer来设置各个点的颜色

⑷ android用 MPAndroidChart空间生成曲线,怎么更改初始放大倍数初始刻度值

1,将MPAndroidChart添加进Android Project
新建AndroidChartDemo
从GitHub下载所需的mpandroidchartlibrary-2-0-9.jar
将下载好的jar包添加进工程下的libs文件夹下,并鼠标右键 Add as Libary
2,完成主界面布局
主界面布局是几个比较简单的button,代码如下:
layout->activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:layout_marginTop="50dp"
android:layout_marginBottom="4dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<Button
android:id="@+id/btn_linechart"
android:text="@string/linechart"
android:textColor="#ffffff"
android:textSize="18sp"
android:background="#8CEBFF"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Button
android:id="@+id/btn_barchart"
android:text="@string/barchart"
android:textColor="#ffffff"
android:textSize="18sp"
android:background="#8CEBFF"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<Button
android:id="@+id/btn_horizontalchart"
android:text="@string/horizontalchart"
android:textColor="#ffffff"
android:textSize="18sp"
android:background="#C5FF8C"
android:layout_marginTop="10dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:id="@+id/btn_combinedchart"
android:text="@string/combinedchart"
android:textColor="#ffffff"
android:textSize="18sp"
android:background="#FF6600"
android:layout_marginTop="10dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:id="@+id/btn_piechart"
android:text="@string/piechart"
android:textColor="#ffffff"
android:textSize="18sp"
android:background="#FF6600"
android:layout_marginTop="10dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:id="@+id/btn_scatterchart"
android:text="@string/scatterchart"
android:textColor="#ffffff"
android:textSize="18sp"
android:background="#FF6600"
android:layout_marginTop="10dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:id="@+id/btn_candlechart"
android:text="@string/candlechart"
android:textColor="#ffffff"
android:textSize="18sp"
android:background="#FF6600"
android:layout_marginTop="10dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:id="@+id/btn_radarchart"
android:text="@string/radarchart"
android:textColor="#ffffff"
android:textSize="18sp"
android:background="#FF6600"
android:layout_marginTop="10dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>

⑸ android中linechart折线图和barchart柱状图能在一起吗

横纵轴缩放,多指缩放,展现动画、高亮、保存到 sdcard、从文件读取图表
achartengine
强大的图表绘制工具,支持折线图、面积图、散点图、时间图、柱状图、条图、饼图、气泡图、圆环图、范围(高至低)条形图、拨号图/表、立方线图及各种图的结合
GraphView
绘制图表和曲线图的View,可用于Android上的曲形图、柱状图、波浪图展示
HoloGraphLibrary

⑹ 如何在 Android 应用中使用 FontAwesome 图标

FontAwesome 可以节省许多时间,原因如下:

首先,你不需要担心不同手机上的屏幕分辨率问题。如果你使用png图片,你需要在包里面对每个图标至少包含四种不同的版本。不仅如此,在某些超清屏幕上,你的图标可能会出现颗粒感。这显然是要避免的。但如果使用FontAwesome,你只需包含一个"TTF”文件。
其次,你可以依赖于当今最丰富的免费图标集之一。而且因为其在web上被广泛的使用,现在用户已经习惯了FontAwesome的风格。你不必再浪费时间去寻找漂亮的丰富的可以免费商用的图标集合,我并不是说不存在这样的图标集,因为确实存在,但是非常稀少。
1. FontAwesome 的工作原理
我们先花点时间来了解一下FontAwesome 的工作原理。FontAwesome 图标集背后的思想非常简单,图标被视为字符(character)。你可以能已经注意到一些奇怪的字符被作为文本对待,你可以轻易的拷贝 β 字符或者 ∑ 字符。你甚至可以在普通的文本编辑框中这样做。还可以改变它们的大小和颜色。这是因为浏览器 - 以及文本编辑框 - 把这些字符视为文本。
FontAwesome 通过包含广泛的图标扩展了这一概念。你可以把它比喻成用图标指定的不能打出的Unicode字符。
FontAwesome
看一眼 FontAwesome's cheatsheet 就知道我在说什么了。你选择列表中的一个图标,记下它的Unicode的字符,在TextView中使用它告诉安卓使用FontAwesome字体来渲染。
2. 导入字体文件
让我们来看一个例子。下载和导入FontAwesome 的TrueType 文件到项目。你可以从 GitHub上下载FontAwesome 的assets。
当你下载了FontAwesome之后,你会发现里面包含了一些文件和文件夹。大部分都是对web项目有用的。我们只对位于fonts目录的 fontawesome-webfont.ttf感兴趣。
在你的安卓项目中,导航到 app > src > main。 main 目录应该包含了一个叫 assets的文件夹。如果没有就创建一个。在assets 文件夹中创建另一个fonts文件夹,并把fontawesome-webfont.ttf 添加到这个文件夹。
主义 fonts 文件夹并不是必须的。你可以直接把FontAwesome 的字体文件放在 assets 目录,但是把相同类型的文件放在专门的目录里面比较方便。只要FontAwesome 字体在assets 或者子目录之下就行。
3. 创建一个帮助类
现在你已经成功的把FontAwesome 字体文件包含在了自己的安卓项目里,是时候使用它了。我们会创建一个帮助类来让事情变得简单点。这个类要使用到android.graphics.Typeface。Typeface类指定typeface 以及一个字体的特征。它用于指明text在绘制(以及测量)的时候该如何显示。
创建一个新的名叫FontManager的java类:

1
2
3
4
5
6
7
8
9
10

public class FontManager {

public static final String ROOT = "fonts/",
FONTAWESOME = ROOT + "fontawesome-webfont.ttf";

public static Typeface getTypeface(Context context, String font) {
return Typeface.createFromAsset(context.getAssets(), font);
}

}

如果你想在项目中使用其他的字体,把字体放在helper 类里面就可以了。类似于:

1

yourTextView.setTypeface(FontManager.getTypeface(FontManager.YOURFONT));

我们需要做的就这么多,但是我们可以做的更好。使用上面的方法的话,我们需要为每个想当成图标来使用的TextView创建一个变量。但作为一个程序员,我们都很懒,对吧?
图标一般都是包含在一个ViewGroup,比如一个RelativeLayout或者LinearLayout中。我们可以写一个方法,爬遍指定xml parent 并且递归的覆盖每个TextView的字体。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

public class FontManager {

// ...

public static void markAsIconContainer(View v, Typeface typeface) {
if (v instanceof ViewGroup) {
ViewGroup vg = (ViewGroup) v;
for (int i = 0; i < vg.getChildCount(); i++) {
View child = vg.getChildAt(i);
markAsIconContainer(child);
}
} else if (v instanceof TextView) {
((TextView) v).setTypeface(typeface);
}
}

}

假设你的布局文件是这样的:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/icons_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1" />

</LinearLayout>

要把这三个TextView标记为图标,我们重写onCreate方法,并添加如下代码片段:

1
2

Typeface iconFont = FontManager.getTypeface(getApplicationContext(), FontManager.FONTAWESOME);
FontManager.markAsIconContainer(findViewById(R.id.icons_container), iconFont);

4. 使用你想要的图标
现在轮到有意思的部分了。访问 FontAwesome的GitHub页面 并浏览所给的图标。选择三个你喜欢的。我准备选择三个chart图标,分别是 area chart icon, pie chart icon, 以及 line chart icon。
在你的项目中,进入 values 文件夹并创建一个新的文件:icons.xml。这个文件将被作为字典使用,它将把Unicode 字符和相应的图标用可读的名字匹配起来。这意味着我们需要为每个图标创建一个入口。

1
2
3
4
5

<resources>
<string name="fa_icon_areachart"></string>
<string name="fa_icon_piechart"></string>
<string name="fa_icon_linechart"></string>
</resources>

你可以在FontAwesome cheatsheet或者图标的 详情页面 找到你感兴趣图标的代码。
下一步就是在布局的TextView里面引用这些字符串。这是最终的样子:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1"
android:text="@string/fa_icon_areachart" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1"
android:text="@string/fa_icon_piechart" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1"
android:text="@string/fa_icon_linechart" />

如果你打开Android Studio的布局编辑器,你会看到它无法渲染这些图标。这是不正常的。编译并启动应用,你又会发现图标是正常渲染了的。

看起啦很小是吧?改变图标的大小很简单,你只需改变textSize属性就是了。改变图标的颜色也一样简单,编辑textColor属性就是了。

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1"
android:textSize="45sp"
android:textColor="#9b59b6"
android:text="@string/fa_icon_areachart" />

⑺ android studiodatachart怎么用

1.先从git上面clone下来所需要的项目依赖,复制MPChartLib到我们的项目中(与app)同级。

2.打开settings.gradle 输入

include 'MPChartLib'
打开app.build.gradle 输入

compile project (':MPChartLib')

3.在布局文件中加入LineChart

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.wingsofts.mpchartdemo.MainActivity">

<com.github.mikephil.charting.charts.LineChart
android:id="@+id/lineChart"
android:layout_width="match_parent"
android:layout_height="match_parent">

</com.github.mikephil.charting.charts.LineChart>
</RelativeLayout>
4.在代码中操作数据集。这里介绍一下涉及到的类

XAxis 为 X轴的类
Entry 为每个点的类

阅读全文

与androidlinechart相关的资料

热点内容
电影院办的卡可以在网上消费电影吗 浏览:835
主角专门抢别人老婆的都市小说 浏览:292
啄木鸟女星电影 浏览:866
c语言编程源码下载工具 浏览:781
儿女传奇电影系列 浏览:593
武平废品回收小程序源码 浏览:273
工作者迷失1963电影 浏览:703
余美颜摩登情书txt 浏览:819
linux命令大全完整版 浏览:829
单片机画电路图用什么软件好 浏览:108
phpfpm工作原理 浏览:421
加密u盘定制哪家好 浏览:947
如何将视频做成动态表情包安卓 浏览:964
外置打印服务器是什么 浏览:321
加密电脑钱包 浏览:693
javastring编程题 浏览:796
淑女宠爱在线电影 浏览:879
ipadstore是什么app 浏览:485
如何看华为服务器raid的型号 浏览:275