2014-06-19 44 views
1

我試圖使用GraphView但我似乎不能有標籤:/的Android GraphView

這是我GraphView:

// init example series data 
GraphViewSeries exampleSeries = new GraphViewSeries(new GraphViewData[] { 
    new GraphViewData(1, 2.0d) 
    , new GraphViewData(2, 1.5d) 
    , new GraphViewData(3, 2.5d) 
    , new GraphViewData(4, 1.0d) 
}); 
  
GraphView graphView = new LineGraphView(this , "GraphViewDemo"); 
graphView.setHorizontalLabels(new String[] {"2 days ago", "yesterday", "today", "tomorrow"}); 
graphView.setVerticalLabels(new String[] {"high", "middle", "low"}); 
graphView.addSeries(exampleSeries); 
  
LinearLayout layout = (LinearLayout) findViewById(R.id.layout); 
layout.addView(graphView); 

,這是我的xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context=".MainActivity" android:id="@+id/layout" 
    android:orientation="vertical"> 
</LinearLayout> 

這就是我得到的:enter image description here

Big Edit!

現在標籤出現了,但它們太大了,我怎樣才能減少字體字母以及整體顯示呢?

Font appear, but too big(changed the type of graph)

+0

我應該得到的左和底部標籤,但我不能:/ – SnakeSheet

+0

你有非常大的文本爲您graphview –

+0

標籤我怎麼能降低顯示器? – SnakeSheet

回答

3

的問題可能是您的文字是白色。試試吧

graphView.getGraphViewStyle()。setHorizo​​ntalLabelsColor(Color.BLACK); graphView.getGraphViewStyle()。setVerticalLabelsColor(Color.BLACK);

文本的大小可以更改如下... graphView.getGraphViewStyle()。setTextSize(11);

+0

非常感謝!現在我怎樣才能減少顯示?以及字母字體? – SnakeSheet

+0

我編輯了我的答案。希望它有助於:) –

+0

它的作品就像一個魅力!非常感謝你 ! – SnakeSheet