如何设置"绝对"区域梯度? [英] How to set "absolute" area gradient?

查看:172
本文介绍了如何设置"绝对"区域梯度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请参阅下面的图片。梯度被错误地画,而垂直的黑线只是丑陋。


  1. 如何创建从绵延分钟最大渐变?例如。如果我有一个规模从0到100我想我区使用这些0..100梯度值N个。

  2. 如何去除垂直的黑线?

更新:提供的答案的作品,但我得到这个神器:

更新2::此仅使用一个时发生的LinearLayout ,如下所示:

 <?XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:ID =@ + ID / chart_layout
    机器人:layout_width =match_parent
    机器人:layout_height =WRAP_CONTENT
    机器人:方向=垂直
    机器人:填充=3dip>    <微调
        机器人:layout_width =match_parent
        机器人:layout_height =WRAP_CONTENT/>    <微调
        机器人:layout_width =match_parent
        机器人:layout_height =WRAP_CONTENT/>    <微调
        机器人:layout_width =match_parent
        机器人:layout_height =WRAP_CONTENT/>< / LinearLayout中>

然后 TChart 添加到 chart_layout 。巴姆!失调误差:)


解决方案

  

如何创建,从最小延伸到最大值的梯度?例如。如果我有一个规模从0到100我想我区使用这些0..100梯度值N个。


  
  

我想要的梯度从最小到淡出到最大(0至100在这种情况下)。所以上面的图片中,指着80将有80个渐变色(几乎绿色)。点,在50将具有50渐变颜色(黄色)。我相信你需要一个新的渐变类型:SYMMETRICRECTGRADIENT


该地区系列绘制段的人之前下了,每个段下的区域与每个段。这就是为什么区系列不能得出一个统一的梯度。然而,于TeeChart的其他版本有,做当它设置为false,你要求什么GradientRelative。我已经加入到愿望清单来实现此属性(以及相关的函数)的Java版本(TJ71016477)的可能性

在此期间,您可以使用SeriesBand工具来做到这一点。这是一个例子:

  tChart1.getAspect()setView3D(假)。
    。tChart1.getLegend()调用setVisible(假);    区区1 =新区域(tChart1.getChart());
    area1.fillSampleValues​​();
    area1.setOrigin(0);
    area1.setUseOrigin(真);
    。area1.getAreaLines()调用setVisible(假);    。area1.getGradient()调用setVisible(假);
    area1.setColor(Color.transparent);    SeriesBand BAND1 =新SeriesBand(tChart1.getChart());
    band1.setSeries(区域);
    。band1.getGradient()调用setVisible(真);
    。band1.getGradient()setDirection(GradientDirection.VERTICAL);
    。band1.getGradient()setStartColor(Color.green);
    。band1.getGradient()setMiddleColor(Color.yellow);
    。band1.getGradient()setUseMiddle(真);
    。band1.getGradient()setEndColor(Color.red);

这是我所得到的与上述code:

更新:我转载的怪神器问题。我已经加入到愿望清单进一步调查(TJ71016541)。
在此期间,使用第二的LinearLayout 只是图表看起来工作正常。

 <?XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =match_parent
    机器人:layout_height =WRAP_CONTENT
    机器人:方向=垂直
    机器人:填充=3dip>    <微调
        机器人:layout_width =match_parent
        机器人:layout_height =WRAP_CONTENT/>    <微调
        机器人:layout_width =match_parent
        机器人:layout_height =WRAP_CONTENT/>    <微调
        机器人:layout_width =match_parent
        机器人:layout_height =WRAP_CONTENT/>    <的LinearLayout
        机器人:ID =@ + ID / chart_layout
        机器人:layout_width =match_parent
        机器人:layout_height =WRAP_CONTENT
        机器人:方向=垂直/>
< / LinearLayout中>

围绕此的另一种方式,如在注释所述被隐藏的区域线,使可见SeriesBand笔

  area1.getLinePen()调用setVisible(假)。
。band1.getPen()调用setVisible(真);

See the image below. The gradient is painted incorrectly, and the vertical black lines are just ugly.

  1. How do I create a gradient that stretches from min to max? E.g. If I have a scale from 0 to 100 I want my area to use N of these 0..100 gradient values.
  2. How do I remove the vertical black lines?

UPDATE: The provided answer works, except that I get this artifact:

UPDATE 2: This only happens when using ONE LinearLayout as shown below:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/chart_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:padding="3dip" >

    <Spinner
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <Spinner
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <Spinner
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</LinearLayout>

Then the TChart is added to chart_layout. Bam! Offset error :)

解决方案

How do I create a gradient that stretches from min to max? E.g. If I have a scale from 0 to 100 I want my area to use N of these 0..100 gradient values.

I want the gradient to fade from minimum to maximum (0 to 100 in this case). So in the image above, points at 80 would have the 80th gradient color (almost green). Points at 50 would have the 50th gradient color (yellow). I believe you need a new gradient type: SYMMETRICRECTGRADIENT

The Area series draws the segments one before the next, and the area below each segment with each of these segments. That's why the Area series can't draw a uniform gradient. However, the other versions of TeeChart have the GradientRelative that does what you request when it's set to false. I've added to the wish list the possibility to implement this property (and the functions associated) to the Java version (TJ71016477).

In the meanwhile, you could use the SeriesBand tool to do it. Here it is an example:

    tChart1.getAspect().setView3D(false);
    tChart1.getLegend().setVisible(false);

    Area area1 = new Area(tChart1.getChart());
    area1.fillSampleValues();
    area1.setOrigin(0);
    area1.setUseOrigin(true);
    area1.getAreaLines().setVisible(false);

    area1.getGradient().setVisible(false);
    area1.setColor(Color.transparent);

    SeriesBand band1 = new SeriesBand(tChart1.getChart());
    band1.setSeries(area1);
    band1.getGradient().setVisible(true);
    band1.getGradient().setDirection(GradientDirection.VERTICAL);
    band1.getGradient().setStartColor(Color.green);
    band1.getGradient().setMiddleColor(Color.yellow);
    band1.getGradient().setUseMiddle(true);
    band1.getGradient().setEndColor(Color.red);

This is what I get with the code above:

UPDATE: I've reproduced the strange artifact issue. I've added to the wish list to be further investigated (TJ71016541). In the meanwhile, using a second LinearLayout just for the chart seems to work fine.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:padding="3dip" >

    <Spinner
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <Spinner
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <Spinner
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <LinearLayout 
        android:id="@+id/chart_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" />
</LinearLayout>

Another way around this, as said in the comments, is hiding the area line and making visible the SeriesBand pen:

area1.getLinePen().setVisible(false);
band1.getPen().setVisible(true);

这篇关于如何设置&QUOT;绝对&QUOT;区域梯度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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