2012-12-23 67 views
0

看到下面的圖片。梯度被錯誤地繪製,並且垂直的黑色線條是醜陋的。如何設置「絕對」區域漸變?

  1. 如何創建從min延伸到max的漸變?例如。如果我有從0到100的比例,我希望我的區域使用這些0..100個梯度值中的N個。
  2. 如何去除垂直黑線?

Bad gradient

UPDATE:所提供的答案的作品,但我得到這個神器:

Artifact

更新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。巴姆!偏移錯誤:)

+0

很抱歉,但我忘了問你,如果你能解釋一下你想要達到什麼目的,因爲我們清楚你的目標是什麼。 謝謝, –

+0

我希望漸變從最小值漸變到最大值(在這種情況下爲0到100)。所以在上面的圖片中,80點將會有第80個漸變顏色(幾乎是綠色)。 50點的顏色將爲第50梯度顏色(黃色)。我相信你需要一個新的漸變類型:'SYMMETRICRECTGRADIENT'。 – l33t

+0

這很容易在Excel中生成。只需使用線性漸變填充顏色創建面積圖即可。此外,它支持梯度的多個停止。這也是必須的:/ – l33t

回答

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

這就是我與上面的代碼:

Area with SeriesBand tool to show a uniform gradient

更新:我轉載的怪神器問題。我已添加到希望列表中進一步調查(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); 
+0

好吧,幾乎可以工作。漸變看起來不錯,但我在區域上方有一個黑色邊框。實際上,在整個控制之上。我將發佈顯示此錯誤的圖片。我嘗試過:'band.getPen()。setVisible(false);'但是沒有成功... – l33t

+0

另外''SeriesBand'不適用於'Bar'系列!沒有什麼是爲一列和多列繪製一些三角形... – l33t

+0

我編輯了答案,顯示我在這裏得到的。我看不到奇怪的線條。也許你正在使用一些不同的代碼? – Yeray

0

如何創建從最小值延伸到最大值的漸變?例如。如果我 的比例從0到100,我希望我的區域使用這些0..100, 中的N個梯度值。

恐怕不可能使用0 ... 100梯度根據比例,所以區域的梯度分佈在整個區域使用開始,中間和結束顏色繪製梯度。

如何去除垂直黑線?

要刪除垂直的黑線,只需設置虛線區域線。

我希望能幫上忙。

感謝,

+0

線條消失了。謝謝:)關於漸變,這是必須的!這有什麼可能實現的機會,還是我需要購買源代碼並自己實現? – l33t

+0

嘗試使用SeriesBand工具。我會發布更完整的回覆。 – Yeray