0

见下图。渐变画错了,垂直的黑线很丑。

  1. 如何创建从min到的渐变max?例如,如果我有一个从 0 到 100 的刻度,我希望我的区域使用这些 0..100 梯度值中的 N 个。
  2. 如何去除垂直的黑线?

渐变不好

更新:提供的答案有效,除了我得到这个工件:

神器

更新 2:这仅在使用 ONE 时发生LinearLayout,如下所示:

<?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>

然后TChart添加到chart_layout. 砰!偏移错误:)

4

2 回答 2

1

如何创建从最小到最大的渐变?例如,如果我有一个从 0 到 100 的刻度,我希望我的区域使用这些 0..100 梯度值中的 N 个。

我希望渐变从最小值渐变到最大值(在这种情况下为 0 到 100)。所以在上图中,80 处的点将具有第 80 种渐变颜色(几乎是绿色)。50 处的点将具有第 50 种渐变颜色(黄色)。我相信你需要一个新的渐变类型:SYMMETRICRECTGRADIENT

区域系列在下一个之前绘制线段,以及每个线段下方的区域以及这些线段中的每一个。这就是为什么 Area 系列不能绘制均匀渐变的原因。但是,其他版本的 TeeChart 具有 GradientRelative,当它设置为 false 时,它​​会执行您请求的操作。我已将在 Java 版本 (TJ71016477) 中实现此属性(以及相关函数)的可能性添加到愿望清单中。

同时,您可以使用 SeriesBand 工具来执行此操作。这是一个例子:

    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);

这就是我通过上面的代码得到的:

使用 SeriesBand 工具显示均匀渐变的区域

更新:我已经重现了奇怪的工件问题。我已添加到愿望清单以进行进一步调查(TJ71016541)。与此同时,LinearLayout只为图表使用一秒钟似乎工作正常。

<?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>

正如评论中所说,另一种解决方法是隐藏区域线并使 SeriesBand 笔可见:

area1.getLinePen().setVisible(false);
band1.getPen().setVisible(true);
于 2013-01-03T16:11:56.630 回答
0

如何创建从最小到最大的渐变?例如,如果我有一个从 0 到 100 的刻度,我希望我的区域使用这些 0..100 梯度值中的 N 个。

恐怕不可能根据比例使用 0...100 渐变,因此区域的渐变分布在整个区域中,使用开始、中间和结束颜色来绘制渐变。

如何去除垂直的黑线?

要删除垂直黑线,您只需将区域线设置为 false。

我希望会有所帮助。

谢谢,

于 2012-12-24T13:56:12.293 回答