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)
Related
Below is the chart I am trying to create using MPAndroidChart library:
required_graph
To create this graph, I need some way to tell the linechart to only show two y-values "Average" and "You". I also need a way to draw a vertical grid-line that only goes up to the circle/y-value. I have searched for tutorials, SO articles, issues on MPAndroidChart github as well as the wiki, but I'm still uncertain how to create the graph above. Is there a way to create this graph with MPAndroidChart? Any help is much appreciated.
Try creating multiple data sets and style them differently. The 1st one should contain all the values, including "Average" and "You", enable fill color and disable drawing the circles.
Then, create a new set with a single value (average) and give it a different style. Do the same with the "you" value.
Good luck !
I am creating a line chart using MPAndroidChart, all is working great, but I've noticed that at the labels often become bunched up. I know there is a way to prevent this (I've seen other apps that don't have this issue,) but I don't know what setting to enable.
There are a couple of ways you could make the labels fit better.
Decrease the text size of the X axis labels with mChart.getXAxis().setTextSize(float)
Set a label count limit for the X axis using mChart.getXAxis().setLabelCount(int). This should work fine, as you are already not showing one label per data point.
Change the date format of your label.
Some, all or none of these might help you, depending on your requirements. Good luck!
I use MPAndroidChart, but cant make space between points. now I have this after opening my chart, but want to have this .
If you want tho reduce the maximum amount of values that can be shown at once, use this:
chart.setVisibleXRangeMaximum(10)
Its all in the wiki: https://github.com/PhilJay/MPAndroidChart/wiki/Modifying-the-Viewport
I want to implement single and multiple highlight line sliders in line chart. I am able to get only single highlight line slider with MPAndroidChart (https://github.com/PhilJay/MPAndroidChart) library. But I also need two highlight line sliders to allow the user to select range of values(min and max values) on the chart. Please refer the below image for more information:
Can we achieve the above requirement with any library or we need to draw a custom view?
Any help or guidance will be well appreciated.
In terms of shinobicharts, while the Crosshair could be easily customised to act like one of sliders, in order to have the two sliders you'd probably want to make use of the Annotations feature.
You can create Annotations with custom Views and add them at any X, Y point (in data terms). You can also convert between data values and pixel values via the Axes. It is therefore possible to make the Annotation follow the user's finger as they drag across the screen.
The trickiest part would be placing the circle on the LineSeries at the right Y-value. As I mentioned above you can convert pixel values (e.g. from a user gesture) to data values so you could easily get the X value but the API would leave quite a bit of work up to you in order to get the correct Y value.
This kind of feature is something that is requested quite often and is certainly something we are looking at providing in the future but for now, while possible, it isn't available out-of-the-box.
Disclaimer: I work for shinobicontrols
I'm using the WilliamChart library for Android.
Everything works perfect and now I want to set the axis color to white. I've tried with the following but that didn't change it:
chartview:chart_axisColor="#fff"
How can I change the axis color?
My second problem is that I have a chart where the numbers are higher than 500 but all about the same. So now I have all the dots of my line on top since the chart starts at 0.
Can WilliamChart figure out my lowest and highest number and fit the points in between?
I think I saw this somewhere but I couldn't find it in the example or the docs.
About the color, you're doing it right, so assuming you also defined:
xmlns:chartview="http://schemas.android.com/apk/res-auto"
it should work (if not raise the issue on github). The sample application has an example of it as well.
If you don't define any minimum and maximum value the library must calculate what they are. Perhaps you are defining them yourself with setAxisBorderValues and in that case the lib assumes those as correct.