如何在我的应用程序中绘制图形?

时间:2021-09-23 21:15:41

I need to incorporate a graph into my android application, I am trying to follow this tutorial:

我需要在我的Android应用程序中加入一个图形,我正在尝试按照本教程:

http://www.jjoe64.com/2011/07/chart-and-graph-library-for-android.html

I tried putting it into my activity class and it shows up with a ton of errors related to GraphView. Here are the snippets of code:

我尝试将它放入我的活动类中,它显示出与GraphView相关的大量错误。以下是代码片段:

// graph with dynamically genereated horizontal and vertical labels   
GraphView graphView = new GraphView(   
  this // context   
  , new GraphViewData[] {   
    new GraphViewData(1, 2.0d)   
    , new GraphViewData(2, 1.5d)   
    , new GraphViewData(2.5, 3.0d) // another frequency   
    , new GraphViewData(3, 2.5d)   
    , new GraphViewData(4, 1.0d)   
    , new GraphViewData(5, 3.0d)   
  } // data   
  , "GraphViewDemo" // heading   
  , null // dynamic labels   
  , null // dynamic labels   
);   
LinearLayout layout = (LinearLayout) findViewById(R.id.graph1);   
layout.addView(graphView);

3 个解决方案

#1


0  

You are supposed to put it in your onCreate method of your activity after you call setContentView method.

在调用setContentView方法后,您应该将它放在活动的onCreate方法中。

#2


0  

This library has issues, because there is no Javadoc and you have to figure out how to use it by reading the source code. You may get compile errors relating to GraphViewData, because you are supposed to explicitly import this class embedded within the GraphView class:

这个库有问题,因为没有Javadoc,你必须通过阅读源代码弄清楚如何使用它。您可能会遇到与GraphViewData相关的编译错误,因为您应该显式导入嵌入在GraphView类中的此类:

import com.jjoe64.graphview.GraphView.GraphViewData;

You also cannot have a black text, white background colour scheme without "hacking the source code". It assumes you need only light text, black background graphs.

您也不能拥有黑色文本,白色背景配色方案而不“黑客入侵源代码”。它假设您只需要浅色文本,黑色背景图。

#3


0  

You should use AchartEngineAchartEngine

你应该使用AchartEngineAchartEngine

its good for making any type of chart and graphs in android..it may be helpful to you...!

它有利于在android中制作任何类型的图表和图形。它可能对你有帮助......!

#1


0  

You are supposed to put it in your onCreate method of your activity after you call setContentView method.

在调用setContentView方法后,您应该将它放在活动的onCreate方法中。

#2


0  

This library has issues, because there is no Javadoc and you have to figure out how to use it by reading the source code. You may get compile errors relating to GraphViewData, because you are supposed to explicitly import this class embedded within the GraphView class:

这个库有问题,因为没有Javadoc,你必须通过阅读源代码弄清楚如何使用它。您可能会遇到与GraphViewData相关的编译错误,因为您应该显式导入嵌入在GraphView类中的此类:

import com.jjoe64.graphview.GraphView.GraphViewData;

You also cannot have a black text, white background colour scheme without "hacking the source code". It assumes you need only light text, black background graphs.

您也不能拥有黑色文本,白色背景配色方案而不“黑客入侵源代码”。它假设您只需要浅色文本,黑色背景图。

#3


0  

You should use AchartEngineAchartEngine

你应该使用AchartEngineAchartEngine

its good for making any type of chart and graphs in android..it may be helpful to you...!

它有利于在android中制作任何类型的图表和图形。它可能对你有帮助......!