当用户触摸图表时,我想仅显示折线图的垂直突出显示线。目前它在水平和垂直方向上绘制参考线。有办法做到吗?
我正在使用 MPAndroidChart 创建一些折线图。由于数据太多,图表不够清晰,需要点击和缩放。
有没有办法设置要显示的 x-xalues 的最大值(例如最后 10 个)并通过滚动显示其他值?
我在文档中没有找到任何内容。我只找到了
setVisibleXRangeMaximum(float maxXRange): Sets the size of the area (range on the x-axis) that should be maximum visible at once. If this is e.g. set to 10, no more than 10 values on the x-axis can be viewed at once without scrolling.
Run Code Online (Sandbox Code Playgroud)
正如我所注意到的,该功能不适用于折线图。
当没有数据时,如何初始化MPAndroidChart ?当活动启动时,它会显示没有数据的消息。我想显示一个grid具有有效范围X-axis和Y-axis轴、标签以及背景网格线的布局。我刚刚从另一个“Graph”库迁移。每当活动启动时,它都会显示有效的图形网格布局。
我没有看到 \xe2\x80\x9cNo Chart data available\xe2\x80\x9d 文本的任何设置方法。如何使文本变大/变小?
\n有没有办法为饼图添加笔划?我想在我的所有切片上进行描边,不仅是外部,还包括内部。我在图书馆没有看到任何方法。任何帮助,将不胜感激。
我的应用程序中有一个PieChart,使用MPAndroidChart库,但默认情况下,图表切片百分比文本全为白色。设法更改百分比颜色,但无法对其描述文本执行相同操作。见下图
如何获取ScatterChart中像素点对应的x轴值(xIndex)?
我一直在查看该库的源代码,我认为下面的方法之一(我从此处的库的源代码复制/粘贴)可以提供帮助。这似乎getValuesByTouchPoint是正确的方法,但我不知道如何使用它。
/**
* Transformer class that contains all matrices and is responsible for
* transforming values into pixels on the screen and backwards.
*
* @author Philipp Jahoda
*/
public class Transformer {
/**
* matrix to map the values to the screen pixels
*/
protected Matrix mMatrixValueToPx = new Matrix();
/**
* matrix for handling the different offsets of the chart
*/
protected Matrix mMatrixOffset = new Matrix();
protected ViewPortHandler mViewPortHandler;
public Transformer(ViewPortHandler viewPortHandler) …Run Code Online (Sandbox Code Playgroud) 我正在使用 MPAndroidChart( https://github.com/PhilJay/MPAndroidChart )。
我制作了一个条形图,但没有显示 xAxis-2nd 值。
x,y : 1 周,3?
x,y : 2 周,0?
x,y : 3 周,0?
x,y : 4 周,0?
x,y : 5 周,0?
这些是我的入场价值。但是像这样,第二个标签没有显示在我的手机中。
我附上了源和结果截图。
ArrayList<BarEntry> entries = new ArrayList<>();
ArrayList<String> labels = new ArrayList<String>();
String[] labels2 = new String[ExRegList.length()];
try {
exerciseWholeCnt = ExRegList.length();
for (int i = 0; i < ExRegList.length(); i++) {
JSONObject obj = ExRegList.getJSONObject(i);
String week = obj.getString("WEEK");
int exCnt = obj.getInt("RESULT_COUNT");
labels.add(week + "?");
labels2[i] = week+"?";
entries.add(new BarEntry(i,exCnt));
} …Run Code Online (Sandbox Code Playgroud) 我尝试在 MPAndroidChart 的 PieChart 中管理文本。但是当我的文本是 True = 2, False = 3 , Not = 95 等困难情况时,在这种情况下,我的饼图布局非常糟糕。这是我的代码:-
fun setupPieChartView() {
mPie = findViewById(R.id.piechart)
mPie?.setUsePercentValues(true)
val desc: Description = Description()
desc.text = "PieChart"
mPie?.description = desc
val legend: Legend? = mPie?.legend
legend?.horizontalAlignment = Legend.LegendHorizontalAlignment.LEFT
val value = Arrays.asList(trueAns.toFloat(), wrongAns.toFloat(), noAns.toFloat())
val label = Arrays.asList("True", "false", "Not")
val entry = ArrayList<PieEntry>()
for (i in value.indices) {
entry.add(PieEntry(value.get(i), label.get(i)))
}
val dataSet = PieDataSet(entry, "Result")
dataSet.setColors(Color.GREEN, Color.RED, Color.GRAY);
dataSet.setDrawValues(true)
val pieData = PieData(dataSet)
pieData.setValueFormatter(PercentFormatter()) …Run Code Online (Sandbox Code Playgroud) 我有以下布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/toolbar_with_filter_back" />
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="@drawable/banner"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="0dp" />
<android.support.constraint.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_begin="165dp" />
<android.support.v7.widget.CardView
android:id="@+id/win_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/_5sdp"
android:elevation="@dimen/_8sdp"
app:cardCornerRadius="@dimen/_10sdp"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="true"
app:layout_constraintTop_toBottomOf="@+id/guideline">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="@dimen/_10sdp">
<android.support.v7.widget.CardView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.4"
android:gravity="center"
android:scaleType="fitXY"
app:cardCornerRadius="8dp"
app:cardPreventCornerOverlap="true">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/exec_business_icon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center"
android:scaleType="fitXY"
android:src="@drawable/icon_dairy" />
<TextView
android:id="@+id/exec_business_iconname"
android:layout_width="match_parent"
android:layout_height="wrap_content" …Run Code Online (Sandbox Code Playgroud)