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.
Related
I need to show chart with dashed line in my application. I am using MpAndroidChart to achieve it. It works, but when data contains too much values, it works incorrectly. For example:
Only 7 values on chart:
Over 500 values:
How to fix it?
The library behaves as expected. The problem is that you are providing too many data points so that the curve overlaps itself (and thus the dashing is displayed as in your image).
Depending on your use case I can suggest the following solutions:
Reduce the line width (probably not sufficient in your case)
Smooth the data points (on this page an overview of possible methods is given)
Hi I am new to Android and I am currently experimenting with some Android features.
So I wanted to find a way to add flexibly add slices to a disk image (could be a pie chart or a roulette wheel). I have done some research on this topic, Drawable Resources | Android. If I wanted to insert a slice dynamically, I think the InsetDrawable method would best suit my situation. So that a bitmap would not be recreated every time the image changes. I have also gone over some tutorial on how to change Cartesian coordinates into Polar coordinates Android SDK: Creating a Rotating Dialer. I was hoping to combine the InsetDrawable method with the polar coordinates to achieve this function. So I was wondering if can anyone tell me whether or not my thoughts are feasible?
A sample of the image that I would like to get is shown below:
Instead of having 6 slices, the user could add more elements to populate the disk to make it 8 or 10 slices, or remove slices from the disk.
It would be great if anyone can share a link to some of the related topics or tutorials as such.
Thanks in advance :)
What is that you exactly want? If you want to dynamically add a slice every time you click a button, all you have to do is arrange the 6 slices in the form of a circle in the xml as 6 ImageViews. You will have to make these ImageViews invisible initially. And inside the onClick function of the button you make the ImageViews visible one by one.
I've been working with Androidplot library for generating line plots and be able to do zoom and pan, so I'm using a modified version of XYPlotZoomPan class.
My current chart is showing some values per day, in a range of dates, so if I'm showing 7 days the domain axis is readable but if I'm trying to show 30 days it turns into a mess.
My goal is to show 7 days and have the option of scrolling through the rest of the chart that is not shown.
The only function that handles boundaries is setDomainBoundaries, currently I've tried this:
setDomainBoundaries(min, max, BoundaryMode.FIXED);
But it lets me show values inside this range and I'm loosing the ability for panning through the rest of the days.
Does someone have an a idea how I can do that? Thanks.
You can create your own domain value format with myplot.setDomainValueFormat(Format f). From here you can create your own formatter.
Another option you can look at is setDomainStep, a good example of that can be found here
I have to design the following layout:, which basically resembles a planner. Here, I have to show schedule for whole week. So far, I had completed the following part .
Now, I am stuck with this part: . I am not getting idea to design this part.
The highlighted portion in the grid indicates an event at that time. My problem is how can I make grids the one illustrated.
I would use 2D graphics and draw it completely in code.
It will be really hard to use xml to achieve this design, You could give it a shot with AbsoluteLayout but it is deprecated.
As about algorithm how to do it, first define a range of hours Your timetable will have,
You don't need full 24h, if all events are in range 8am-8pm for example displaying hours from 8pm to 8am would be a waste of sapce.
Get size of screen and calculate a size of one rectangle for the smallest time-frame.
And later it is simple maths to calculate position and size of rectangle to represent event.
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.