1

我正在尝试使用 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>

这就是我得到的:在此处输入图像描述

大编辑!

现在标签出现了,但它们太大了,我怎样才能减少字体字母以及整体显示?

字体出现,但太大(更改图形类型)

4

1 回答 1

3

问题可能在于您的文本是白色的。试试看嘛

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

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

于 2014-06-19T07:06:17.523 回答