如何在MPAndroidChart中设置说明? [英] How to set description in MPAndroidChart?

查看:346
本文介绍了如何在MPAndroidChart中设置说明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的 MPAndroidChart 用户.

我在网上和Wiki上找到的示例这里全部给出setDescription()原型为:

The examples I have found on-line and the Wiki here all give the setDescription() prototype as:

setDescription(String desc)`

但是,mChart.setDescription("");不能为我编译,AndroidStudio->转到声明"告诉我Chart.java中定义的setDescription的声明是:

However, mChart.setDescription(""); does not compile for me and AndroidStudio->Go To Declaration tells me the declaration for setDescription defined in Chart.java is :

   public void setDescription(Description desc) {
        this.mDescription = desc;
    }

Description.java中的Description构造函数不使用字符串.

And the Description constructor in Description.java does not take a String.

如何设置描述(或至少将其关闭)?我是在指向错误的库吗?

How do I set the description (or at least turn it off)? Am I pointing to the wrong libraries?

这是我的应用程序的gradle文件:

Here is my app's gradle file:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
allprojects {
    repositories {
        maven { url "https://jitpack.io" }
    }
}
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

然后,模块gradle文件:

And, the module gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.example.android.nbmc_hbmc"
        minSdkVersion 19
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.1.0'
    compile 'com.github.PhilJay:MPAndroidChart:v3.0.1'
    compile 'com.google.android.gms:play-services-auth:10.0.1'
    compile 'pub.devrel:easypermissions:0.2.1'
    testCompile 'junit:junit:4.12'
}

这是我的图表代码.它可以编译并显示图表,但是它具有描述标签"描述标签",我无法更改或关闭该标签.

And this is my chart code. It compiles and shows the chart but it has the Description Label "Description Label" that I can't change or turn off.

import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.components.Description;
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.interfaces.datasets.ILineDataSet;

import java.util.ArrayList;
import java.util.List;

import static com.example.android.nbmc_hbmc.R.id.chart;

public class NbmcEcgGraphActivity extends Activity {


    private RelativeLayout mainLayout;
    private LineChart mChart;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ecggraph);
        mainLayout = (RelativeLayout) findViewById(R.id.activity_ecggraph);

        // Create new line chart
        LineChart mChart = (LineChart) findViewById(chart);

        mChart.setDescription(new Description());
        mChart.setNoDataText("No Data Yet");

推荐答案

维基似乎已经过时了!

MPAndroidChart 3.0.1中的正确语法是

The correct syntax in MPAndroidChart 3.0.1 is

mChart.getDescription().setText("Description of my chart");

参考: javadoc

这篇关于如何在MPAndroidChart中设置说明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆