aChartEngine works real slow with large data - android

I'm working on achartengine (achartengine-1.0.0) in android app, it works fine with small data like <= 600, but when I draw points about 2000+ ( will use about 8000 or more), graph gets real slow!! even if user waits for delay but when touches it and moves the graph, graph takes quite long again!
How can I get rid of this slowness?
Thanks in advance

The 1.1.0 version has a set of performance improvements included. You can download this version here.
Most of the time is spent on rendering, so this is where you can improve things:
Disable antialiasing mRenderer.setAntialiasing(false);
Don't use PointStyles
Other suggestions:
Add only data that is to be displayed into the model. How does a chart with 2000 points look like?

As Leco mentioned in the comments above, removing setLineWidth() or setting it to a lower value did improve the performance a lot.

Related

Anychart X-Axis Data Overflow

Anyone know how to deal with a situation where you have too much data to fit onto the screen in a line chart on mobile?
When I have 20 observations in a time series on the X-axis, everything is OK. When I have 100, the data starts to write over itself.
Do I need to sample the data myself or is there a function in AnyChart for tick sampling?
Any help appreciated.
If you need to reduce the number of ticks on the X-Axis you can add the following line to your code:
chart.xScale().ticks().interval(4);
It makes the chart to show a tick for every 4 points.
If I got your idea in the wrong way, please, provide more details about your issue.

achartengine - plotting moving and still graphs

Is there any efficient way of doing this? My screenshot from Android device
As for now I am reading accelerometer data
(all graphs are moving to the left edge of screen) and compare them with my black threshold.
When new accelerometer single data arrives, I plot all three values (red,blue,black). This means adding three new points to the correspondent series at the end and removing the first point from series (to enable 'movement').
Is there an option to avoid adding new points to the black graph (threshold) to make it plot in an efficient manner? Or maybe this is quite efficient option, huh?
There are many options to do graphing. If you want static graphing you can use these API's/code samples.
AChartEngine
Simple Line Chart
Draw a Graph
Charts4j
AndroidPlot - one of the best looking ones, does dynamic plots too and is now open sourced.
TeeChart
So many others to choose from but most are static and non of these can handle real time data plots, i.e. ECG wave forms. One example you might want to look at is the Tricorder android example. Problem it is really complex to setup and if you just want the graphs, there is so much code to rip out. It can be done but I even noticed there is a lag the longer you run the program.
So far the only way I have found a real good dynamic graphing, is to do it yourself and use the SurfaceView and then draw usin the path.lineTo() see below for previous SO answer for this solution.
SO example:

Android OpenCV optimization - line detection is slow Hough Lines

in my project I need to detect lines in image. I actually have to detect rows and columns inside rectangle. I use OpenCV to accomplish this. I have done it succesfuly but it's kinda slow. I use many functions to preprocess the image - e.g. thresholding, canny, dilation, gaussian blur etc.
I use HoughLines like this
Imgproc.HoughLines(image, lines, 1, Math.PI/90 , threshold, minLineSize, maxGap);
It takes about 2.5 s to complete my program which has ~ 600 lines. But on this one line it takes 2.2 s. As you can see I use Java interface for OpenCV. Is it possible to optimize it someway? Would rewriting my program to NDK make it faster? If I understand OpenCV4Android, than it's just wrapper for functions written in NDK, so I don't think it would be faster. Or is there better and faster approach to detect lines in image? Thanks for any advice.
Can you count the number of lines returned from HoughLines - if there are 1000's then it will likely take that sort of time to generate.
I'd recommend changing your Canny settings to reduce the number of edges that HoughLines needs to work on if possible.
Also, you can try different parameters for HoughLines. My values of 80, 30 and 10 respectively for the call to HoughLines seems to give manageable results.

I want to make a rectangle slowly extend across the screen taking exactly 1 second in android

Basically, I am making a rectangle that represents charge on your weapon. I want a green rectangle to advance over a red one after a certain amount of time. My issue is the timing. I have no clue how to do any timing anything in android.I'm fairly new so don't use too many things I might not understand. All of this is within a view. I researched threading and handlers, but just got confused.
Check out View Animations if you want to support pre 3.0 without using a library. OR Property Animations if targetting 3.0+ is ok.
I have more experience with the View Animations and I can tell you that the Scale animation is the one you'd be looking for. Make your X scale to 100% its size perhaps would get the job done.

Cocos2d android Texture issue on Motorola xoom

I am developing a game in android with Cocos2d framework with latest build from github(Weikuan Zhou).
In my game, I used lots of images(total images size is around 11MB).
Problem:
I am getting the black box instead of images when I play my game more than 3 times.
What steps will reproduce the problem?
1. When I play my game more than 3 times via "Play Again" functionality of my game.
What is the expected output? What do you see instead?
- images should be displayed properly instead of "BLACK BOX".
and in my logcat, I see the Heap memory goes around 13Mb.
I already release Texture via below method
CCTextureCache.sharedTextureCache().removeAllTextures();
I also tried to remove sprite manually ex. removeChild() method.
But so far not succeeding to find any solution.
If any one have solution for this please let me know.
From what you're describing, you're hitting exactly the same problem i did, which is that cocos2d for android is really buggy when dealing with lots of single sprites loaded individually.
The best route to take to resolve this problem is to get hold of (unless you've got a mac) the free flash version of zwoptex from here http://zwopple.com/zwoptex/static/downloads/zwoptex-flashversion.zip
this will let you build up spritesheets, i suggest relating as many sprites as you can onto each sheet, whilst trying to keep them sensibly grouped.
This is mainly down to cocos doing a single render for ALL sprites in a spritesheet, rather than one render per sprite for normal sprites, hence massively reduced processing time, and much less memory usage.
you can then load the spritesheet with code such as (can't guarantee this code will execute as i'm grabbing snippets from a structured project but it will lead you to the right solution)
CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFrames("menus.plist"); // loads the spritesheet into the frame cache
CCSpriteSheet menuSpriteSheet = CCSpriteSheet.spriteSheet("menus.png", 20); // loads the spritesheet from the cache ready for use
.... // menu is a CCLayer
CCSprite sprite = CCSprite.sprite(CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName("name of sprite from inside spritesheet.png"));
menuSpriteSheet.addChild(sprite, 1, 1); / you add the sprite to its spritesheet
menu.addChild(menuSpriteSheet, 1); // then add the spritesheet to the layer
This problem happens when you load resources at run time. So it is better to load resources before the scene starts.You can do as follows.
Using the sprite sheets for resources in your game.
Implement your Ui in constructor of your class.
Implement your functionality in overridden method onEnter() in your layer.
You must unload your sprite sheets after finishing your scene.
These is the procedure that I am following.
Thanks.

Categories

Resources