Android路径实时图表 [英] Android Paths for real time charting
问题描述
onDraw:
@覆盖
void onDraw(Canvas canvas){
scaleX = getWidth()/(maxX - minX);
scaleY = getHeight()/(maxY - minY);
// TODO:使用剪辑来绘制x / y轴,允许在属性中定义颜色等等。
canvas.drawColor(0xFF000000);
for(DataLine line:mPathList.values()){
canvas.drawPath(line,line.getPaint());
}
}
(DataLine是Path的子类,对象)
错误是来自OpenGLRenderer的警告:
形状路径太大,无法渲染到纹理
如果你查看你的日志,你会注意到这样的错误:
04-04 10:39:06.314:W / OpenGLRenderer(6092):形状路径太大,无法渲染到纹理中
由于打开硬件加速,一切都被渲染为纹理,并且纹理有一个大小限制。如果你把较大的形状分解成较小的形状,这将解决你的问题。或者只需关闭硬件加速:
android:hardwareAccelerated =false
/ pre>
I'm trying to create a real-time charting utility in android, and for the most part it works, except that when I get too many data points in one of my Paths it breaks openGL. I'm using paths because I'm transforming the entire dataset via matrix when a passed in value is outside the current bounds of the graph. Am I going about this the wrong way? is there a better/more appropriate API for this sort of thing? I'd be happy to trim the path to the current bounds if that were possible/I knew how to do it. Thanks!
onDraw:
@Override protected void onDraw(Canvas canvas) { scaleX = getWidth() / (maxX - minX); scaleY = getHeight() / (maxY - minY); // TODO: Use clips to draw x/y axis, allow color to be defined in attributes, etc. canvas.drawColor(0xFF000000); for (DataLine line : mPathList.values()) { canvas.drawPath(line, line.getPaint()); } }
(DataLine is a subclass of Path that includes a Paint object)
Error in question is a warning from the OpenGLRenderer: "Shape path too large to be rendered into a texture"
解决方案If you looked in your logs you will notice an error like so:
04-04 10:39:06.314: W/OpenGLRenderer(6092): Shape path too large to be rendered into a texture
Since turning on hardware acceleration everything gets rendered as a texture and there is a size limit for textures. If you break down the larger shapes into smaller ones, that will solve your problem. Or just turn off hardware acceleration:
android:hardwareAccelerated="false"
这篇关于Android路径实时图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!