MPAndroidChart填充颜色渐变

时间:2015-10-02 12:47:36

标签: android charts mpandroidchart

MPAndroidChart(或任何其他Android图表库)是否可以使用渐变颜色填充绘制线下的图表?像这样:

set1.setFillColor(getResources().getColor(R.drawable.chart_fill));

然后在chart_fill.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >

    <gradient
        android:angle="90"
        android:endColor="#FF207a54"
        android:startColor="#FFffffff" />

</shape>

3 个答案:

答案 0 :(得分:11)

您可以使用以下两种方法:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:GetBucketLocation",
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::*"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:PutObject",
                "s3:GetObject",
                "s3:DeleteObject",
                "s3:PutObjectVersion",
                "s3:GetObjectVersion",
                "s3:DeleteObjectVersion",
                "s3:ListMultipartUploadParts",
                "s3:ListMultipartUpload",
                "s3:RestoreObject",
                "s3:GetObjectVersionTorrent",
                "s3:GetObjectTorrent",
                "s3:PutObjectVersionTagging",
                "s3:PutObjectTagging",
                "s3:GetObjectVersionTagging",
                "s3:GetObjectTagging",
                "s3:DeleteObjectTagging",
                "s3:DeleteObjectVersionTagging"
            ],
            "Resource": [
                "arn:aws:s3:::travis-s3-pub-test/*"
            ]
        }
    ]
}

这是指该班级javadoc的链接。

这是MPAndroidChart sample project

中的示例
            "s3:PutObject",
            "s3:GetObject",
            "s3:DeleteObject",

LineRadarDataSet#setDrawFilled(boolean isFilled); LineRadarDataSet#setFillDrawable(Drawable d);

set1.setDrawFilled(true);
if (Utils.getSDKInt() >= 18) {
    // fill drawable only supported on api level 18 and above
    Drawable drawable = ContextCompat.getDrawable(this, R.drawable.fade_red);
    set1.setFillDrawable(drawable);
}
else {
    set1.setFillColor(Color.BLACK);
}

以下是fade_red.xml上的示例样本:

a line chart with a red gradient fill

答案 1 :(得分:3)

科特琳解决方案:

- hosts: localhost
  roles:
    - { role: roleone }
    - { role: roletwo, myvariable : ["var1","var2"] }

这是- hosts: localhost roles: - { role: roleone } - { role: roletwo, myvariable : ["foo1","foo2"], when: init=="true", myvariable : ["bar1","bar2"], when: init == "false" } 文件:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
    lineDataSet.setDrawFilled(true)
    val fillGradient = ContextCompat.getDrawable(requireContext(), R.drawable.red_gradient)
    lineDataSet.fillDrawable = fillGradient
}

答案 2 :(得分:2)

好的,我找到了解决方案:

William Chart我正在使用这种方法:

int[] colors = { getResources().getColor(R.color.menu_text),
 getResources().getColor(android.R.color.white) };

float[] index = { 0, 1 };
dataset.setGradientFill(colors, index);