0
A
回答
0
我认为你不能用条形图中GraphView
但多个系列与不同的颜色和可滚动一个GraphView混合LineGraph看起来是这样的: (你会做关于视一些技巧,因为如果一列示出,其延伸视口以适应图表 - 它具有1个单位的宽度)
MainActivity.java
。public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GraphView graphView = new BarGraphView(this, "Graph Title");
GraphViewData[] data1 = new GraphViewData[] {
new GraphViewData(1, 5.0d),
new GraphViewData(2, 3.0d),
new GraphViewData(3, 4.0d),
new GraphViewData(4, 3.0d),
new GraphViewData(5, 7.0d),
new GraphViewData(6, 6.0d),
new GraphViewData(7, 7.0d),
new GraphViewData(8, 2.0d),
};
GraphViewSeriesStyle style1 = new GraphViewSeriesStyle();
style1.setValueDependentColor(new ValueDependentColor() {
@Override
public int get(GraphViewDataInterface data) {
if(((int)data.getX())%2 == 0) {
return Color.rgb(200, 60, 0);
}
else {
return Color.rgb(60, 200, 0);
}
}
});
GraphViewSeries series1 = new GraphViewSeries("Series 1", style1, data1);
graphView.setManualYAxisBounds(10,0);
graphView.setViewPort(1,3.99999);
graphView.setScrollable(true);
graphView.addSeries(series1);
LinearLayout layout = (LinearLayout) findViewById(R.id.graph1);
layout.addView(graphView);
}
activity_main.xml中
<RelativeLayout 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"
tools:context=".MainActivity">
<LinearLayout
android:id="@+id/graph1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"></LinearLayout>
相关问题
- 1. 如何使用图书馆
- 2. 使用图书馆
- 3. 如何从“Android的图书馆工程”
- 4. 如何使用任何图书馆
- 5. Android无法使用谷歌图书馆
- 6. Android的凌空图书馆
- 7. 使用lxml的图书馆
- 8. 如何为Android安装图书馆
- 9. 如何使用哈拉卡图书馆
- 10. 如何在图书馆中使用Realm
- 11. Android - 图书馆问题
- 12. Android Studio参考图书馆
- 13. Android build.gradle - 图书馆冲突
- 14. 适用于Android的图书馆
- 15. 如何设计图书馆?
- 16. 图书馆与图书馆项目与外部图书馆的区别
- 17. 如何将SailsJs用作图书馆?
- 18. 从图书馆
- 19. SimpleHTMLDom图书馆
- 20. VS2005图书馆
- 21. 图书馆
- 22. AndroidPdfViewer图书馆
- 23. 使用我的图书馆的AAR文件,该文件对其他图书馆
- 24. Android的Facebook的图书馆发行
- 25. DocsClient的图书馆
- 26. android graphview条形图
- 27. android:图书馆模块中的fcm
- 28. CircularImage图书馆夸大错误的Android
- 29. 我如何要求图书馆比Play所需的图书馆更新!框架?
- 30. 带类的图书馆如何工作?
您好,感谢您的片断。你知道如何在小节之间添加边距吗? – redrom 2014-09-11 09:51:57
您可以尝试将条放置在移位的x坐标处。新GraphViewData(1,3.0d),' '新GraphViewData(2,3.0d),' '新GraphViewData(3.5,4.0d),' '新GraphViewData(4.5,3.0d),' '新的GraphViewData(6,7.0d),' ... 或尝试编辑库源自身并在那里更改栏宽。 – Gyebro 2014-09-11 15:19:39