Editing Source code of AChart Engine (Pie Chart) - android

i am trying to edit the source code of AChart Engine which is very good,
I need to reduce the margin above the pie chart i have tried with renderer.setMargins() but not working,and also i need the chart to be bit bigger which should work for all screen sizes.
I have added the pie chart to a LinerLayout and i have a Scroll View to that linear layout but when i scroll down the pie chart shrinks.
There is some margin below thew legends how to remove that?
please share your views on this and help me.

I told you before that you are asking several questions in a single one. However, I will answer them anyway:
Play with the value you pass to the renderer.setScale() method.
Use renderer.setInScroll(true).
Use renderer.setFitLegend(true).

For the 2nd case use renderer.setZoomEnabled(false, false); and renderer.setPanEnabled(false, false);

Related

How to have numbered scale with Seekbar (Android)?

I am trying to customise Seekbar. I need Seekbar like :
How do I add numbered scale to Seekbar as shown in image above?
I have been able to make custom thumb and custom progress drawable simply by using their vectors, in XML, as:
android:thumb="#drawable/custom_seekbar_thumb"
android:progressDrawable="#drawable/custom_seekbar_progress"
android:splitTrack="false"
But I have not been able to use the numbered scale as shown in the image.
Some answers on stack overflow say about how to draw numbers above/below Seekbar, but I couldn't find any information on how to draw the vertical line (|) below each number.
Any help would be appreciated. Thanks!
There is a method setTickMark and xml attribute android:tickMark that can be used to draw vertical lines. But there are two problems. The first one is it is only available in api 24+. The second one is that all the ticks would be the same and in your design they are different.
Unless you find a library that does exactly what you need, your best option is to create a custom view by subclassing/copying SeekBar and customizing the onDraw method.

How to set major and minor grid lines using Androidplot?

I’m trying to implement the following chart using Androidplot, and I’m wondering how to set the major and minor grids as shown in the picture with Androidplot? Is it using setLinesPerRangeLabel to achieve it? I’m new to Androidplot so some sample code will be of great help, thanks!
Try playing around with setRangeStep() and setLinesPerRangeLabel() (use setDomainStep() & setLinesPerDomainLabel() for domain)
For the step I use StepMode.SUBDIVIDE. When the setLinesPer[Range/Domain]Label is high enough you should start to see the thicker graph lines.

MPAndroidChart Labels displays all in one line - Need to wrap

I am creating a chart using MPAndroidChart with 10 data sets using one of the examples provided. My labels are displaying all on one single line and are not wrapping. They are getting chopped off on the right.
Legend l = mChart.getLegend();
l.setForm(Legend.LegendForm.SQUARE);
l.setPosition(Legend.LegendPosition.BELOW_CHART_LEFT);
I would like to display the labels in multi-lines. Any ideas please?
Currently this library does not support a "wrapping" mechanism for the Legend.
However a workaround could be to set the legend-position to be somewhere right of the chart.
In that way there should be more space for entries when they are aligned vertically instead of horizontally.

How to draw a dynamic graph?

I have to draw a dynamic graph of data from a database in android
Any example code regarding this will be appreciated.
I like GraphViz for generating graphs as .gif files.
So...many...graph questions...
Read here: https://stackoverflow.com/questions/5156740/im-looking-for-fancy-charts-library-for-android/5157576#5157576
TeeChart beta is public: http://steema.com/entry/60
Can heavily recommend TeeChart, it's a great library. Been using it for a while now. Since I haven't put this anywhere yet, here's a bit of my "how-to" document:
TeeChart info:
Disable 3D: chart.getAspect().setView3D(false);
Disable Legend: chart.getLegend().setVisible(false);
Disable footer: chart.getFooter().setVisible(false);
Disable header: chart.getHeader().setVisible(false);
SOLVED - How to set marks to data value instead of cylinder number?
For a Bar data-set: bar.getMarks().setStyle(MarksStyle.VALUE);
SOLVED - How to move the marks closer to the chart rectangle?
bar.getMarks().setArrowLength(5); - or negative values to put them on top of the bar
SOLVED - Different styles:
bar.setBarStyle(BarStyle.RECTANGLE);
SOLVED - How do I put a heavier color reference (in terms of readability) on the legend? Thicker (higher) line, not wider
chart.getLegend().setColorWidth(100); makes it wider, but not thicker or anything
chart.getLegend().setFontSeriesColor(true); helps with the issue by also coloring the text
line.getLinePen().setWidth(5); works, but it will change the width of the line as well.
No legend callback yet.
SOLVED - How do I make the lines thicker in a graph?
line.getLinePen().setWidth(5); works, but it will change the width of the Legend as well.
SOLVED - How do I change the color of labels on axes?
chart.getAxes().getLeft().getLabels().getFont().setColor(Color.WHITE);
chart.getAxes().getBottom().getLabels().getFont().setColor(Color.WHITE);
SOLVED WORKAROUND - How do I set the background color of the chart itself? Tried so far (the TChart methods that take a Color from the TChart Color class, not the View methods) - only managed to make the 'surrounding' area black.
chart.setBackground(Color.BLACK);
chart.getCanvas().setBackColor(Color.BLACK);
chart.getGraphics3D().setBackColor(Color.BLACK);
---> WORKAROUND: Use the setBackground above, then use: chart.getWalls().getBack().setVisible(false); --- setColor() on walls is bugged?
SOLVED - How to choose the bounds of a chart manually?
chart.getAxes().getLeft().setAutomatic(false);
chart.getAxes().getLeft().setMinMax(-2, 2);

Android Layout On Top of an Image

I am struggling with a Layout Problem on Android. This is very simple to do on the iPhone, but with the various screen sizes and the Layout classes available. I am having a hard time doing this.
One thing that I have noticed is that setting backgrounds on objects in the xml really messes up the layout on the device. I generally have to put in a FrameLayout and an ImageView to get a background.
So Am trying to get to this. http://www.calidadsystems.com/images/AndroidListItem.png (Sorry I don't have enough pts to post the image)
his is a status view and is an item in a List View. There are 8 TextViews that need to be set. Each of the 222 fields will change. The current background has the colors in there at specific locations and I am trying to line up the Labels and TextViews to get the picture below. I built this one with AbsoluteLayout which is deprecated, but it also does not work very well on the device.
I have constantly struggled with the layouts on Android. Does someone have some good sample code that could do this?
You're probably going to want to use a RelativeLayout. You can use the android:layout_alignTop="id" attribute to make the rows be in line correctly. And android:layout_alignLeft="id" for the columns. Other than that its just a matter of playing with the android:layout_marginLeft="XXdip" attribute to get the space between them how you want it. Check out this page for an overview and examples of all of the Layout types. Here is some more sample RelativeLayout code. And one more page with another example. RelativeLayout is a bit tricky to get used to but once you've used it a few times its pretty easy to understand and get the Layout that you want. The benefit of it is that your UIs look nice on several different screen sizes when you define them this way.
Why not just composed the layout in a table layout and set the table layout's background to a custom made graphic you make? This should work well with you. Specifically the design of your design would be like 4 columns with x rows. Then using the strechcolumn property, you should be able to accomplish what you are trying to do!
If you scale the graphic properly, then you shouldn't have this problem overall.

Categories

Resources