android plot,在Android上绘制图表 – androidplot和achartengi...

我想在我的Activity中集成一个简单的XY线图.在寻找带有自定义(自定义背景,颜色,轴标签)的免费图表时,我找到了两个候选人:Achartengine和Adnroidplot.还有一些其他库,但它们不可自定义或仅作为单独的Intent提供.

我还需要支持旧的Android API(必须支持至少1.6).

我尝试过Achartengine,但是当我将它集成到ScrollView中时失败了.当我滚动时,图表变得有点腐败,它被挤压,一些背景元素似乎消失了.

然后我尝试了Adnroidplot.起初它没有从1.6开始因为Pair类.但我在Adnroidplot论坛上找到了解决问题的方法.一切似乎工作正常,虽然自定义Observers工作正常,也动态更新.自定义X轴标签有点困难(我需要自定义字符串而不是数字),但是使用自定义格式化程序我终于做到了.

但后来我尝试使用来自客户端数据库的真实数据.有一系列具有相同价值的点.我很震惊地看到Adnroidplot无法绘制水平线,它会挂起或完全弄乱图表!

以下是测试用例,我从Adnroidplot Quickstart借用了它,并进行了一些小修改,使一个系列具有相同的值:

pricesPlot = (XYPlot) findViewById(R.id.mySimpleXYPlot);

// Create array of y-values to plot:

Number[] series1Numbers = {7, 7}; // horizontal line expected, got nothing or hang

// Turn the above arrays into XYSeries:

XYSeries series1 = new SimpleXYSeries(

Arrays.asList(series1Numbers), // SimpleXYSeries takes a List so turn our array into a List

ArrayFormat.Y_VALS_ONLY, // Y_VALS_ONLY means use the element index as the x value

"Series1"); // Set the display title of the series

// Create a formatter to use for drawing a series using LineAndPointRenderer:

LineAndPointFormatter series1Format = new LineAndPointFormatter(

Color.rgb(0, 200, 0), // line color

Color.rgb(0, 100, 0), // point color

null); // fill color (optional)

// Add series1 to the xyplot:

pricesPlot.addSeries(series1, series1Format);

// Reduce the number of range labels

pricesPlot.setTicksPerRangeLabel(3);

// By default, AndroidPlot displays developer guides to aid in laying out your plot.

// To get rid of them call disableAllMarkup():

pricesPlot.disableAllMarkup();

我已经在Adnroidplot论坛上发布了,但我不确定他们会有多快回答以及何时解决问题.

所以我希望StackOverflow上的某个人可能知道一些解决方法吗?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值